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
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_NO_SUCH_TAG = 'Doesn\'t exist'
ERROR_NO_TAG_GIVEN = 'No tag name supplied'

View file

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

View file

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

View file

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

View file

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

View file

@ -9,12 +9,12 @@ import sqlite3
import string
import time
import constants
import decorators
import exceptions
import helpers
import objects
import searchhelpers
from . import constants
from . import decorators
from . import exceptions
from . import helpers
from . import objects
from . import searchhelpers
from voussoirkit import pathclass
from voussoirkit import safeprint
@ -551,11 +551,16 @@ class PDBPhotoMixin:
self.commit()
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.
photos: An iterable of Photo objects to check.
If not provided, everything is checked.
'''
if photos is None:
photos = self.get_photos_by_recent()
for photo in photos:
if os.path.exists(photo.real_filepath):
continue

View file

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

View file

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

View file

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

View file

@ -8,17 +8,25 @@ import urllib.parse
import warnings
import zipstream
import constants
import decorators
import exceptions
import helpers
import jsonify
import objects
import phototagger
import searchhelpers
import sessions
from etiquette import constants
from etiquette import decorators
from etiquette import exceptions
from etiquette import helpers
from etiquette import jsonify
from etiquette import objects
from etiquette import phototagger
from etiquette import searchhelpers
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(
SEND_FILE_MAX_AGE_DEFAULT=180,
TEMPLATES_AUTO_RELOAD=True,
@ -249,7 +257,7 @@ def logout():
@site.route('/favicon.ico')
@site.route('/favicon.png')
def favicon():
filename = os.path.join('static', 'favicon.png')
filename = os.path.join(STATIC_DIR, 'favicon.png')
return flask.send_file(filename)
@ -549,14 +557,6 @@ def get_search_json():
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):
try:
tags = P.export_tags(phototagger.tag_export_easybake, specific_tag=specific_tag)

View file

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