2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

master,client: support repository rescan

This commit is contained in:
Sebastien Bourdeauducq 2015-07-17 18:55:48 +02:00
parent 4907991ea3
commit 6b36d93cc2
3 changed files with 20 additions and 3 deletions

View File

@ -82,6 +82,9 @@ def get_argparser():
"what",
help="select object to show: schedule/devices/parameters")
parser_scan_repository = subparsers.add_parser(
"scan-repository", help="rescan repository")
return parser
@ -134,6 +137,10 @@ def _action_del_parameter(remote, args):
remote.delete(args.name)
def _action_scan_repository(remote, args):
remote.scan_async()
def _show_schedule(schedule):
clear_screen()
if schedule:
@ -228,6 +235,7 @@ def main():
"del_device": "master_ddb",
"set_parameter": "master_pdb",
"del_parameter": "master_pdb",
"scan_repository": "master_repository"
}[action]
remote = Client(args.server, port, target_name)
try:

View File

@ -56,18 +56,19 @@ def main():
scheduler.start()
atexit.register(lambda: loop.run_until_complete(scheduler.stop()))
repository = Repository()
repository.scan_async()
server_control = Server({
"master_ddb": ddb,
"master_pdb": pdb,
"master_schedule": scheduler,
"master_repository": repository
})
loop.run_until_complete(server_control.start(
args.bind, args.port_control))
atexit.register(lambda: loop.run_until_complete(server_control.stop()))
repository = Repository()
loop.run_until_complete(repository.scan())
server_notify = Publisher({
"schedule": scheduler.notifier,
"devices": ddb.data,

View File

@ -54,8 +54,16 @@ def _sync_explist(target, source):
class Repository:
def __init__(self):
self.explist = Notifier(dict())
self._scanning = False
@asyncio.coroutine
def scan(self):
if self._scanning:
return
self._scanning = True
new_explist = yield from _scan_experiments()
_sync_explist(self.explist, new_explist)
self._scanning = False
def scan_async(self):
asyncio.async(self.scan())