From 126b74dfa4dc8ad15d368f40ada8ea94bc60ac58 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 5 Jun 2019 11:39:08 -0400 Subject: [PATCH] Better LRE progress updates Former-commit-id: 3ff0b9316f115f2f1cf98baff215e1e591562bb9 --- opendm/remote.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/opendm/remote.py b/opendm/remote.py index 5e0666cd..345c7024 100644 --- a/opendm/remote.py +++ b/opendm/remote.py @@ -339,10 +339,14 @@ class Task: # Add seed file images.append(seed_file) + class nonloc: + last_update = 0 + def print_progress(percentage): - if percentage % 10 == 0: + if (time.time() - nonloc.last_update >= 2) or int(percentage) == 100: log.ODM_DEBUG("LRE: Upload of %s at [%s%%]" % (self, int(percentage))) - + nonloc.last_update = time.time() + # Upload task task = self.node.create_task(images, get_submodel_args_dict(), @@ -363,6 +367,7 @@ class Task: def monitor(): class nonloc: status_callback_calls = 0 + last_update = 0 def status_callback(info): # If a task switches from RUNNING to QUEUED, then we need to @@ -378,8 +383,9 @@ class Task: nonloc.status_callback_calls = 0 try: def print_progress(percentage): - if percentage % 10 == 0: + if (time.time() - nonloc.last_update >= 2) or int(percentage) == 100: log.ODM_DEBUG("LRE: Download of %s at [%s%%]" % (self, int(percentage))) + nonloc.last_update = time.time() task.wait_for_completion(status_callback=status_callback) log.ODM_DEBUG("LRE: Downloading assets for %s" % self)