-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
32 lines (24 loc) · 833 Bytes
/
config.py
File metadata and controls
32 lines (24 loc) · 833 Bytes
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
from ConfigParser import SafeConfigParser, NoOptionError
import os
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG = THIS_DIR + '/config.ini'
parser = SafeConfigParser()
parser.read(CONFIG)
APP_KEY = parser.get('oauth', 'client.key')
APP_SECRET = parser.get('oauth', 'client.secret')
LOCAL_IMG_DIR = parser.get('images', 'location')
def get_key():
return APP_KEY
def get_secret():
return APP_SECRET
def get_img_dir():
return LOCAL_IMG_DIR
def save_access_token(token_key, token_secret):
parser.set('oauth', 'access.key', token_key)
parser.set('oauth', 'access.secret', token_secret)
parser.write(open(CONFIG, 'w'))
def get_access_token():
try:
return parser.get('oauth', 'access.key'), parser.get('oauth', 'access.secret')
except NoOptionError:
return None, None