Move modules into an actual package

This commit is contained in:
voussoir 2017-02-04 19:55:13 -08:00
parent 8b05a26ff7
commit c84acca6c9
14 changed files with 54 additions and 46 deletions

1
etiquette/__init__.py Normal file
View file

@ -0,0 +1 @@
pass

View file

@ -100,7 +100,7 @@ SQL_USER = _sql_dictify(SQL_USER_COLUMNS)
# Errors and warnings # Errors and warnings
ERROR_DATABASE_OUTOFDATE = 'Database is out-of-date. {current} should be {new}. Please use etiquette_upgrader.py' ERROR_DATABASE_OUTOFDATE = 'Database is out-of-date. {current} should be {new}. Please use utilities\\etiquette_upgrader.py'
ERROR_INVALID_ACTION = 'Invalid action' ERROR_INVALID_ACTION = 'Invalid action'
ERROR_NO_SUCH_TAG = 'Doesn\'t exist' ERROR_NO_SUCH_TAG = 'Doesn\'t exist'
ERROR_NO_TAG_GIVEN = 'No tag name supplied' ERROR_NO_TAG_GIVEN = 'No tag name supplied'

View file

@ -4,7 +4,7 @@ import functools
import time import time
import warnings import warnings
import jsonify from . import jsonify
def required_fields(fields): def required_fields(fields):

View file

@ -3,8 +3,8 @@ import math
import mimetypes import mimetypes
import os import os
import constants from . import constants
import exceptions from . import exceptions
from voussoirkit import bytestring from voussoirkit import bytestring

View file

@ -1,7 +1,8 @@
import flask import flask
import helpers
import json import json
from . import helpers
def make_json_response(j, *args, **kwargs): def make_json_response(j, *args, **kwargs):
dumped = json.dumps(j) dumped = json.dumps(j)
response = flask.Response(dumped, *args, **kwargs) response = flask.Response(dumped, *args, **kwargs)

View file

@ -2,10 +2,10 @@ import os
import PIL.Image import PIL.Image
import traceback import traceback
import constants from . import constants
import decorators from . import decorators
import exceptions from . import exceptions
import helpers from . import helpers
from voussoirkit import bytestring from voussoirkit import bytestring
from voussoirkit import pathclass from voussoirkit import pathclass

View file

@ -9,12 +9,12 @@ import sqlite3
import string import string
import time import time
import constants from . import constants
import decorators from . import decorators
import exceptions from . import exceptions
import helpers from . import helpers
import objects from . import objects
import searchhelpers from . import searchhelpers
from voussoirkit import pathclass from voussoirkit import pathclass
from voussoirkit import safeprint from voussoirkit import safeprint
@ -551,11 +551,16 @@ class PDBPhotoMixin:
self.commit() self.commit()
return photo return photo
def purge_deleted_files(self, *, commit=True): def purge_deleted_files(self, photos=None, *, commit=True):
''' '''
Remove Photo entries if their corresponding file is no longer found. Remove Photo entries if their corresponding file is no longer found.
photos: An iterable of Photo objects to check.
If not provided, everything is checked.
''' '''
photos = self.get_photos_by_recent() if photos is None:
photos = self.get_photos_by_recent()
for photo in photos: for photo in photos:
if os.path.exists(photo.real_filepath): if os.path.exists(photo.real_filepath):
continue continue

View file

@ -1,9 +1,9 @@
import shlex import shlex
import constants from . import constants
import exceptions from . import exceptions
import helpers from . import helpers
import objects from . import objects
def build_query(orderby): def build_query(orderby):
query = 'SELECT * FROM photos' query = 'SELECT * FROM photos'

View file

@ -1,9 +1,10 @@
import flask import flask
from flask import request from flask import request
import functools import functools
import helpers
import uuid import uuid
from . import helpers
def _generate_token(): def _generate_token():
token = str(uuid.uuid4()) token = str(uuid.uuid4())
#print('MAKE SESSION', token) #print('MAKE SESSION', token)

View file

@ -1,10 +1,10 @@
# Use with # Use with
# py -i etiquette_easy.py # py -i etiquette_easy.py
import phototagger import etiquette.phototagger
import os import os
import sys import sys
P = phototagger.PhotoDB() P = etiquette.phototagger.PhotoDB()
import traceback import traceback
def easytagger(): def easytagger():

View file

@ -8,17 +8,25 @@ import urllib.parse
import warnings import warnings
import zipstream import zipstream
import constants from etiquette import constants
import decorators from etiquette import decorators
import exceptions from etiquette import exceptions
import helpers from etiquette import helpers
import jsonify from etiquette import jsonify
import objects from etiquette import objects
import phototagger from etiquette import phototagger
import searchhelpers from etiquette import searchhelpers
import sessions from etiquette import sessions
site = flask.Flask(__name__)
TEMPLATE_DIR = 'C:\\git\\Etiquette\\templates'
STATIC_DIR = 'C:\\git\\Etiquette\\static'
site = flask.Flask(
__name__,
template_folder=TEMPLATE_DIR,
static_folder=STATIC_DIR,
)
site.config.update( site.config.update(
SEND_FILE_MAX_AGE_DEFAULT=180, SEND_FILE_MAX_AGE_DEFAULT=180,
TEMPLATES_AUTO_RELOAD=True, TEMPLATES_AUTO_RELOAD=True,
@ -249,7 +257,7 @@ def logout():
@site.route('/favicon.ico') @site.route('/favicon.ico')
@site.route('/favicon.png') @site.route('/favicon.png')
def favicon(): def favicon():
filename = os.path.join('static', 'favicon.png') filename = os.path.join(STATIC_DIR, 'favicon.png')
return flask.send_file(filename) return flask.send_file(filename)
@ -549,14 +557,6 @@ def get_search_json():
return jsonify.make_json_response(search_results) return jsonify.make_json_response(search_results)
@site.route('/static/<filename>')
def geft_static(filename):
filename = filename.replace('\\', os.sep)
filename = filename.replace('/', os.sep)
filename = os.path.join('static', filename)
return flask.send_file(filename)
def get_tags_core(specific_tag=None): def get_tags_core(specific_tag=None):
try: try:
tags = P.export_tags(phototagger.tag_export_easybake, specific_tag=specific_tag) tags = P.export_tags(phototagger.tag_export_easybake, specific_tag=specific_tag)

View file

@ -1,7 +1,7 @@
import gevent.monkey import gevent.monkey
gevent.monkey.patch_all() gevent.monkey.patch_all()
import etiquette import etiquette_site
import gevent.pywsgi import gevent.pywsgi
import gevent.wsgi import gevent.wsgi
import sys import sys
@ -14,14 +14,14 @@ else:
if port == 443: if port == 443:
http = gevent.pywsgi.WSGIServer( http = gevent.pywsgi.WSGIServer(
listener=('0.0.0.0', port), listener=('0.0.0.0', port),
application=etiquette.site, application=etiquette_site.site,
keyfile='C:\\git\\etiquette\\etiquette\\https\\etiquette.key', keyfile='C:\\git\\etiquette\\etiquette\\https\\etiquette.key',
certfile='C:\\git\\etiquette\\etiquette\\https\\etiquette.crt', certfile='C:\\git\\etiquette\\etiquette\\https\\etiquette.crt',
) )
else: else:
http = gevent.pywsgi.WSGIServer( http = gevent.pywsgi.WSGIServer(
listener=('0.0.0.0', port), listener=('0.0.0.0', port),
application=etiquette.site, application=etiquette_site.site,
) )