misc thumbservice todos
This commit is contained in:
parent
a8725aa6af
commit
46d67365ba
|
@ -73,8 +73,9 @@ more information.
|
||||||
|
|
||||||
Optional: Photolib uses a secondary service to generate thumbnails for video files. After the above installation
|
Optional: Photolib uses a secondary service to generate thumbnails for video files. After the above installation
|
||||||
instructions are complete, run `photothumbd` on a differnet port with the same arguments. On first run, it will create
|
instructions are complete, run `photothumbd` on a differnet port with the same arguments. On first run, it will create
|
||||||
a user for internal communications and log the username/password. This username/password must be used in the
|
a user for internal communications and log the username/password or you can set `THUMBSERVICE_INITIAL_PASSWORD_HASH` to
|
||||||
`--thumb-service` for `photoappd`.
|
the sha256 hash of the desired password. This username/password must be used in the `--thumb-service` option
|
||||||
|
for `photoappd`.
|
||||||
|
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
|
|
|
@ -20,7 +20,7 @@ from photoapp.common import pwhash
|
||||||
from photoapp.dbsession import DatabaseSession
|
from photoapp.dbsession import DatabaseSession
|
||||||
from photoapp.thumb import thumb_path, image_file_style
|
from photoapp.thumb import thumb_path, image_file_style
|
||||||
from photoapp.webutils import validate_password
|
from photoapp.webutils import validate_password
|
||||||
from photoapp.utils import genpw
|
from photoapp.utils import genpw, get_extension
|
||||||
|
|
||||||
|
|
||||||
THUMBSERVICE_USER_INTERNAL = "_thumbservice"
|
THUMBSERVICE_USER_INTERNAL = "_thumbservice"
|
||||||
|
@ -112,10 +112,13 @@ def setup_thumb_user(engine):
|
||||||
if u:
|
if u:
|
||||||
return
|
return
|
||||||
|
|
||||||
password = genpw()
|
password_hash = os.environ.get("THUMBSERVICE_INITIAL_PASSWORD_HASH")
|
||||||
|
if not password_hash:
|
||||||
|
password = genpw()
|
||||||
|
logging.warning("created thumbserver user: %s:%s", THUMBSERVICE_USER_INTERNAL, password)
|
||||||
|
password_hash = pwhash(password)
|
||||||
|
|
||||||
logging.warning("created thumbserver user: %s:%s", THUMBSERVICE_USER_INTERNAL, password)
|
s.add(User(name=THUMBSERVICE_USER_INTERNAL, password=password_hash))
|
||||||
s.add(User(name=THUMBSERVICE_USER_INTERNAL, password=pwhash(password)))
|
|
||||||
s.commit()
|
s.commit()
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,8 +191,9 @@ class ThumbWorker(Thread):
|
||||||
return
|
return
|
||||||
|
|
||||||
# download the image
|
# download the image
|
||||||
local_src_path = os.path.join(tmpdir, image.fname) # TODO fname isn't sanitized? use temp.<extension>
|
local_src_path = os.path.join(tmpdir, "input.{}".format(get_extension(image.fname)))
|
||||||
thumb_tmp_path = os.path.join(tmpdir, "thumb.jpg")
|
thumb_tmp_path = os.path.join(tmpdir, "thumb.jpg")
|
||||||
|
# TODO simplify low level operations like this
|
||||||
with (
|
with (
|
||||||
self.library.open(image.path, "rb") as src,
|
self.library.open(image.path, "rb") as src,
|
||||||
open(local_src_path, "wb") as dest,
|
open(local_src_path, "wb") as dest,
|
||||||
|
@ -265,7 +269,7 @@ def main():
|
||||||
parser = argparse.ArgumentParser(description="Photod photo server")
|
parser = argparse.ArgumentParser(description="Photod photo server")
|
||||||
|
|
||||||
parser.add_argument('-p', '--port', help="tcp port to listen on",
|
parser.add_argument('-p', '--port', help="tcp port to listen on",
|
||||||
default=int(os.environ.get("THUMB_SERVICE_PORT", 8081)), type=int)
|
default=int(os.environ.get("THUMBSERVICE_PORT", 8081)), type=int)
|
||||||
parser.add_argument('-l', '--library', default=os.environ.get("STORAGE_URL"), help="library path")
|
parser.add_argument('-l', '--library', default=os.environ.get("STORAGE_URL"), help="library path")
|
||||||
parser.add_argument('-c', '--cache', default=os.environ.get("CACHE_URL"), help="cache url")
|
parser.add_argument('-c', '--cache', default=os.environ.get("CACHE_URL"), help="cache url")
|
||||||
# https://docs.sqlalchemy.org/en/13/core/engines.html
|
# https://docs.sqlalchemy.org/en/13/core/engines.html
|
||||||
|
|
Loading…
Reference in New Issue