Skip to content

Commit

Permalink
Add hashing feature
Browse files Browse the repository at this point in the history
  • Loading branch information
irismessage committed May 8, 2023
1 parent 6d6a354 commit cc9f5e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand All @@ -38,4 +45,5 @@ Entering exam number..
Uploading file...
Uploaded successfully.
Saving cookies.
Finished!
```
13 changes: 9 additions & 4 deletions uoy_assessment_uploader/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cc9f5e4

Please sign in to comment.