ref: extract globals into common config.py

pull/5/head
rrr-marble 4 years ago
parent ffc3ce75cc
commit 822e512a01

@ -0,0 +1,11 @@
# use database residing here
DB_LOCATION = (
"testbox/photovoter.dblite" # Q: any allowances for this being not OUR database?
)
DATA_LOCATION = "/tmp/123"
# place compressed images here (needs to exist)
DEST_SHRUNK = "image/"
# move originals here (needs to exist)
DEST_ORIGINAL = "original/"

@ -9,12 +9,9 @@ from uuid import uuid4
import sqlite3
import zipfile
# use database residing here
DB_LOCATION = (
"../testbox/photovoter.dblite" # Q: any allowances for this being not OUR database?
)
DATA_LOCATION = "/tmp/123"
# Global settings of this program
# ./config.py
from config import DB_LOCATION, DATA_LOCATION
app = FastAPI()
security = HTTPBasic()
@ -229,7 +226,7 @@ def unpack_pictures_zip(file: UploadFile, time):
print(f"Accepted {file.filename} at {time} into processing")
os.chdir(DATA_LOCATION)
os.mkdir("processing")
os.makedirs("processing", exist_ok=True)
os.chdir("processing")
# using private ._file field is a dirty hack, but

@ -8,15 +8,6 @@ from sys import argv, stderr
from shutil import move
import sqlite3
# update database residing here
DB_LOCATION = (
"db/photovoter.dblite" # Q: any allowances for this being not OUR database?
)
# place compressed images here (needs to exist)
DEST_SHRUNK = "db/image/"
# move originals here (needs to exist)
DEST_ORIGINAL = "db/original/"
def process_pictures(source: str, dest_shrunk: str, dest_original: str):
"""Process images from the base directory in the first command line argument.
@ -187,7 +178,15 @@ def main():
usage()
exit(1)
run(DB_LOCATION, argv[1], DEST_SHRUNK, DEST_ORIGINAL)
import sys
import os
# append root directory to sys.path
# to allow import globals from ../config.py
sys.path.append(os.path.dirname(__file__) + "/..")
import config as cfg
run(cfg.DB_LOCATION, argv[1], cfg.DEST_SHRUNK, cfg.DEST_ORIGINAL)
if __name__ == "__main__":

Loading…
Cancel
Save