mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 14:17:19 +00:00
added console output to scan_comics.py options.
This commit is contained in:
1
Pipfile
1
Pipfile
@@ -16,6 +16,7 @@ django-bootstrap4 = "*"
|
|||||||
dj-database-url = "*"
|
dj-database-url = "*"
|
||||||
pypdf4 = "*"
|
pypdf4 = "*"
|
||||||
python-dotenv = "*"
|
python-dotenv = "*"
|
||||||
|
loguru = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.8"
|
python_version = "3.8"
|
||||||
|
|||||||
26
Pipfile.lock
generated
26
Pipfile.lock
generated
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "24dc60dfd360e3b070182ba6e7d35553ca1714d613d316a3b04f7ca6b1415ee4"
|
"sha256": "25036caa93a668b5386d54417c22afd2bb42bbdf6d8fcb9828a278eefd381269"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@@ -45,6 +45,14 @@
|
|||||||
],
|
],
|
||||||
"version": "==3.0.4"
|
"version": "==3.0.4"
|
||||||
},
|
},
|
||||||
|
"colorama": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff",
|
||||||
|
"sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"
|
||||||
|
],
|
||||||
|
"markers": "sys_platform == 'win32'",
|
||||||
|
"version": "==0.4.3"
|
||||||
|
},
|
||||||
"dj-database-url": {
|
"dj-database-url": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163",
|
"sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163",
|
||||||
@@ -92,6 +100,14 @@
|
|||||||
],
|
],
|
||||||
"version": "==2.9"
|
"version": "==2.9"
|
||||||
},
|
},
|
||||||
|
"loguru": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:1e0e6ff59be5e22f863d909ca989e34bb14c21b374f6af45281e603d003dbb96",
|
||||||
|
"sha256:4688d9e1f31d70e1ec7ccce5305967bc28f377eb1048d009108c11faebe05bcf"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==0.5.0"
|
||||||
|
},
|
||||||
"pypdf4": {
|
"pypdf4": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:7c932441146d205572f96254d53c79ea2c30c9e11df55a5cf87e056c7b3d7f89"
|
"sha256:7c932441146d205572f96254d53c79ea2c30c9e11df55a5cf87e056c7b3d7f89"
|
||||||
@@ -141,6 +157,14 @@
|
|||||||
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
|
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
|
||||||
],
|
],
|
||||||
"version": "==1.25.9"
|
"version": "==1.25.9"
|
||||||
|
},
|
||||||
|
"win32-setctime": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:568fd636c68350bcc54755213fe01966fe0a6c90b386c0776425944a0382abef",
|
||||||
|
"sha256:b47e5023ec7f0b4962950902b15bc56464a380d869f59d27dbf9ab423b23e8f9"
|
||||||
|
],
|
||||||
|
"markers": "sys_platform == 'win32'",
|
||||||
|
"version": "==1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {
|
"develop": {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from os.path import isdir
|
from os.path import isdir
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
@@ -13,10 +14,21 @@ class Command(BaseCommand):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.base_dir = Setting.objects.get(name="BASE_DIR").value
|
self.base_dir = Setting.objects.get(name="BASE_DIR").value
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def add_arguments(self, parser):
|
||||||
self.scan_directory()
|
# Positional arguments
|
||||||
|
parser.add_argument('poll_ids', nargs='+', type=int)
|
||||||
|
|
||||||
def scan_directory(self, directory=False):
|
# Named (optional) arguments
|
||||||
|
parser.add_argument(
|
||||||
|
'--out',
|
||||||
|
action='store_true',
|
||||||
|
help='Output to console',
|
||||||
|
)
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
self.scan_directory(options=options)
|
||||||
|
|
||||||
|
def scan_directory(self, directory=False, **options):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -35,6 +47,8 @@ class Command(BaseCommand):
|
|||||||
book.delete()
|
book.delete()
|
||||||
for file in os.listdir(comic_dir):
|
for file in os.listdir(comic_dir):
|
||||||
if isdir(os.path.join(comic_dir, file)):
|
if isdir(os.path.join(comic_dir, file)):
|
||||||
|
if options['out']:
|
||||||
|
logger.info(f"Scanning Directory {file}")
|
||||||
if directory:
|
if directory:
|
||||||
next_directory, created = Directory.objects.get_or_create(name=file, parent=directory)
|
next_directory, created = Directory.objects.get_or_create(name=file, parent=directory)
|
||||||
else:
|
else:
|
||||||
@@ -43,6 +57,8 @@ class Command(BaseCommand):
|
|||||||
next_directory.save()
|
next_directory.save()
|
||||||
self.scan_directory(next_directory)
|
self.scan_directory(next_directory)
|
||||||
else:
|
else:
|
||||||
|
if options['out']:
|
||||||
|
logger.info(f"Scanning File {file}")
|
||||||
try:
|
try:
|
||||||
if directory:
|
if directory:
|
||||||
book = ComicBook.objects.get(file_name=file, directory=directory)
|
book = ComicBook.objects.get(file_name=file, directory=directory)
|
||||||
|
|||||||
Reference in New Issue
Block a user