Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add admin to show how to change personality.
- Loading branch information
Showing
6 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import io | ||
from PIL import Image | ||
import flask | ||
from flask.ext import login | ||
|
||
from sirius.protocol import protocol_loop | ||
from sirius.protocol import messages | ||
from sirius.coding import image_encoding | ||
|
||
|
||
blueprint = flask.Blueprint('admin', __name__) | ||
|
||
|
||
@blueprint.route('/admin/randomly-change-personality', methods=['GET', 'POST']) | ||
def randomly_change_personality(): | ||
# Restrict to debug for now until we have a proper user management | ||
# system. | ||
assert flask.current_app.config['DEBUG'], "Debug not enabled" | ||
|
||
im = image_encoding.threshold(Image.open('./tests/normalface.png')) | ||
|
||
if flask.request.method == 'POST': | ||
msg = messages.SetPersonality( | ||
device_address='000d6f000273ce0b', | ||
face_pixels=im, | ||
nothing_to_print_pixels=im, | ||
cannot_see_bridge_pixels=im, | ||
cannot_see_internet_pixels=im, | ||
) | ||
success, next_print_id = protocol_loop.send_message( | ||
'000d6f000273ce0b', msg) | ||
|
||
if success: | ||
flask.flash('Sent your message to the printer!') | ||
else: | ||
flask.flash(("Could not send message because the " | ||
"printer {} is offline.").format('000d6f000273ce0b'), | ||
'error') | ||
|
||
return flask.redirect(flask.request.path) | ||
|
||
return flask.render_template( | ||
'admin.html', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.