forked from seungwonpark/ghudegy-chain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
27 lines (19 loc) · 849 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import subprocess
def check_work():
commit_num = subprocess.check_output("git rev-list HEAD --count", shell=True).decode('utf-8').strip()
commit_num = int(commit_num)
sha1 = subprocess.check_output("git rev-parse HEAD", shell=True).decode('utf-8').strip()
work = len(sha1) - len(sha1.lstrip('0'))
print(f"Number of commits done: {commit_num}")
print(f"SHA1 hash of latest commit: {sha1}")
print(f"Difficulty of work done in commit: {work}")
assert commit_num <= work, "Not enough work done."
def check_text():
with open('success.txt', 'r') as f:
lines = f.readlines()
assert len(lines) == 1, "success.txt must have only 1 line"
line = lines[0].strip()
assert len(line) <= 100, "Username must be shorter than 100 characters"
if __name__ == '__main__':
check_text()
check_work()