Logging for thumbnail template management

pull/423/head
Christopher Usher 3 weeks ago committed by Mike Lang
parent 2391a73ced
commit 8020df8e60

@ -458,6 +458,7 @@ class Cutter(object):
image_data = frame
elif job.thumbnail_mode == 'TEMPLATE':
template, crop, location = get_template(self.dbmanager, job.thumbnail_template, job.thumbnail_crop, job.thumbnail_location)
self.logging.info('Generating thumbnail from the video frame at {} using {} as template'.format(job.thumbnail_time, job.thumbnail_template))
image_data = compose_thumbnail_template(template, frame, crop, location)
else:
# shouldn't be able to happen given database constraints
@ -771,6 +772,7 @@ class VideoUpdater(object):
thumbnail_image = frame
elif job.thumbnail_mode == 'TEMPLATE':
template, crop, location = get_template(self.dbmanager, job.thumbnail_template, job.thumbnail_crop, job.thumbnail_location)
self.logging.info('Generating thumbnail from the video frame at {} using {} as template'.format(job.thumbnail_time, job.thumbnail_template))
thumbnail_image = compose_thumbnail_template(template, frame, crop, location)
else:
assert False, "Bad thumbnail mode: {}".format(job.thumbnail_mode)

@ -503,6 +503,7 @@ def get_thumbnail_named_template(channel, quality):
template, crop, location = get_template(app.db_manager, request.args['template'], crop, location)
except ValueError:
return 'Template {} not found'.format(request.args['template']), 404
logging.info('Generating thumbnail from the video frame at {} using {} as template'.format(request.args['timestamp'], request.args['template']))
return get_thumbnail(channel, quality, request.args['timestamp'], template, crop, location)
@ -521,6 +522,7 @@ def get_thumbnail_uploaded_template(channel, quality):
Should be a comma-seperated list of numbers.
"""
template = request.data
logging.info('Generating thumbnail from the video frame at {} using a custom template'.format(request.args['timestamp']))
return get_thumbnail(channel, quality, request.args['timestamp'], template, request.args['crop'], request.args['location'])

@ -607,6 +607,7 @@ def list_templates():
SELECT name, description, attribution, crop, location FROM templates ORDER BY name
"""
results = database.query(conn, query)
logging.info('List of thumbnail templates fetched')
return json.dumps([row._asdict() for row in results.fetchall()])
@ -624,6 +625,7 @@ def get_template(name):
return 'Template {} not found'.format(name), 404
image = row[0]
logging.info('Thumbnail image of {} fetched'.format(name))
return flask.Response(image, mimetype='image/png')
@ -639,6 +641,7 @@ def get_template_metadata(name):
row = results.fetchone()
if row is None:
return 'Template {} not found'.format(name), 404
logging.info('Thumbnail metadata of {} fetched'.format(name))
return json.dumps(row._asdict())
def validate_template(new_template):
@ -692,6 +695,7 @@ def add_template(artist=None):
)
database.query(conn, query, **new_template)
logging.info('Thumbnail template {} added'.format(new_template['name']))
return '', 201
@app.route('/thrimshim/update-template/<name>', methods=['POST'])
@ -729,6 +733,10 @@ def update_template(name, artist=None):
) for column in columns))
database.query(conn, query, old_name=name, **new_template)
if name == new_template['name']:
logging.info('Thumbnail template {} updated'.format(name))
else:
logging.info('Thumbnail template {} renamed to {} and updated'.format(name, new_template['name']))
return '', 200
@ -747,6 +755,7 @@ def get_thumbnail(ident):
event = row._asdict()
if event['thumbnail_mode'] != 'NONE' and event['thumbnail_image']:
logging.info('Thumbnail for event {} fetched'.format(ident))
return flask.Response(event['thumbnail_image'], mimetype='image/png')
else:
return '', 404

Loading…
Cancel
Save