Display Wasatch Photonics device information, calibration reports, etc.
JavaScript Python CSS Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
cookbook
scripts
.travis.yml
README.md
setup.py

README.md

CookBook

Build Status Coverage Status

Web application to display Wasatch Photonics device information, calibration reports, etc.

Live demonstration available at http://waspho.com

CookBook screenshot

Getting Started

See the VPS configuration section below for system requirements before installing the CookBook applicatino code. The cookbook makes use of these projects:

PDFExploder StickerCode CalibrationReport PyQRNative

Clone all of the above projects into your python environment, and run python setup.py develop on each of the first three. Run setup.py develop install on PyQRNative.

  • cd directory containing this file

  • $VENV/bin/python setup.py develop

This project uses the http://peterhudec.github.io/authomatic/ library for authentication. Tests are configured to use an environment variable as the authenticated user mock-up. You'll need to set these environment variables to the specific API keys for your application. For example:

export AUTHOMATIC_SECRET="xxxxxxxxx"

See the file cookbook/environment_config.py for more details.

Testing

  • $VENV/bin/nosetests --cover-erase --with-coverage --cover-package=cookbook

  • $VENV/bin/nosetests cookbook.tests:FunctionalTests.test_show_checkout_is_fully_populated

  • $VENV/bin/initialize_cookbook_db config/development.ini

  • $VENV/bin/pserve config/development.ini

Database Loading

Clean the old information:
rm config/cookbook.sqlite
rm -rf cookbook/assets/img/thumbnails/*.*  # <- mind the glob

Reinitialize the database:
$VENV/bin/initialize_cookbook_db config/development.ini
python scripts/load_database.py

Deploying

Certain systems such as Digital Ocean 512MB ram droplets seem to expose a memory issue with the CookBook. To deploy on this class of servers, make sure the application will auto restart:

export AUTHOMATIC_SECRET="xxxxxxxxx"
export AUTH_POLICY_SECRET="xxxxxxxx"
export CONSUMER_KEY="xxxxxxxxxxxxxx"
export CONSUMER_SECRET="xxxxxxxxxxx"
sudo -E bash scripts/repeat_run.sh

VPS system configuration

login with established ssh key for root@linode or droplet

sudo dnf -y install screen policycoreutils-python-utils sudo dnf -y install zlib-devel libjpeg-devel sudo dnf -y install make automake gcc gcc-c++ kernel-devel cmake sudo dnf -y install redhat-rpm-config python-devel sudo dnf -y install ImageMagick-devel sudo reboot

Add users:

adduser USERNAME passwd USERNAME mkdir /home/USERNAME/.ssh chown -R USERNAME.USERNAME /home/USERNAME/.ssh usermod USERNAME -a -G wheel

Setup ssh with cookbook administration keys from remote system

cat ~/.ssh/public_key | ssh \ username@IPADDRESS "cat >> ~/.ssh/authorized_keys"

As USERNAME on linode/droplet:

chmod 0700 ~/.ssh chmod 0600 ~/.ssh/{authorized_keys,id_rsa}

As root on linode/droplet, change configuration

open ssh port for remote connections

On Droplets:

sudo semanage port -a -t ssh_port_t -p tcp CUSTOM_PORT

On Linode:

firewall-cmd --zone=FedoraServer --add-port=CUSTOM_PORT/tcp --permanent firewall-cmd --zone=FedoraServer --add-port=80/tcp --permanent

sudo vi /etc/ssh/sshd_config change Port 22 to Port CUSTOM_PORT

Disable remote root login

PermitRootLogin no

disable remote password logins

PasswordAuthentication no

sudo systemctl restart sshd

re-login on as username on port CUSTOM_PORT

mkdir projects mkdir projects/pythonxyMatch export VENV=/home/USERNAME/projects/pythonxyMatch sudo dnf install python-virtualenv