Проверка на root только для Linux (в винде не надо) + Fixes #4

This commit is contained in:
Jack Stdin 2016-02-14 16:15:10 +03:00
parent cb1da8dd5f
commit 61435791fc
5 changed files with 25 additions and 8 deletions

View File

@ -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 ....
```

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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()