Set photodb log_level from argv.

This commit is contained in:
voussoir 2020-11-08 20:20:04 -08:00
parent de2f1caa42
commit 010c92cb73
3 changed files with 27 additions and 5 deletions

View file

@ -3,9 +3,12 @@ import sys
from voussoirkit import getpermission
from voussoirkit import pathclass
from voussoirkit import vlogging
import etiquette
LOG_LEVEL = vlogging.NOTSET
class CantFindPhotoDB(Exception):
pass
@ -24,7 +27,12 @@ def find_photodb():
if path == path.parent:
raise CantFindPhotoDB()
path = path.parent
photodb = etiquette.photodb.PhotoDB(path.with_child('_etiquette'), create=False)
photodb = etiquette.photodb.PhotoDB(
path.with_child('_etiquette'),
create=False,
log_level=LOG_LEVEL,
)
photodbs[path] = photodb
return photodb
@ -215,6 +223,9 @@ def tag_breplace_argparse(args):
photodb.commit()
def main(argv):
global LOG_LEVEL
(LOG_LEVEL, argv) = vlogging.get_level_by_argv(argv)
parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers()

View file

@ -17,14 +17,16 @@ import gevent.pywsgi
import sys
from voussoirkit import pathclass
from voussoirkit import vlogging
import backend
####################################################################################################
site = backend.site
HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https')
LOG_LEVEL = vlogging.NOTSET
####################################################################################################
def etiquette_flask_launch(
*,
@ -52,7 +54,7 @@ def etiquette_flask_launch(
if localhost_only:
site.localhost_only = True
backend.common.init_photodb(create=create)
backend.common.init_photodb(create=create, log_level=LOG_LEVEL)
message = f'Starting server on port {port}'
if use_https:
@ -73,6 +75,9 @@ def etiquette_flask_launch_argparse(args):
)
def main(argv):
global LOG_LEVEL
(LOG_LEVEL, argv) = vlogging.get_level_by_argv(argv)
parser = argparse.ArgumentParser()
parser.add_argument('port', nargs='?', type=int, default=5000)

View file

@ -10,9 +10,12 @@ import sys
import traceback
from voussoirkit import getpermission
from voussoirkit import vlogging
import etiquette
LOG_LEVEL = vlogging.NOTSET
def easytagger():
while True:
i = input('> ')
@ -35,7 +38,7 @@ def photag(photo_id):
def erepl_argparse(args):
global P
P = etiquette.photodb.PhotoDB(create=args.create)
P = etiquette.photodb.PhotoDB(create=args.create, log_level=LOG_LEVEL)
if args.exec_statement:
exec(args.exec_statement)
@ -53,6 +56,9 @@ def erepl_argparse(args):
break
def main(argv):
global LOG_LEVEL
(LOG_LEVEL, argv) = vlogging.get_level_by_argv(argv)
parser = argparse.ArgumentParser()
parser.add_argument('--exec', dest='exec_statement', default=None)