Commit 2db51726 authored by Daniel Eggert's avatar Daniel Eggert
Browse files

updated example.py

parent 9482344f
if __name__ == "__main__":
from deprogressapi import ProgressReport, FormalProgressInterface
# dummy send handler
class ProgressImplementation(FormalProgressInterface):
def send(self, progress_json: str):
pass
# create the (dummy) send handler
progress_send_handler = ProgressImplementation()
# create the root report
pr1 = ProgressReport('Init', send_handler=progress_send_handler, steps=2)
# create a sub report
pr1_sub1 = pr1.create_subreport(step_message='Step 1.1 - Download')
# run the corresponding task ...
# complete the sub report
pr1_sub1.complete()
# create another sub report with pre-determined number of steps
pr1_sub2 = pr1.create_subreport(step_message='Step 1.2 - Process Download', steps=2)
# create corresponding sub-sub reports
pr1_sub21 = pr1_sub2.create_subreport(step_message='Step 1.2.1 - Process Download')
# ...
pr1_sub21.complete()
pr1_sub22 = pr1_sub2.create_subreport(step_message='Step 1.2.2 - Process Download')
# ...
pr1_sub22.complete()
pr1_sub2.complete()
pr1.complete()
from deprogressapi import ProgressReport, FormalProgressInterface
class ProgressImplementation(FormalProgressInterface):
def send(self, progress_json: str):
pass
progress_send_handler = ProgressImplementation()
pr1 = ProgressReport('Init', send_handler=progress_send_handler, steps=2)
pr1_sub1 = pr1.create_subreport(step_message='Step 1.1 - Download')
pr1_sub2 = pr1.create_subreport(step_message='Step 1.2 - Process Download', steps=2)
pr1_sub21 = pr1_sub2.create_subreport(step_message='Step 1.2.1 - Process Download')
pr1_sub22 = pr1_sub2.create_subreport(step_message='Step 1.2.2 - Process Download')
data = progress_send_handler.get_data()
print(data['step_message'] == 'Init')
print(data['children'][0]['step_message'] == 'Step 1.1 - Download')
print(data['children'][1]['children'][0]['step_message'] == 'Step 1.2.1 - Process Download')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment