-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSETUP.py
33 lines (26 loc) · 1.11 KB
/
SETUP.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
import json
import re
CONFIG_FILE = 'config.json'
# Prompt user for email account details to use
while True:
recipient_email = input('Enter an email address to receive cinema listings: \n')
if not re.match("[^@]+@[^@]+\.[^@]+", recipient_email): # rough check for email format
print('Invalid address! Please enter a valid email address')
else:
break
while True:
sender_email = input('Enter the email address that will be used to send the listings (MUST be a Gmail account): \n')
if not re.match("[^@]+@[^@]+\.[^@]+", sender_email): # rough check for email format
print('Invalid address! Please enter a valid email address')
else:
break
sender_pwd = input('Enter the password associated with this email account: \n')
# Build dictionary with email account details
config = {'recipient_email': recipient_email,
'sender_email': sender_email,
'sender_pwd': sender_pwd
}
# Write dictionary to JSON config file
with open(CONFIG_FILE, 'w') as outfile:
json.dump(config, outfile)
print('User config info saved!')