-
Notifications
You must be signed in to change notification settings - Fork 3
/
app-cli.py
69 lines (53 loc) · 2.14 KB
/
app-cli.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
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
import argparse
import signal
import atexit
from time import sleep
import datetime
import validators
from tlsBook import TlsChecker
checker: TlsChecker
def main():
global checker
parser = argparse.ArgumentParser()
parser.add_argument('email', help='Please enter the email you used to create your TLS application.')
parser.add_argument('password',
help='Please enter the password you used to create your TLS application (We will not record your password). if '
'your password contains special characters, put it in quotations marks')
parser.add_argument('target_emails',
help='Please enter a list of email recipients when there is an appointment separated by a comma character')
args = parser.parse_args()
emails = validators.concat_emails(args.email, args.target_emails)
if not args.target_emails or not validators.is_valid(emails):
print('Please provide valid email addresses')
exit(1)
if not validators.validate_required(args.password):
print('Password is required')
exit(1)
checker = TlsChecker(args.email, args.password, emails)
appointment_found = False
minutes = 2
failed_logins = 0
print('Starting TLS checking')
while not appointment_found and failed_logins < 3:
print(datetime.datetime.now())
loggedIn = checker.login()
if loggedIn:
failed_logins = 0
appointment_found = checker.check(loggedIn)
print('------------- Will try again in ' + str(minutes) + ' minutes ----------------------------')
sleep(60 * minutes) # 5 minutes
else:
failed_logins += 1
print("Something does not seem right with your credentials, I will try again, plz wait => try: " + str(failed_logins))
# break
def handle_exit():
global checker
if checker:
checker.terminate()
# Failsafe mechanism in case of program crashing
atexit.register(handle_exit)
signal.signal(signal.SIGTERM, handle_exit)
signal.signal(signal.SIGINT, handle_exit)
if __name__ == '__main__':
main()