diff --git a/README.md b/README.md index 97eba81..b2195e9 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,21 @@ Like this: - ```shell uoy-assessment-uploader --help ``` - + +Once it's submitted, you should receive an email to your uni address with confirmation. +The email will show you the MD5 hash, like so: + +> MD5 hash of file: 97f212cda7e5200a67749cac560a06f4 + +If this matches the hash shown by the program, you can be certain you successfully uploaded the right file. + ## Example ```shell uoy-assessment-uploader --username "ab1234" --exam-number "Y1234567" --submit-url "/2021-2/submit/COM00012C/901/A" ``` ``` Found file 'exam.zip'. - +MD5 hash of file: 05086595c7c7c1a962d6eff6872e18c0 [WDM] - Downloading: 100%|██████████| 6.98M/6.98M [00:00<00:00, 8.98MB/s] Loading cookies. Logging in.. @@ -38,4 +45,5 @@ Entering exam number.. Uploading file... Uploaded successfully. Saving cookies. +Finished! ``` diff --git a/uoy_assessment_uploader/__init__.py b/uoy_assessment_uploader/__init__.py index 3ea18ce..ec3f72f 100755 --- a/uoy_assessment_uploader/__init__.py +++ b/uoy_assessment_uploader/__init__.py @@ -1,6 +1,7 @@ """Tool for automating submitting assessments to the University of York Computer Science department.""" import getpass +import hashlib import sys from argparse import ArgumentParser from pathlib import Path @@ -17,7 +18,7 @@ from .selenium import enter_exam_number, load_cookies, login, save_cookies, upload -__version__ = "0.2.2" +__version__ = "0.3.0" # timeout for selenium waits, in seconds TIMEOUT = 10 @@ -177,15 +178,19 @@ def main(): args = Args() parser.parse_args(namespace=args) + # verify arguments + submit_url = resolve_submit_url(args.submit_url) # check zip to be uploaded exists if not args.file.is_file(): print(f"File doesn't exist '{args.file}'.") sys.exit(1) print(f"Found file '{args.file}'.") file_name = str(args.file.resolve()) - - # verify arguments - submit_url = resolve_submit_url(args.submit_url) + # display hash of file + with open(file_name, 'rb') as f: + # noinspection PyTypeChecker + digest = hashlib.file_digest(f, hashlib.md5).hexdigest() + print(f"MD5 hash of file: {digest}") # webdriver setup # options