Difference between revisions of "Print"
|Line 17:||Line 17:|
Revision as of 01:49, 23 April 2016
|Contact Person:||Graham Northup and Benjamin Lannon|
|VM Host (Physical):||bennu|
|Operating system:||Debian Jessie (8) amd64|
The print VM is a web-based printing interface that offers accounts to COSI members. Users can register accounts using their Clarkson usernames and print to the CSLabs Printer using the web interface. This service supports only Open Source file types, promoting the Guiding Principles of COSI. See Printing for more information on this process.
The machine uses CUPS (specifically the
lp command) to interface with the printer, PyKota to handle quotas, and uWSGI and Flask (in a Python backend) to handle the web interface. The source code for the web interface is available through the COSI-Lab GitHub account, under "print.dev" in the "wsgi" branch.
Set up process
The critical software components of this setup are:
- Python version 2 (probably > 2.5), accessible through various
- uWSGI and its Python2 support, packages
- Flask, a Python module available in
When this is done, call
test.sh in the repository's root directory--it includes a sudo that will (typically) be elided if you're already the superuser. For long-term sessions or stable builds, you may consider running this in a long-term
tmux session, possibly set up by an init script (the necessary script is left as an exercise to the reader).
First and foremost, print now has a console, located in /srv/wsgi/print as console.py. For best results, run it from within the directory it resides. Yes, it can create users and edit passwords, making the below redundant for all but the most involved of tasks. To see what the console can do, type help in it.
Creating a user:
$ pkusers --add --limitby balance --balance 100 <<USERNAME>> $ edpykota --add --printer CSLabsPrinter <<USERNAME>> $ mysql pykota mysql> UPDATE users SET password=<<MD5ed PASSWORD>> WHERE username=<<USERNAME>>
Increasing the balance for a user (Omit the <<USERNAME>> field to make changes to all users):
$ pkusers --balance +<<NUM PAGES>> --comment "<<REASON FOR INCREASE>>" <<USERNAME>>
Reset Balance for beginning of the Semester:
$ pkusers -b 200 -C "Reset for Semester"
Pull balance information:
$ pkusers -L # All users (quite probably a lot) $ pkusers -L <<USERNAME>> # A user by name
Delete user (do not use unless absolutely necessary):
$ pkusers --delete -- <<USERNAME>>
Passwords are managed exclusively through code in the web interface; to access this, enter the terminal at the repository root and drop into a root python shell (with
sudo python or
sudo python2.x, of course):
>>> import userdb, hashlib >>> u = userdb.User.FromName('<<USERNAME>>') >>> u.password = hashlib.sha512('<<PASSWORD>>').hexdigest() >>> u.Update()
The development print server is being transitioned here; as such, no further separate development branch exists, but further bugfixes and feature additions will nonetheless continue to be added (live, as it were).