-
Notifications
You must be signed in to change notification settings - Fork 30
/
config.py
68 lines (65 loc) · 3.23 KB
/
config.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
66
67
68
import os
import json
# mirrors listed here
MIRRORS = [
('http', 'pypi.douban.com'),
('http', 'pypi.hustunique.com'),
('http', 'pypi.gocept.com'),
('http', 'pypi.tuna.tsinghua.edu.cn'),
('http', 'mirror.picosecond.org/pypi'),
('http', 'mirrors.aliyun.com/pypi'),
('http', 'pypi.pubyun.com'),
('http', 'mirrors-uk.go-parts.com/python'),
('http', 'mirrors-ru.go-parts.com/python'),
('http', 'mirrors-au.go-parts.com/python'),
]
EMAIL_OVERRIDE = None # None or "[email protected]"
def load_config():
# if at dotcloud load the dotcloud settings
dotcloud_config = '/home/dotcloud/environment.json'
if os.path.exists(dotcloud_config):
env = json.load(open(dotcloud_config))
return {'host': env['DOTCLOUD_CACHE_REDIS_HOST'],
'port': env['DOTCLOUD_CACHE_REDIS_PORT'],
'password': env['DOTCLOUD_CACHE_REDIS_PASSWORD'],
'db': 1,
'ip_api_key': env.get('IPLOC_API_KEY', None),
'twitter_consumer_key' : env.get('TWITTER_CONSUMER_KEY', None),
'twitter_consumer_secret' : env.get('TWITTER_CONSUMER_SECRET', None),
'twitter_access_key' : env.get('TWITTER_ACCESS_KEY', None),
'twitter_access_secret' : env.get('TWITTER_ACCESS_SECRET', None),
'email_host' : env.get('EMAIL_HOST', None),
'email_port' : env.get('EMAIL_PORT', None),
'email_user' : env.get('EMAIL_USER', None),
'email_password' : env.get('EMAIL_PASSWORD', None),
'email_from' : env.get('EMAIL_FROM', None),
'email_to' : env.get('EMAIL_TO', None),
'email_bcc' : env.get('EMAIL_BCC', None),
'email_to_admin': env.get('EMAIL_TO_ADMIN', None),
}
else:
# local config
dotcloud_config = '/tmp/environment.json'
if os.path.exists(dotcloud_config):
env = json.load(open(dotcloud_config))
return { 'host': 'localhost',
'port': 6379,
'password': None,
'db': 0,
'ip_api_key': env.get('IPLOC_API_KEY', None),
'twitter_consumer_key' : env.get('TWITTER_CONSUMER_KEY', None),
'twitter_consumer_secret' : env.get('TWITTER_CONSUMER_SECRET', None),
'twitter_access_key' : env.get('TWITTER_ACCESS_KEY', None),
'twitter_access_secret' : env.get('TWITTER_ACCESS_SECRET', None),
'email_host' : env.get('EMAIL_HOST', None),
'email_port' : env.get('EMAIL_PORT', None),
'email_user' : env.get('EMAIL_USER', None),
'email_password' : env.get('EMAIL_PASSWORD', None),
'email_from' : env.get('EMAIL_FROM', None),
'email_to' : env.get('EMAIL_TO', None),
'email_bcc' : env.get('EMAIL_BCC', None),
'email_to_admin': env.get('EMAIL_TO_ADMIN', None),
}
else:
print("can't find a local environment file here '/tmp/environment.json' ")
return None #TODO throw exception?