- refactored Status
- added update interval
This commit is contained in:
+19
-10
@@ -1,6 +1,18 @@
|
||||
class Status:
|
||||
def __init__(self):
|
||||
def __init__(self, update_interval=10):
|
||||
self.progress = -1
|
||||
self.update_interval = update_interval
|
||||
|
||||
@staticmethod
|
||||
def print_status(status: dict):
|
||||
print("-------------------------------------------")
|
||||
for key in status.keys():
|
||||
value = status[key]['value']
|
||||
unit = status[key]['unit']
|
||||
if isinstance(value, float):
|
||||
print(f"{key} : {value:0.6f}{unit}")
|
||||
else:
|
||||
print(f"{key} : {value}{unit}")
|
||||
|
||||
def on_change(self, status: dict) -> bool:
|
||||
if status == {}:
|
||||
@@ -8,14 +20,11 @@ class Status:
|
||||
|
||||
if "progress" in status.keys():
|
||||
progress = status["progress"]['value']
|
||||
if self.progress < 0 or progress - self.progress >= 10:
|
||||
if self.progress < 0 or progress - self.progress >= self.update_interval:
|
||||
self.progress = progress
|
||||
print("-------------------------------------------")
|
||||
for key in status.keys():
|
||||
value = status[key]['value']
|
||||
unit = status[key]['unit']
|
||||
if isinstance(value, float):
|
||||
print(f"{key} : {value:0.6f}{unit}")
|
||||
else:
|
||||
print(f"{key} : {value}{unit}")
|
||||
self.on_report(status=status)
|
||||
|
||||
return True
|
||||
|
||||
def on_report(self, status: dict) -> bool:
|
||||
return True
|
||||
Reference in New Issue
Block a user