Skip to content

Prelims management. Lives on horton.eecs.umich.edu. Created in 2018 by Patrick Pannuto. Python flask.

Notifications You must be signed in to change notification settings

eecsdco/prelims_scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prelims README

This directory is a self-contained webapp built on top of Pyramid web framework, part of the Pylons project. The goal of modern web frameworks are to tease apart data backends (models), website logic (controllers), and the rendered website itself (views). In practice, this means it can be a little intimidating to see how everything goes together to build things at first, I'll try to give a simple overview.

Updates Aug. 2024

  • On Aug. 20, it was reported that the system was down. The issue was that the venv was running a python version that was not installed on the system after an OS upgrade. The venv was rebuilt to use python3.12.

Updates Nov. 2021

  • This project now requires Python3 to run.
  • Pserve now uses 'gunicorn' instead of 'waitress' to serve up the application because gunicorn supports SSL whereas waitress does not. This dependency was added in setup.py.
  • Added 'setuptools' to setup.py as it was required by Python3.
  • The project is protected behind a Shibboleth login. The directory for shibboleth is /var/www/html/secure. Laura has it redirecting appropriately to https://horton.eecs.umich.edu:6543.

Getting Started

The website is basically a lot of extra python modules all working together. Web framework pieces tend to have relatively high churn without the highest emphasis on backwards compatability, the solution is to have one python environment for each website (a "virtualenv").

Virtualenv

Create a virtual environment for this project:

# venv_prelims is the name of the directory that will be created
python -m venv venv_prelims

# ALTERNATIVELY, specify the python version (3.12 in this case). This was the solution to the issue that arose in Aug. 2024
python3.12 -m venv venv_prelims

Next we need to "activate" this virtual environment. This is done on a per-shell basis (it will update your $PS1 automatically). There are tools (virtualenvwrapper) that will automate this, but are probably more than you care about.

# Activate this virtual environment
source venv_prelims/bin/activate

Anything python-related (e.g. install packages) you do in a virtual enivronment will only affect this environment. This also means you don't have to (in fact, should not) be installing things as root, since they're only being installed in this local folder.

Now install setup tools

# Installing setuptools is required for the next step
pip install setuptools

Building the webapp

First we have to install all of the dependencies inside of this virtualenv. If you add any new packages, be sure to add them to the requires array inside of setup.py.

# Make sure you do this in shell with the venv_prelims virtualenv active!
python setup.py develop

The next step is to initialize the databsae. We use sqlite, which means the database is just a simple file on disk, but this script will take care of things like setting up all of the tables properly. It also pre-populates the faculty table with the list found in prelims/scripts/fac_uniqs.

initialize_prelims_db development.ini

If you are developing, it may be more useful to skip this step and instead use the example database which is pre-populated with a little bit of test data. In that case, all you need to do is cp exampledb.sqlite prelims.sqlite

Deploying the webapp (LOCALLY)

For basic testing / debugging, python includes a built-in http server, which is easier than bothering to hook it in to apache / nginx / whatever your webserver of choice is.

pserve development.ini --reload

The --reload flag is optional, but is nice during development. It will cause the site to automatically rebuild whenever you edit a file that would require a rebuild.

If you're going to be debugging this on a remote machine, be sure to add your local machine to the debugtoolbar.hosts entry in development.ini.

SSL Keys

Whether running this app locally, make sure to have the following keys in place:

  • /etc/ssl/certs/all.cert
  • /etc/ssl/private/key.pem

You should be able to visit the site at https://0.0.0.0:6543/ locally.

PRODUCTION

This project lives on horton at /var/www/html/prelims_scheduler. It runs via apache and is behind Shibboleth, so running pserve is not needed.

Be sure the python packages version matches what's in the apache config:

In apache2/sites-available/default-ssl.conf

make sure the Python version in this line

WSGIPythonPath /var/www/html/prelims_scheduler/venv_prelims/lib/python3.10/site-packages

matches the version that is actually in the venv_prelims/lib path

About

Prelims management. Lives on horton.eecs.umich.edu. Created in 2018 by Patrick Pannuto. Python flask.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published