forked from fossasia/susi_linux
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauthentication.py
41 lines (35 loc) · 1.41 KB
/
authentication.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
""" Authentication Generator script for Susi Hardware. Run this script and input options
to generate a file for using SUSI in authenticated mode
To run this file use python3 authentication.py <choice_to_be authenticated> <email> <password>
"""
import sys
import json_config
config = json_config.connect('config.json')
def authenticating():
"""Method for setting authentication parameters in the configuration
:return: None
"""
try:
# choice = input('Do you wish to use SUSI in Authenticated Mode? (y/n)\n')
choice = sys.argv[1]
print(choice)
if choice == 'y':
# email = input('Enter SUSI Sign-in Email Address: ')
email = sys.argv[2]
print(email)
# password = input('Enter SUSI Sign-in Password: ')
password = sys.argv[3]
config['usage_mode'] = 'authenticated'
config['login_credentials']['email'] = email
config['login_credentials']['password'] = password
elif choice == 'n':
print('Setting anonymous mode as default')
config['usage_mode'] = 'anonymous'
else:
raise ValueError
except ValueError:
print('Invalid choice. Anonymous mode set as default. Run the configuration script again if you wish '
'to change your choice.')
config['usage_mode'] = 'anonymous'
print("Authenticating \n")
authenticating()