Git Product home page Git Product logo

packet's Introduction

CSH Web Packet

Python 3.6 Build Status

Packet is used by CSH to facilitate the freshmen packet portion of our introductory member evaluation process. This is the second major iteration of packet on the web. The first version was Tal packet.

Setup

Requires Python 3.6 or newer.

To get the server working you'll just need the Python dependencies and some secrets. There will be some UI issues due to missing assets though. To solve that you'll want to set up the front end dependencies or download a copy of the current assets from prod.

Alternatively, you can set up a Docker container using Dockerfile. This is what's used in prod so it's the most reliable method.

Python dependencies

Use pip3 install -r requirements.txt to install the required python dependencies. A venv is highly recommended.

If 1 or more of the packages fail to install the likely issue is missing header files for the libraries with native C components. See the contents of Dockerfile for the Linux packages that you'll need. On windows it's a bit more of a pain. Try using WSL or finding a pre-compiled wheel from a trustworthy source.

Frontend dependencies

To build any of the frontend dependencies you're going to need node, npm, and yarn.

Make sure your system is also capable of building with Sass. To download all node dependencies run.

yarn install

Following the install, you should be able to run gulp

gulp production

If it doesn't work for some reason, you may have to globally install gulp through npm

npm install -g gulp

Secrets and configuration

Packet supports 2 primary configuration methods:

  1. Environment variables - See config.env.py for the expected names and default values.
  2. Pyfile config - Create a config.py file in the root directory of the project and set variables to override the values in config.env.py.

Both methods can be used at the same time, though Pyfile config will take priority over environment variables.

Required configuration values:

  • SQLALCHEMY_DATABASE_URI - Must be set to a valid SQLAlchemy DB URI. A dev database for the project is hosted by CSH. Contact a current maintainer of packet for the details.
  • LDAP_BIND_DN - Must point to a valid CSH account on LDAP. Use the form uid={username},cn=users,cn=accounts,dc=csh,dc=rit,dc=edu.
  • LDAP_BIND_PASS - The password for that CSH account.
  • SECRET_KEY - Use a sufficiently long random string here. The flask create-secret command can generate a good one for you.
  • OIDC_CLIENT_SECRET - Required to use CSH auth. Contact a current maintainer of packet for the details.

To switch between OIDC realms you'll need to set the modify the following values:

  • OIDC_CLIENT_SECRET - Unique to each realm. Again, contact a current maintainer of packet for the details.
  • OIDC_ISSUER - The OIDC issuer URL.
  • REALM - Set to "csh" or "intro" depending on the realm you want.

By default OIDC_ISSUER and REALM are configured for the CSH members realm.

Usage

To run packet using the flask dev server use this command:

python3 wsgi.py

The Flask debug mode flag can be set using via the config system explained above.

Alternative you can run it through gunicorn using this command:

gunicorn -b :8000 packet:app --access-logfile -

CLI

Packet makes use of the Flask CLI for exposing functionality to devs and admins. This is primarily designed to be used locally with the target DB set via the server's config values.

To use the CLI just set the project up as normal and then run the flask command in the project's root directory. It'll automatically load up the app and show you a list of available commands. For more details on a particular command use the help flag like this:

flask {command} --help

WARNING: Be sure to double check which DB you're pointed at when using one of the admin or DB commands.

All DB commands are from the Flask-Migrate library and are used to configure DB migrations through Alembic. See their docs here for details.

Code standards

This project is configured to use Pylint. Commits will be pylinted by Travis CI and if the score drops your build will fail blocking you from merging. To make your life easier just run it before making a PR.

To run pylint use this command:

pylint packet

All python files should have a top-level docstring explaining the contents of the file and complex functions should have docstrings explaining any non-obvious portions.

packet's People

Contributors

dependabot[bot] avatar devinmatte avatar evelyndooley avatar henrylb avatar joeleager avatar liam-middlebrook avatar mbillow avatar mxmeinhold avatar ramzallan avatar squablyscientist avatar stevenmirabito avatar willnilges avatar zedoax avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.