From 19d80f5811ce4eb5878915a4735494fb37af6c94 Mon Sep 17 00:00:00 2001 From: jar3b Date: Sat, 12 Mar 2016 19:54:24 +0300 Subject: [PATCH] Small config rework. Add .gitignore --- .gitignore | 1 + aore/phias.py | 7 ++++--- config.example.py | 17 +++++++++++++++++ passenger_wsgi.py | 24 +++++++----------------- 4 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 config.example.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f85c6b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.py \ No newline at end of file diff --git a/aore/phias.py b/aore/phias.py index 6b2bd77..eda1d97 100644 --- a/aore/phias.py +++ b/aore/phias.py @@ -3,16 +3,17 @@ import json import logging from bottle import response + +from aore.search.fiasfactory import FiasFactory from miscutils.bottlecl import BottleCL class App(BottleCL): - def __init__(self, config): + def __init__(self): super(App, self).__init__() logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) - self._config = config - # self._factory = FiasFactory() + self._factory = FiasFactory() def init_routes(self): self.add_route(r'/expand/', self.__expand) diff --git a/config.example.py b/config.example.py new file mode 100644 index 0000000..8f32d5d --- /dev/null +++ b/config.example.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +from aore import config + +# Config section +config.sphinx_conf.listen = "192.168.0.37:9312" +config.sphinx_conf.var_dir = "C:\\Sphinx" + +config.db_conf.database = "pyfias" +config.db_conf.host = "192.168.0.37" +config.db_conf.port = 5432 +config.db_conf.user = "postgres" +config.db_conf.password = "intercon" + +config.unrar_config.path = "C:\\Program Files (x86)\\WinRAR\\unrar.exe" +config.folders.temp = "E:\\!TEMP" + +config.basic.logging = True diff --git a/passenger_wsgi.py b/passenger_wsgi.py index c0845cb..4dfa1b9 100644 --- a/passenger_wsgi.py +++ b/passenger_wsgi.py @@ -1,25 +1,15 @@ # -*- coding: utf-8 -*- -from aore import phias, config -from bottle import run +from aore import phias -# Config section -# config.sphinx_conf.listen = "192.168.0.37:9312" -# config.sphinx_conf.var_dir = "C:\\Sphinx" -# -# config.db_conf.database = "pyfias" -# config.db_conf.host = "192.168.0.37" -# config.db_conf.port = 5432 -# config.db_conf.user = "postgres" -# config.db_conf.password = "intercon" -# -# config.unrar_config.path = "C:\\Program Files (x86)\\WinRAR\\unrar.exe" -# config.folders.temp = "E:\\!TEMP" -# -# config.basic.logging = True +# Load config +try: + from config import * +except ImportError: + assert "No config" # Define main app -application = phias.App('test-config-fname') +application = phias.App() # Run bottle WSGI server if no external if __name__ == '__main__':