diff --git a/README.md b/README.md index a19b18b..747a233 100644 --- a/README.md +++ b/README.md @@ -71,28 +71,33 @@ _Внимание_! Только Python 2.7, только PostgreSQL, тольк 1. Установить lxml, через pip не ставится, так что качаем [отсюда](https://pypi.python.org/pypi/lxml/3.5.0). 2. Установить unrar.exe (можно установить WinRar целиком). 3. Установить sphinxapi последней версии (либо взять из директории Sphinx): + ``` python -m pip install https://github.com/Romamo/sphinxapi/zipball/master ``` ### Debian Linux -1. Установить libxml +1. Установить libxml: + ``` sudo apt-get install python-dev libxml2 libxml2-dev libxslt-dev ``` -2. Установить unrar (non-free) +2. Установить unrar (non-free): + ``` sudo sh -c 'echo deb ftp://ftp.us.debian.org/debian/ stable main non-free > /etc/apt/sources.list.d/non-free.list' sudo apt-get update sudo apt-get install unrar ``` -3. Установить sphinxapi последней версии: +3. Установить sphinxapi последней версии: + ``` pip install https://github.com/Romamo/sphinxapi/zipball/master ``` 4. Установить, собственно, приложение: - полностью: + ``` sudo mkdir -p /var/www/py-phias sudo chown www-fias: /var/www/py-phias @@ -102,6 +107,7 @@ _Внимание_! Только Python 2.7, только PostgreSQL, тольк sudo pip install -r requirements.txt ``` - как библиотеку: + ``` python -m pip install .... ``` \ No newline at end of file diff --git a/aore/miscutils/sphinx.py b/aore/miscutils/sphinx.py index f1a162e..580c6d9 100644 --- a/aore/miscutils/sphinx.py +++ b/aore/miscutils/sphinx.py @@ -17,6 +17,11 @@ class SphinxHelper: self.files = dict() self.aodp = DbHandler() + # Создаем временную папку, если ее нет + if not os.path.exists(folders.temp): + os.makedirs(folders.temp) + + def configure_indexer(self, indexer_binary, config_filename): logging.info("Start configuring Sphinx...") self.index_binary = indexer_binary diff --git a/aore/updater/aodataparser.py b/aore/updater/aodataparser.py index 5fe773e..32c6ff8 100644 --- a/aore/updater/aodataparser.py +++ b/aore/updater/aodataparser.py @@ -15,6 +15,10 @@ class AoDataParser: else: self.allowed_fields = db_shemas[self.datasource.table_name].fields + # Создаем временную папку, если ее нет + if not os.path.exists(folders.temp): + os.makedirs(folders.temp) + self.pagesize = pagesize self.currentpage = 0 self.counter = 0 diff --git a/aore/updater/aorar.py b/aore/updater/aorar.py index 4c6c305..8242a0f 100644 --- a/aore/updater/aorar.py +++ b/aore/updater/aorar.py @@ -21,8 +21,9 @@ class AoRar: try: local_filename = os.path.abspath(folders.temp + "/" + url.split('/')[-1]) if os.path.isfile(local_filename): - # TODO: UNCOMMENT os.remove(local_filename) - return local_filename + os.remove(local_filename) + else: + os.makedirs(local_filename) request = requests.get(url, stream=True) with open(local_filename, 'wb') as f: diff --git a/manage.py b/manage.py index 405b9d5..8983a4d 100644 --- a/manage.py +++ b/manage.py @@ -4,6 +4,7 @@ import logging import optparse import os import sys +import platform from aore.miscutils.sphinx import SphinxHelper from aore.updater.soapreceiver import SoapReceiver @@ -115,9 +116,9 @@ def main(): # Manage DB if options.database: - if not is_root(): + if 'Linux' in platform.system() and not is_root(): print "This option need to be run with elevated privileges." - # return + return # create new database aoupdater = Updater(options.source) @@ -134,7 +135,7 @@ def main(): # Manage Sphinx if options.sphinx and options.indexer_path and options.output_conf: - if not is_root(): + if 'Linux' in platform.system() and not is_root(): print "This option need to be run with elevated privileges." return sphinxh = SphinxHelper()