-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
66 lines (47 loc) · 1.75 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
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
from os import path
import sys, json, os
def ValidateFiles():
if not (path.isfile('settings.json')):
ManualCredEntry()
if not (path.exists('./memes')):
print('Could not find memes folder')
exit()
return
def ManualCredEntry():
print("Please manually enter your twitter credentials...")
consumerKey = input("Enter your consumer key: ")
consumerSecret = input("Enter your consumer secret: ")
accessKey = input("Enter your access key: ")
accessSecret = input("Enter your access secret: ")
data = { 'loginDetails':
{
'consumerKey' : consumerKey,
'consumerSecret' : consumerSecret,
'accessKey' : accessKey,
'accessSecret' : accessSecret}
}
with open('settings.json', 'x') as outfile:
json.dump(data, outfile, indent=4)
return
def WriteToSettingsFile(input):
data = { 'loginDetails':
{
'consumerKey' : consumerKey,
'consumerSecret' : consumerSecret,
'accessKey' : accessKey,
'accessSecret' : accessSecret}
}
def GetCredentialsFromFile():
try:
data_file = open(r"./settings.json")
data = json.load(data_file)
except IOError:
print("ERROR: Couldn't find settings.json")
ManualCredEntry()
CONSUMER_KEY = data["loginDetails"]["consumerKey"]
CONSUMER_SECRET = data["loginDetails"]["consumerSecret"]
ACCESS_KEY = data["loginDetails"]["accessKey"]
ACCESS_SECRET = data["loginDetails"]["accessSecret"]
creds = [CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET]
data_file.close()
return creds