Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How I monitor progress in python
import sys, os, datetime
from time import time
def update_progress(total_imported, skipped_files, current_location):
text = str(total_imported) + "/" + str(total_imported+skipped_files) + " imported. Looking in folder: " + current_location
sys.stdout.write('\r' + text)
def main():
start_time = datetime.datetime.fromtimestamp(time())
print("Starting program with the following parameters: " + str(sys.argv))
base_path = os.path.split(os.path.abspath(os.path.realpath(sys.argv[0])))[0]
update_progress(total_imported, skipped_files, base_path)
end_time = datetime.datetime.fromtimestamp(time())
total_time = dateutil.relativedelta.relativedelta(end_time, start_time)
print "\nImport completed in: %d days, %d hours, %d minutes and %d seconds" % (total_time.days, total_time.hours, total_time.minutes, total_time.seconds)
if __name__ == '__main__':
os.system('mode con: cols=150 lines=8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.