Update closest_photodb to take starting path argument.
This commit is contained in:
parent
399d27bb44
commit
26d5ff5730
5 changed files with 10 additions and 8 deletions
|
@ -1953,21 +1953,20 @@ class PhotoDB(
|
|||
self.sql.commit()
|
||||
|
||||
@classmethod
|
||||
def closest_photodb(cls, *args, **kwargs):
|
||||
def closest_photodb(cls, path, *args, **kwargs):
|
||||
'''
|
||||
Starting from the cwd and climbing upwards towards the filesystem root,
|
||||
look for an existing Etiquette data directory and return the PhotoDB
|
||||
object. If none exists, raise exceptions.NoClosestPhotoDB.
|
||||
'''
|
||||
cwd = pathclass.cwd()
|
||||
starting = path
|
||||
|
||||
path = cwd
|
||||
while True:
|
||||
if path.with_child(constants.DEFAULT_DATADIR).is_dir:
|
||||
break
|
||||
parent = path.parent
|
||||
if path == parent:
|
||||
raise exceptions.NoClosestPhotoDB(cwd.absolute_path)
|
||||
raise exceptions.NoClosestPhotoDB(starting.absolute_path)
|
||||
path = parent
|
||||
|
||||
path = path.with_child(constants.DEFAULT_DATADIR)
|
||||
|
|
|
@ -30,7 +30,7 @@ def find_photodb():
|
|||
pass
|
||||
|
||||
# If this raises, main will catch it.
|
||||
photodb = etiquette.photodb.PhotoDB.closest_photodb(log_level=LOG_LEVEL)
|
||||
photodb = etiquette.photodb.PhotoDB.closest_photodb(cwd, log_level=LOG_LEVEL)
|
||||
photodbs[cwd] = photodb
|
||||
return photodb
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ def etiquette_flask_launch(
|
|||
site.localhost_only = True
|
||||
|
||||
try:
|
||||
backend.common.init_photodb(log_level=LOG_LEVEL)
|
||||
backend.common.init_photodb(path=pathclass.cwd(), log_level=LOG_LEVEL)
|
||||
except etiquette.exceptions.NoClosestPhotoDB as exc:
|
||||
pipeable.stderr(exc.error_message)
|
||||
pipeable.stderr('Try `etiquette_cli.py init` to create the database.')
|
||||
|
|
|
@ -6,6 +6,8 @@ gunicorn etiquette_flask_prod:site --bind "0.0.0.0:PORT" --access-logfile "-"
|
|||
'''
|
||||
import werkzeug.middleware.proxy_fix
|
||||
|
||||
from voussoirkit import pathclass
|
||||
|
||||
import backend
|
||||
|
||||
backend.site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(backend.site.wsgi_app)
|
||||
|
@ -13,4 +15,4 @@ backend.site.wsgi_app = werkzeug.middleware.proxy_fix.ProxyFix(backend.site.wsgi
|
|||
site = backend.site
|
||||
site.debug = False
|
||||
|
||||
backend.common.init_photodb()
|
||||
backend.common.init_photodb(path=pathclass.cwd())
|
||||
|
|
|
@ -10,6 +10,7 @@ import sys
|
|||
import traceback
|
||||
|
||||
from voussoirkit import interactive
|
||||
from voussoirkit import pathclass
|
||||
from voussoirkit import pipeable
|
||||
from voussoirkit import vlogging
|
||||
|
||||
|
@ -41,7 +42,7 @@ def erepl_argparse(args):
|
|||
global P
|
||||
|
||||
try:
|
||||
P = etiquette.photodb.PhotoDB.closest_photodb(log_level=LOG_LEVEL)
|
||||
P = etiquette.photodb.PhotoDB.closest_photodb(pathclass.cwd(), log_level=LOG_LEVEL)
|
||||
except etiquette.exceptions.NoClosestPhotoDB as exc:
|
||||
pipeable.stderr(exc.error_message)
|
||||
pipeable.stderr('Try `etiquette_cli.py init` to create the database.')
|
||||
|
|
Loading…
Reference in a new issue