Skip to content
Snippets Groups Projects
Commit 1bbe86e3 authored by Dmitry Shelepnev's avatar Dmitry Shelepnev
Browse files

Add sopds_util commands save_mygenres and load_mygenres

parent bd4f67ae
Branches
Tags
No related merge requests found
...@@ -250,6 +250,14 @@ MySQL по сравнению с sqlite работает гораздо быст ...@@ -250,6 +250,14 @@ MySQL по сравнению с sqlite работает гораздо быст
python3 manage.py sopds_util clear [--verbose] python3 manage.py sopds_util clear [--verbose]
Сохранить свой справочник жанров в файл opds_catalog/fixtures/mygenres.json:
python3 manage.py sopds_util save_mygenres
Загрузить свой справочник жанров из файла opds_catalog/fixtures/mygenres.json:
python3 manage.py sopds_util load_mygenres
Если вы используете MySQL и при очистке БД у вас возникла ошибка (2006, 'MySQL server has gone away'), Если вы используете MySQL и при очистке БД у вас возникла ошибка (2006, 'MySQL server has gone away'),
то добавьте в файл настройки /etc/my.cnf следующие настройки, после чего перезапустите сервер БД: то добавьте в файл настройки /etc/my.cnf следующие настройки, после чего перезапустите сервер БД:
......
This diff is collapsed.
...@@ -11,7 +11,7 @@ class Command(BaseCommand): ...@@ -11,7 +11,7 @@ class Command(BaseCommand):
verbose = False verbose = False
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('command', help='Use [ clear | info ]') parser.add_argument('command', help='Use [ clear | info | save_mygenres | load_mygenres ]')
parser.add_argument('--verbose',action='store_true', dest='verbose', default=False, help='Set verbosity level for books collection scan.') parser.add_argument('--verbose',action='store_true', dest='verbose', default=False, help='Set verbosity level for books collection scan.')
parser.add_argument('--nogenres',action='store_true', dest='nogenres', default=False, help='Not install genres fom fixtures.') parser.add_argument('--nogenres',action='store_true', dest='nogenres', default=False, help='Not install genres fom fixtures.')
...@@ -26,6 +26,10 @@ class Command(BaseCommand): ...@@ -26,6 +26,10 @@ class Command(BaseCommand):
self.clear() self.clear()
elif action == "info": elif action == "info":
self.info() self.info()
elif action == "save_mygenres":
self.save_mygenres()
elif action == "load_mygenres":
self.load_mygenres()
def clear(self): def clear(self):
with transaction.atomic(): with transaction.atomic():
...@@ -42,4 +46,14 @@ class Command(BaseCommand): ...@@ -42,4 +46,14 @@ class Command(BaseCommand):
self.stdout.write('Genres count = %s'%Counter.objects.get_counter(models.counter_allgenres)) self.stdout.write('Genres count = %s'%Counter.objects.get_counter(models.counter_allgenres))
self.stdout.write('Series count = %s'%Counter.objects.get_counter(models.counter_allseries)) self.stdout.write('Series count = %s'%Counter.objects.get_counter(models.counter_allseries))
def save_mygenres(self):
call_command('dumpdata', 'opds_catalog.genre','--output','opds_catalog/fixtures/mygenres.json', app_label='opds_catalog')
self.stdout.write('Genre dump saved in opds_catalog/fixtures/mygenres.json')
def load_mygenres(self):
opdsdb.clear_genres(self.verbose)
call_command('loaddata', 'mygenres.json', app_label='opds_catalog')
Counter.objects.update_known_counters()
self.stdout.write('Genres load from opds_catalog/fixtures/mygenres.json')
...@@ -54,6 +54,9 @@ def clear_all(verbose=False): ...@@ -54,6 +54,9 @@ def clear_all(verbose=False):
cursor.execute('delete from opds_catalog_bookshelf') cursor.execute('delete from opds_catalog_bookshelf')
cursor.execute('delete from opds_catalog_counter') cursor.execute('delete from opds_catalog_counter')
def clear_genres(verbose=False):
cursor = connection.cursor()
cursor.execute('delete from opds_catalog_genre')
# Книги где avail=0 уже известно что удалены # Книги где avail=0 уже известно что удалены
# Книги где avail=2 это только что прверенные существующие книги # Книги где avail=2 это только что прверенные существующие книги
......
...@@ -207,7 +207,7 @@ SOPDS_ROOT_LIB = 'W:\\_Downloads\\_Lib.rus.ec - Официальная\\lib.rus. ...@@ -207,7 +207,7 @@ SOPDS_ROOT_LIB = 'W:\\_Downloads\\_Lib.rus.ec - Официальная\\lib.rus.
SOPDS_AUTH = True SOPDS_AUTH = True
SOPDS_SCAN_SHED_MIN ='0' SOPDS_SCAN_SHED_MIN ='0'
SOPDS_SCAN_SHED_HOUR ='0,12' SOPDS_SCAN_SHED_HOUR ='0,12'
SOPDS_INPX_ENABLE = False SOPDS_INPX_ENABLE = True
#Конвертеры EPUB и MOBI #Конвертеры EPUB и MOBI
#SOPDS_FB2TOEPUB = os.path.join(BASE_DIR,'convert/fb2toepub/unix_dist/fb2toepub') #SOPDS_FB2TOEPUB = os.path.join(BASE_DIR,'convert/fb2toepub/unix_dist/fb2toepub')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment