This repository has been archived by the owner on Aug 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_bash.py
57 lines (42 loc) · 2.71 KB
/
generate_bash.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import datetime
from pathlib import Path
# plaintext
with open("create_plaintext.sh", "w") as cb:
for f in sorted(Path("page/keys").iterdir()):
if f.name == ".gitkeep" or f.name == "removed" or f.name == "updated":
continue
cb.write(f"echo parsing {f}; python ../diagnosis-keys/parse_keys.py -d {f} > page/plaintext/{f.stem}.txt &\n")
cb.write("wait")
# users
with open("create_users.sh", "w") as cb:
for f in sorted(Path("page/keys").iterdir()):
if f.name == ".gitkeep" or f.name == "removed" or f.name == "updated":
continue
if datetime.datetime.fromisoformat(f.stem) > datetime.datetime.fromisoformat("2020-10-17"):
cb.write(f"echo parsing {f}; python ./create_users.py -m 1 -v v1.5 -d {f} > page/users/{f.stem}.txt &\n")
elif datetime.datetime.fromisoformat(f.stem) >= datetime.datetime.fromisoformat("2020-07-02"):
cb.write(f"echo parsing {f}; python ./create_users.py -n -m 5 -d {f} > page/users/{f.stem}.txt &\n")
elif "2020-06-23" in f.stem:
cb.write(f"echo parsing {f}; python ./create_users.py -m 10 -d {f} > page/users/{f.stem}.txt &\n")
else:
cb.write(f"echo parsing {f}; python ./create_users.py -d {f} > page/users/{f.stem}.txt &\n")
cb.write("wait")
# users hourly
with open("create_users_hourly.sh", "w") as cb:
for f in sorted(Path("page/keys_hourly").iterdir()):
if f.name == ".gitkeep" or f.name == "removed" or f.name == "updated":
continue
if datetime.datetime.fromisoformat(f.stem[: f.stem.rfind("-")]) > datetime.datetime.fromisoformat("2021-01-21"):
cb.write(f"echo parsing {f}; python ./create_users.py -m 1 -v v1.5 -d {f} > page/users_hourly/{f.stem}.txt &\n")
elif datetime.datetime.fromisoformat(f.stem[: f.stem.rfind("-")]) > datetime.datetime.fromisoformat("2020-07-02"):
cb.write(f"echo parsing {f}; python ./create_users.py -n -a -m 5 -d {f} > page/users_hourly/{f.stem}.txt &\n")
elif datetime.datetime.fromisoformat(f.stem[: f.stem.rfind("-")]) == datetime.datetime.fromisoformat("2020-07-02"):
if int(f.stem[f.stem.rfind("-") + 1 :]) > 11:
cb.write(f"echo parsing {f}; python ./create_users.py -n -a -d {f} > page/users_hourly/{f.stem}.txt &\n")
else:
cb.write(f"echo parsing {f}; python ./create_users.py -a -d {f} > page/users_hourly/{f.stem}.txt &\n")
elif "2020-06-23" in f.stem:
cb.write(f"echo parsing {f}; python ./create_users.py -m 10 -d {f} > page/users_hourly/{f.stem}.txt &\n")
else:
cb.write(f"echo parsing {f}; python ./create_users.py -d {f} > page/users_hourly/{f.stem}.txt &\n")
cb.write("wait")