diff --git a/artiq/frontend/artiq_client.py b/artiq/frontend/artiq_client.py
index 8dddaef7d..d4ce1926c 100755
--- a/artiq/frontend/artiq_client.py
+++ b/artiq/frontend/artiq_client.py
@@ -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("
" + 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:
diff --git a/artiq/master/experiments.py b/artiq/master/experiments.py
index 0dc96d7ab..b6ea84fca 100644
--- a/artiq/master/experiments.py
+++ b/artiq/master/experiments.py
@@ -109,7 +109,8 @@ class ExperimentDB:
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 @@ class ExperimentDB:
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):