From ad70ef77426ed99f90c90b6700a43b90993be92e Mon Sep 17 00:00:00 2001 From: jar3b Date: Sat, 12 Mar 2016 20:14:28 +0300 Subject: [PATCH] Fixes #7 --- aore/miscutils/bottlecl.py | 4 ++-- aore/phias.py | 4 ++-- aore/updater/updater.py | 20 ++++++++++++++++++-- config.example.py | 8 ++++---- passenger_wsgi.py | 4 ++-- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/aore/miscutils/bottlecl.py b/aore/miscutils/bottlecl.py index 210d8b5..371338a 100644 --- a/aore/miscutils/bottlecl.py +++ b/aore/miscutils/bottlecl.py @@ -20,5 +20,5 @@ class BottleCL(object): else: self._app.error_handler[error_code] = handler - def start(self, host, port): - self._app.run(host=host, port=port) + def start(self, **kwargs): + self._app.run(**kwargs) diff --git a/aore/phias.py b/aore/phias.py index eda1d97..b195816 100644 --- a/aore/phias.py +++ b/aore/phias.py @@ -9,9 +9,9 @@ from miscutils.bottlecl import BottleCL class App(BottleCL): - def __init__(self): + def __init__(self, log_filename): super(App, self).__init__() - logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) + logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO, filename=log_filename) self._factory = FiasFactory() diff --git a/aore/updater/updater.py b/aore/updater/updater.py index a4b12b0..0568819 100644 --- a/aore/updater/updater.py +++ b/aore/updater/updater.py @@ -55,11 +55,27 @@ class Updater: finally: db.close() + # Получает верию ФИАС с клавиатуры (если мы берем базу из папки или локального архива и не можем определить, + # что это за версия + @staticmethod + def __get_update_version_from_console(): + mode = None + while not mode: + try: + mode = int(raw_input('Enter FIAS update version (3 digit):')) + except ValueError: + print "Not a valid fias version, try again." + + return mode + def __get_updates_from_folder(self, foldername): # TODO: Вычислять версию, если берем данные из каталога - yield dict(intver=0, textver="Unknown", delta_url=foldername, complete_url=foldername) + yield dict(intver=self.__get_update_version_from_console(), + textver="Unknown", delta_url=foldername, + complete_url=foldername) - def __get_updates_from_rar(self, url): + @staticmethod + def __get_updates_from_rar(url): aorar = AoRar() if url.startswith("http://") or url.startswith("https://"): diff --git a/config.example.py b/config.example.py index 8f32d5d..cc0d46c 100644 --- a/config.example.py +++ b/config.example.py @@ -2,16 +2,16 @@ from aore import config # Config section -config.sphinx_conf.listen = "192.168.0.37:9312" +config.sphinx_conf.listen = "127.0.0.1:9312" config.sphinx_conf.var_dir = "C:\\Sphinx" config.db_conf.database = "pyfias" -config.db_conf.host = "192.168.0.37" +config.db_conf.host = "192.168.0.1" config.db_conf.port = 5432 config.db_conf.user = "postgres" -config.db_conf.password = "intercon" +config.db_conf.password = "postgres" -config.unrar_config.path = "C:\\Program Files (x86)\\WinRAR\\unrar.exe" +config.unrar_config.path = "C:\\Program Files\\WinRAR\\unrar.exe" config.folders.temp = "E:\\!TEMP" config.basic.logging = True diff --git a/passenger_wsgi.py b/passenger_wsgi.py index 4dfa1b9..48a287f 100644 --- a/passenger_wsgi.py +++ b/passenger_wsgi.py @@ -9,8 +9,8 @@ except ImportError: assert "No config" # Define main app -application = phias.App() +application = phias.App("pyphias.log") # Run bottle WSGI server if no external if __name__ == '__main__': - application.start('0.0.0.0', 8087) + application.start(host='0.0.0.0', port=8087, debug=True)