Created
June 14, 2023 15:10
-
-
Save NoDataFound/6e8499d0dba947379da2503d2ba60890 to your computer and use it in GitHub Desktop.
simple python progress monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
# define progress file | |
progress_file = 'progress.json' | |
# read progress file to find place | |
if os.path.isfile(progress_file): | |
with open(progress_file, 'r') as progress_file: | |
progress = json.load(progress_file) | |
else: | |
progress = {'step': 0, 'completed_steps': []} | |
# define updating progress | |
def update_progress(step): | |
progress['step'] = step | |
progress['completed_steps'].append(step) | |
progress_file = 'progress.json' | |
with open(progress_file, 'w') as progress_file: | |
json.dump(progress, progress_file) | |
# Set progress step number to monitor | |
if progress['step'] < 1: | |
code_that_does = "stuff" | |
#update progress that the step is complete | |
update_progress(1) | |
if progress['step'] < 2: | |
code_that_does = "things" | |
update_progress(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment