-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
52 lines (39 loc) · 1.61 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
# encoding: utf-8
GITHUB_SECRET_FILE = 'github/secret.py'
EVERNOTE_SECRET_FILE = 'enote/secret.py'
SETTING_FILE = 'settings.py'
NOTEBOOK = 'gist-evernote'
def initialize():
"""Use settings.py to setup/update environment"""
from settings import GITHUB_AUTH_TOKEN, \
EVERNOTE_PROD_TOKEN, EVERNOTE_SANDBOX_TOKEN
setting_str = ''
# setup github credential
while not GITHUB_AUTH_TOKEN:
GITHUB_AUTH_TOKEN = raw_input("Github Personal Access Token: ")
with open(GITHUB_SECRET_FILE, 'w') as f:
string = "GITHUB_AUTH_TOKEN = \"{}\"\n".format(GITHUB_AUTH_TOKEN)
f.write(string)
setting_str += string
# setup evernote credential
while not EVERNOTE_PROD_TOKEN:
EVERNOTE_PROD_TOKEN = raw_input("Evernote Production Developer Token: ")
with open(EVERNOTE_SECRET_FILE, 'w') as f:
string = "EVERNOTE_PROD_TOKEN = \"{}\"\n".format(EVERNOTE_PROD_TOKEN)
f.write(string)
setting_str += string
# optional for local debug
string = "EVERNOTE_SANDBOX_TOKEN = \"{}\"\n".format(EVERNOTE_SANDBOX_TOKEN)
f.write(string)
setting_str += string
# setup notebook
notebook = raw_input("Evernote notebook name you want to put gists (default set to {}): ".format(NOTEBOOK))
notebook = notebook if notebook else NOTEBOOK
setting_str += "NOTEBOOK_TO_SYNC = \"{}\"\n".format(notebook)
# update setting
with open(SETTING_FILE, "w") as f:
f.write(setting_str)
print("You're all set! run\n\n python app.py\n\nto start synchronization :) ")
return True
if __name__ == '__main__':
initialize()