Skip to content

Commit 58f3cc4

Browse files
committed
feat: auto OTP is optional while development
1 parent ce77857 commit 58f3cc4

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

gyft.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ def parse_args():
1616
"-D",
1717
"--development",
1818
action="store_true",
19-
help="Automate erpcreds parsing while development",
19+
help="Automate erpcreds parsing while development (except OTP)",
20+
)
21+
parser.add_argument(
22+
"-O",
23+
"--otp",
24+
action="store_true",
25+
help="Automate erpcreds parsing while development (including OTP)",
2026
)
2127
parser.add_argument(
2228
"-o", "--output", help="Output file containing timetable in .ics format"
@@ -44,16 +50,31 @@ def main():
4450
output_filename = args.output if args.output else "timetable.ics"
4551

4652
session = requests.Session()
53+
54+
if args.otp and not args.development:
55+
print('ERROR: -O [--otp] must be used with -D [--development]')
56+
return
57+
4758
if args.development:
48-
import erpcreds
49-
50-
_, sso_token = erp.login(
51-
headers,
52-
session,
53-
ERPCREDS=erpcreds,
54-
OTP_CHECK_INTERVAL=2,
55-
LOGGING=True,
56-
)
59+
if args.otp:
60+
import erpcreds
61+
62+
_, sso_token = erp.login(
63+
headers,
64+
session,
65+
ERPCREDS=erpcreds,
66+
OTP_CHECK_INTERVAL=2,
67+
LOGGING=True,
68+
)
69+
else:
70+
import erpcreds
71+
72+
_, sso_token = erp.login(
73+
headers,
74+
session,
75+
ERPCREDS=erpcreds,
76+
LOGGING=True,
77+
)
5778
else:
5879
_, sso_token = erp.login(headers, session)
5980

0 commit comments

Comments
 (0)