-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparrot.py
57 lines (33 loc) · 1.3 KB
/
parrot.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 sys
from cryptography.fernet import Fernet
import os
from airtable import Airtable
if len(sys.argv) == 1:
print("Oops! Please provide command line arguments.")
else:
f = Fernet(input("Secret key: "))
api_key = input("Airtable API Key: ")
base_key = input("Airtable Base Key: ")
table = Airtable(base_key, 'Admins', api_key)
if sys.argv[1] == "new":
users_email = input("Admin Username: ")
users_password = f.encrypt(input("Admin Code: ").encode())
try:
table.insert({'Username': users_email,'Password': users_password.decode("utf-8") })
except:
print("Oops! There was an error. Please check you are using valid API crediantals.")
elif sys.argv[1] == "update":
users_email = input("Admin Username: ")
users_password = f.encrypt(input("New Admin Code: ").encode())
try:
table.update_by_field('Username', users_email, {'Username': users_email,'Password': users_password.decode("utf-8") })
except:
print("Oops! There was an error. Please check you are using valid API crediantals.")
elif sys.argv[1] == "remove":
users_email = input("Admin Username: ")
try:
table.delete_by_field('Username', users_email)
except:
print("Oops! There was an error. Please check you are using valid API crediantals.")
else:
print("Invalid command line arguments.")