|
|
|
@ -9,12 +9,9 @@ from uuid import uuid4
|
|
|
|
import sqlite3
|
|
|
|
import sqlite3
|
|
|
|
import zipfile
|
|
|
|
import zipfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Global settings of this program
|
|
|
|
# use database residing here
|
|
|
|
# ./config.py
|
|
|
|
DB_LOCATION = (
|
|
|
|
from config import DB_LOCATION, DATA_LOCATION
|
|
|
|
"../testbox/photovoter.dblite" # Q: any allowances for this being not OUR database?
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
DATA_LOCATION = "/tmp/123"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
app = FastAPI()
|
|
|
|
security = HTTPBasic()
|
|
|
|
security = HTTPBasic()
|
|
|
|
@ -219,9 +216,9 @@ async def upload_pictures(
|
|
|
|
def unpack_pictures_zip(file: UploadFile, time):
|
|
|
|
def unpack_pictures_zip(file: UploadFile, time):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Unpack and process zip archived photo
|
|
|
|
Unpack and process zip archived photo
|
|
|
|
Extract pictures in the DATA_LOCATION/processing
|
|
|
|
Extract pictures in the DATA_LOCATION/processing
|
|
|
|
#TODO: and feed them to util/import_photos.py
|
|
|
|
#TODO: and feed them to util/import_photos.py
|
|
|
|
#TODO: Walk the nested DATA_LOCATION/processing ourselves
|
|
|
|
#TODO: Walk the nested DATA_LOCATION/processing ourselves
|
|
|
|
Uses: DATA_LOCATION
|
|
|
|
Uses: DATA_LOCATION
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# we only call this function sporadically, so import here
|
|
|
|
# we only call this function sporadically, so import here
|
|
|
|
@ -229,7 +226,7 @@ def unpack_pictures_zip(file: UploadFile, time):
|
|
|
|
|
|
|
|
|
|
|
|
print(f"Accepted {file.filename} at {time} into processing")
|
|
|
|
print(f"Accepted {file.filename} at {time} into processing")
|
|
|
|
os.chdir(DATA_LOCATION)
|
|
|
|
os.chdir(DATA_LOCATION)
|
|
|
|
os.mkdir("processing")
|
|
|
|
os.makedirs("processing", exist_ok=True)
|
|
|
|
os.chdir("processing")
|
|
|
|
os.chdir("processing")
|
|
|
|
|
|
|
|
|
|
|
|
# using private ._file field is a dirty hack, but
|
|
|
|
# using private ._file field is a dirty hack, but
|
|
|
|
|