From 4d431f5ed8d60185e11d2ad1964b78dd26861306 Mon Sep 17 00:00:00 2001 From: Tom Hunger Date: Mon, 26 Jan 2015 16:04:20 +0000 Subject: [PATCH] Keep track of stats for preview and printing. --- sirius/web/printer_print.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sirius/web/printer_print.py b/sirius/web/printer_print.py index 6b903db..56e4d21 100644 --- a/sirius/web/printer_print.py +++ b/sirius/web/printer_print.py @@ -11,6 +11,7 @@ from sirius.models import messages as model_messages from sirius.protocol import protocol_loop from sirius.protocol import messages from sirius.coding import image_encoding +from sirius import stats blueprint = flask.Blueprint('printer_print', __name__) @@ -70,10 +71,12 @@ def printer_print(user_id, username, printer_id): if success: flask.flash('Sent your message to the printer!') + stats.inc('printer.print.ok') else: flask.flash(("Could not send message because the " "printer {} is offline.").format(printer.name), 'error') + stats.inc('printer.print.offline') # Store the same message in the model. model_message = model_messages.Message( @@ -107,10 +110,9 @@ def preview(user_id, username, printer_id): assert username == login.current_user.username message = flask.request.data - - print "M", message - pixels = image_encoding.html_to_png( '{}'.format(message)) + stats.inc('printer.preview') + return ''.format(base64.b64encode(pixels)) -- 2.47.3