From 7d07edb5deb22072f156c31f044d9abdc023e3a0 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 1 Nov 2019 20:31:39 +0100 Subject: [PATCH] Status changes --- sorteerhoed/HITStore.py | 2 +- sorteerhoed/central_management.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sorteerhoed/HITStore.py b/sorteerhoed/HITStore.py index 65c7abc..caba7c1 100644 --- a/sorteerhoed/HITStore.py +++ b/sorteerhoed/HITStore.py @@ -72,7 +72,7 @@ class HIT(Base): if self.submit_page_at: return "submitted by worker" if self.open_page_at: - return "started working" + return "working" if self.accept_time: return "accepted by worker" return "created" diff --git a/sorteerhoed/central_management.py b/sorteerhoed/central_management.py index a54d9a7..c0296a5 100644 --- a/sorteerhoed/central_management.py +++ b/sorteerhoed/central_management.py @@ -160,7 +160,6 @@ class CentralManagement(): self.currentHit.submit_page_at = datetime.datetime.utcnow() self.store.saveHIT(self.currentHit) self.plotter.park() - self.server.statusPage.set('state', self.currentHit.getStatus()) self.server.statusPage.set('hit_opened', self.currentHit.open_page_at) # park always triggers a plotter.finished after being processed @@ -218,15 +217,19 @@ class CentralManagement(): self.store.saveHIT(sqsHit) if updateStatus: + self.logger.warning(f'update status: {sqsHit.getStatus()}') # TODO: have HITStore/HIT take care of this by emitting a signal # only update status if it is the currentHit self.server.statusPage.set('state', sqsHit.getStatus()) + else: + self.logger.warning('DO NOT update status') elif signal.name == 'plotter.finished': if self.currentHit.submit_page_at: self.setLight(False) scan = threading.Thread(target=self.scanImage, name='scan') scan.start() self.server.statusPage.set('hit_submitted', self.currentHit.submit_page_at) + self.server.statusPage.set('state', self.currentHit.getStatus()) else: self.logger.critical(f"Unknown signal: {signal.name}") @@ -303,6 +306,7 @@ class CentralManagement(): proc = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) # opens connection to scanner, but only starts scanning when output becomes ready: _, e = proc.communicate(80) + time.sleep(5) # sleep a few seconds for scanner to return to start position if e: self.logger.critical(f"Scanner caused: {e.decode()}") @@ -346,6 +350,8 @@ class CentralManagement(): self.logger.exception(e) # TODO: create copyfile('www/basic.svg', filename) + + time.sleep(5) # sleep a few seconds for scanner to return to start position self.eventQueue.put(Signal('hit.scanned', {'hit_id':self.currentHit.id})) self.eventQueue.put(Signal('scan.finished'))