search for config.py in the present directory or in a directory above, and generate a good error if it cannot be found
This commit is contained in:
Родитель
e68bb924a6
Коммит
1697dc8896
15
server.py
15
server.py
|
@ -8,10 +8,21 @@ import os
|
|||
import base64
|
||||
import json
|
||||
import hashlib
|
||||
import config
|
||||
import urllib
|
||||
import cStringIO
|
||||
import mimetools
|
||||
import sys
|
||||
|
||||
# search for server configuration (API keys and such)
|
||||
CONFIG_FILE_NAME = 'config.py'
|
||||
if os.path.exists(CONFIG_FILE_NAME):
|
||||
import config
|
||||
elif os.path.exists(os.path.join("..", CONFIG_FILE_NAME)):
|
||||
sys.path.append('..')
|
||||
import config
|
||||
sys.path.pop()
|
||||
else:
|
||||
raise RuntimeError('no configuration file found: %s' % CONFIG_FILE_NAME)
|
||||
|
||||
class WebHandler(tornado.web.RequestHandler):
|
||||
def get_current_user(self):
|
||||
|
@ -362,4 +373,4 @@ if __name__ == '__main__':
|
|||
logging.basicConfig(level = logging.DEBUG)
|
||||
run()
|
||||
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче