Added logging, added quiet flag
This commit is contained in:
parent
db406adfdc
commit
3fde0f4f08
9 changed files with 84 additions and 19 deletions
atlasimagecomposer/cli
|
@ -1,13 +1,16 @@
|
|||
import argparse
|
||||
import logging
|
||||
import pathlib
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
from .. import __version__
|
||||
from ..backend import compose
|
||||
from ..config import Paths, AtlasDefaults
|
||||
from ..config import Paths, AtlasDefaults, Logging
|
||||
from ..utils.filesystem import rmdir
|
||||
from ..utils.disables import disable_tqdm
|
||||
|
||||
LOGGER = logging.getLogger(Logging.NAME)
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class Arguments(argparse.Namespace):
|
||||
|
@ -19,6 +22,7 @@ class Arguments(argparse.Namespace):
|
|||
cacheclear: bool
|
||||
filter: List[str]
|
||||
timeout: int
|
||||
quiet: bool
|
||||
|
||||
def parse_arguments():
|
||||
"""
|
||||
|
@ -36,6 +40,7 @@ def parse_arguments():
|
|||
parser.add_argument("--filter", action="extend", nargs="+", dest="filter", help='Specify one or more spritesheet ids that will be fetched')
|
||||
parser.add_argument("--timeout", action="store", type=int, default=None, dest="timeout", help="Set the timeout for all requests towards AtlasAcademy, default is 10s")
|
||||
parser.add_argument("--clear-cache", action="store_true", default=False, dest="cacheclear", help="Clear cached assets before downloading files")
|
||||
parser.add_argument("--quiet", "-q", action="store_true", default=False, dest="quiet", help="Disable logging output")
|
||||
|
||||
|
||||
args = Arguments()
|
||||
|
@ -56,7 +61,11 @@ def run_cli():
|
|||
if args.timeout and args.timeout >= 0:
|
||||
AtlasDefaults.TIMEOUT = args.timeout
|
||||
|
||||
welcome()
|
||||
if args.quiet:
|
||||
disable_tqdm()
|
||||
LOGGER.disabled = True
|
||||
else:
|
||||
welcome()
|
||||
|
||||
input_id = args.id
|
||||
if not input_id:
|
||||
|
@ -67,7 +76,7 @@ def run_cli():
|
|||
if t <= 0:
|
||||
raise ValueError
|
||||
except ValueError:
|
||||
print("Servant ID has to be a valid integer above 0")
|
||||
LOGGER.error("Servant ID has to be a valid integer above 0")
|
||||
sys.exit(1)
|
||||
|
||||
input_id = int(input_id)
|
||||
|
@ -78,8 +87,8 @@ def run_cli():
|
|||
cachepath = Paths.IMAGES / "manual" / str(input_id)
|
||||
if cachepath.exists():
|
||||
rmdir(cachepath)
|
||||
print("Successfully cleared cached assets")
|
||||
LOGGER.info("Successfully cleared cached assets")
|
||||
else:
|
||||
print("No cache to clear was found, continuing")
|
||||
LOGGER.info("No cache to clear was found, continuing")
|
||||
|
||||
compose(input_id, args.filter)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue