diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2019-05-22 14:35:33 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2019-05-22 14:35:33 -0300 |
commit | 450371836069d844781ee3f02ae2d44b324359b8 (patch) | |
tree | b964128879b905c8cb1fb443d6f7ad6693f00354 | |
parent | e8e977182995073fcf1ce96c94a9c5c99fa98b2d (diff) | |
download | ckandumper-450371836069d844781ee3f02ae2d44b324359b8.tar.gz ckandumper-450371836069d844781ee3f02ae2d44b324359b8.tar.bz2 |
Record argument and duration
-rwxr-xr-x | ckandumper | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -164,7 +164,7 @@ class CkanDumper: def __init__(self, args): self.url = args.url[0] - self.dest = args.dest[0] + self.dest = ''.join(args.dest) self.package_list = '/api/3/action/package_list' self.package_show = '/api/3/action/package_show?' self.group_list = '/api/3/action/group_list' @@ -352,13 +352,29 @@ if __name__ == "__main__": try: start_time = time.time() + # Initialize our dumper ckan = CkanDumper(args) + + # Record date and invocation + logs = ''.join(args.dest) + os.sep + 'logs' + os.sep + ckan.download.ensuredir(logs) + invocation = open(logs + 'ckandumper.args', 'a') + invocation.write(str(datetime.datetime.now()) + '\t' + ' '.join(sys.argv) + '\n') + invocation.close() + + # Download everything we can ckan.dump() - interval = round(time.time() - start_time) + # Calculate runtime + end_time = time.time() + interval = round(end_time - start_time) duration = str(datetime.timedelta(seconds=interval)) + # Record duration print(f'Done. Elapsed time: {duration}') + elapsed = open(logs + 'ckandumper.duration', 'a') + elapsed.write(str(start_time) + '\t' + str(end_time) + '\t' + duration) + elapsed.close() except (FileNotFoundError, KeyboardInterrupt, subprocess.CalledProcessError) as e: print(e) exit(1) |