From CSLabsWiki
Jump to: navigation, search
IP Address(es):
Contact Person: Alex Macri
Last Update: January 2016
VM Host (Physical): 7 Grand Dad
Host VM: DubsDot
Services: Print

Operating system: Debian Jessie (8) amd64
LDAP Support: Yes
Development Status: Stable
Status: Running


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.

Technical Information

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 "" in the "wsgi" branch.

Set up process

The critical software components of this setup are:

  • Python version 2 (probably > 2.5), accessible through various python2.x Debian packages.
  • uWSGI and its Python2 support, packages uwsgi and uwsgi-plugin-python.
  • Flask, a Python module available in python-flask.

When this is done, call 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).

Manual Maintenance

First and foremost, print now has a console, located in /srv/wsgi/print as 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).