Skip to content

Commit

Permalink
master: allow remote listing of directories
Browse files Browse the repository at this point in the history
sbourdeauducq committed Dec 8, 2015
1 parent ed08352 commit 7b25805
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion artiq/frontend/artiq_client.py
Original file line number Diff line number Diff line change
@@ -96,6 +96,10 @@ def get_argparser():
help="use a specific repository revision "
"(defaults to head)")

parser_ls = subparsers.add_parser(
"ls", help="list a directory on the master")
parser_ls.add_argument("directory")

return parser


@@ -154,6 +158,15 @@ def _action_scan_repository(remote, args):
remote.scan_repository(args.revision)


def _action_ls(remote, args):
contents = remote.list_directory(args.directory)
for name, is_dir in sorted(contents, key=lambda x: (-x[1], x[0])):
if is_dir:
print("<DIR> " + name)
else:
print(" " + name)


def _show_schedule(schedule):
clear_screen()
if schedule:
@@ -285,7 +298,8 @@ def main():
"set_dataset": "master_dataset_db",
"del_dataset": "master_dataset_db",
"scan_devices": "master_device_db",
"scan_repository": "master_experiment_db"
"scan_repository": "master_experiment_db",
"ls": "master_experiment_db"
}[action]
remote = Client(args.server, port, target_name)
try:
6 changes: 5 additions & 1 deletion artiq/master/experiments.py
Original file line number Diff line number Diff line change
@@ -109,7 +109,8 @@ async def scan_repository(self, new_cur_rev=None):
self._scanning = False

def scan_repository_async(self, new_cur_rev=None):
asyncio.ensure_future(exc_to_warning(self.scan_repository(new_cur_rev)))
asyncio.ensure_future(
exc_to_warning(self.scan_repository(new_cur_rev)))

async def examine(self, filename, use_repository=True):
if use_repository:
@@ -128,6 +129,9 @@ async def examine(self, filename, use_repository=True):
self.repo_backend.release_rev(revision)
return description

def list_directory(self, directory):
return [(de.name, de.is_dir()) for de in os.scandir(directory)]


class FilesystemBackend:
def __init__(self, root):

0 comments on commit 7b25805

Please sign in to comment.