From bff6a386f917e10bc61146c8e8ac25c592462cb0 Mon Sep 17 00:00:00 2001 From: Luis Riera Date: Mon, 14 Feb 2022 15:03:34 -0500 Subject: [PATCH 1/4] cherry picked first commit --- api/everything.py | 2 +- setup.sh | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/api/everything.py b/api/everything.py index 35a6881..d35b7c4 100755 --- a/api/everything.py +++ b/api/everything.py @@ -17,7 +17,7 @@ from flask import send_from_directory from flask import flash from flask import abort -from werkzeug import secure_filename +from werkzeug.utils import secure_filename # need to import g from flask_login from flask_login import login_user, logout_user, current_user, LoginManager, login_required diff --git a/setup.sh b/setup.sh index e4265ff..cd2621a 100755 --- a/setup.sh +++ b/setup.sh @@ -4,11 +4,23 @@ # Setup virtualenv #mkdir -p data -if [ ! -d venv ] +if [ -d venv ] then - virtualenv venv + echo "Deactivating and removing old virtualenv" + deactivate 2>&1 /dev/null + rm -rf venv fi +# Check for correct python version +VERSION=`python2 -V | awk '{print $2}'` +if [ "${VERSION:0:1}" -ne "2" ] || [ "${VERSION:2:1}" -ne "7" ]; then + echo "You must use Python 2.7. You are using $VERSION" + return 1 +else + echo -e "You are using Python $VERSION" +fi + +virtualenv --python=python2.7 venv . venv/bin/activate pip install -r requirements.txt From aacc81b3c75912d5210fbcf0ce80315dd8d32085 Mon Sep 17 00:00:00 2001 From: Sreynit Khatt <59736834+sreynit02@users.noreply.github.com> Date: Fri, 18 Feb 2022 15:44:11 -0500 Subject: [PATCH 2/4] Update README.md --- README.md | 111 +++++++++++++++++++----------------------------------- 1 file changed, 39 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 140957b..116f2f4 100755 --- a/README.md +++ b/README.md @@ -1,72 +1,39 @@ -# Working with URCPP - -## Important things to know before developing - - - Uses Python 2.7 - - There is still sqlite code in here, but we are using mysql - -## Quick Installation Guide with Docker - -1. Ensure that you have the proper binaries installed by running `which docker docker-compose` and verifying the output (there should be a path for both). New student VMs should already be ready. If you do not have them, install them. - * `sudo apt-get install docker.io` - * Use the Linux instructions from https://docs.docker.com/compose/install/ - * Your user should be in the docker group or you will need sudo privileges. -2. Clone this repository. -3. In your new repo directory, use docker-compose to start your application. - * `docker-compose up` - -4. If this is successful, access your application at your server + the port - * If on your computer: http://localhost:8080 - * If on your student VM, use that IP: e.g., http://172.31.3.69:8080 -5. The application data will persist in your docker/data/db/ directory. To re-initialize it, use the appropriate script in tools/. -6. To understand more about using Docker and docker-compose, read http://172.31.2.178/en/docker. - -## Manual Installation Guide - -### Necessary packages and configuration -1. Ensure you have the necessary packages to run this application. - * `apt install git mysql-server python2.7 python-pip virtualenv` -2. You must be using Python 2.7 - * If you are unsure how to fix this, read http://172.31.2.178/en/python-versions -3. Ensure you have access to the git repo using ssh keys - * Try and clone this repository. If it doesn't work, do the next step - * Paste your public key into bitbucket - * If you are unsure how to get your key, read http://172.31.2.178/en/ssh -4. Clone this repo. - -### Database Setup -1. Ensure MySQL is running, with the proper root password set - * test with `mysql -u root --password="root"` - * if you can't connect and you do not have sudo privileges, someone will have to set this up for you - * `sudo systemctl start mysql` - * `echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; flush privileges;" | sudo mysql -u root --password=root` -2. Create the user and database - * This will erase any existing data! - * There will be ignorable errors if this is the initial setup. - * Run `./erase_mysql_db_and_use_real_data.sh` from the tools directory. -3. Edit the application configuration for your db host. - * In `api/config.yaml`, change your database host from "db" to your mysql host (e.g., "localhost") - -### Application Setup -1. Initialize the application: `./setup.sh` -2. Activate your virtual environment: `source venv/bin/activate` -3. Run the application: `python api.py` -4. If this is successful, access your application at your server + the port - * If on your computer: http://localhost:8080 - * If on your student VM, use that IP: e.g., http://172.31.3.69:8080 -5. The application data will persist in mysql database. To re-initialize it, use the appropriate script in tools/. - -## Customization and Troubleshooting - -### Database Config - -### Common Errors - * If you run into this error `bind: address already in use`, run the following command: - `sudo systemctl stop mysql` - - - -### OLD BITS -4. run `phpmyadmin-ctl install` to run the phpmyadmin client. -5. navigate to the phpmyadmin interface - +## Requirements +- Python2.7 +- linux, unix, mac, windows(with attachments), Ubuntu +- virtualenv +- mysql and python mysql-db + +## Setup +1. In your working environment, clone the URCPP Repo: +- `https://github.com/BCStudentSoftwareDevTeam/urcpp` as of 02/10/2022 +3. Pull the most recent changes +4. In the file `setup.sh` add lineRun `source setup.sh` + +## Create database with Phpmyadmin + +5. Go to your Phpmyadmin interface and log in with your credentials +- Located here: `http://0.0.0.0/phpmyadmin/` +Make sure to replace 0.0.0.0 with your server's IP address +6. Create a new database named `urcpp_flask_v2` +- If a database of that name already exists, drop it and create it again +7. Create a user named `urcpp-flask` with password `DanforthLabor123!` +8. Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask` +Continue to step 13. + +## Create database with MySQL Workbench and Terminal + +9. In your terminal use the command `mysql -u root -p`. You will be prompted to enter your password +10. To create the database: `CREATE DATABASE urcpp_flask_v2;` (Make sure you include the ;) +11. To create a user named `urcpp-flask` with password `DanforthLabor123!`: `CREATE USER 'urcpp-flask'@localhost IDENTIFIED BY 'DanforthLabor123!'; ` +12. To Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask`: ` GRANT ALL PRIVILEGES ON `urcpp_flask_v2` . * TO 'urcpp-flask'@localhost; ` +13. To make sure permissions take effect: ` flush privileges; ` + +## Continue from here again +14. Create a file named `secret_key` in the `api` folder +- `secret_key` MUST contain some alphanumeric characters. Anything will work including `AnythignWillWork` +15. Comment out lines 20-27 in `api/__init__.py` +16. Run `python recreate_static.py` +17. Run `python recreate_dynamic.py` +18. Comment lines 20-27 in `api/__init__.py` back in +19. Run `python api.py` From 3a8782070556b69967ee1e4f4d652a18f8b5ac71 Mon Sep 17 00:00:00 2001 From: sreynitkhatt Date: Fri, 25 Feb 2022 15:19:35 -0500 Subject: [PATCH 3/4] revised setup code and instructions --- README.md | 4 ++-- api/everything.py | 2 +- setup.sh | 49 ++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 116f2f4..3abec7e 100755 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ 1. In your working environment, clone the URCPP Repo: - `https://github.com/BCStudentSoftwareDevTeam/urcpp` as of 02/10/2022 3. Pull the most recent changes -4. In the file `setup.sh` add lineRun `source setup.sh` +4. Run `source setup.sh` ## Create database with Phpmyadmin @@ -19,7 +19,7 @@ Make sure to replace 0.0.0.0 with your server's IP address - If a database of that name already exists, drop it and create it again 7. Create a user named `urcpp-flask` with password `DanforthLabor123!` 8. Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask` -Continue to step 13. +Continue to step 14. ## Create database with MySQL Workbench and Terminal diff --git a/api/everything.py b/api/everything.py index d35b7c4..35a6881 100755 --- a/api/everything.py +++ b/api/everything.py @@ -17,7 +17,7 @@ from flask import send_from_directory from flask import flash from flask import abort -from werkzeug.utils import secure_filename +from werkzeug import secure_filename # need to import g from flask_login from flask_login import login_user, logout_user, current_user, LoginManager, login_required diff --git a/setup.sh b/setup.sh index cd2621a..ed970d8 100755 --- a/setup.sh +++ b/setup.sh @@ -12,13 +12,13 @@ then fi # Check for correct python version -VERSION=`python2 -V | awk '{print $2}'` -if [ "${VERSION:0:1}" -ne "2" ] || [ "${VERSION:2:1}" -ne "7" ]; then - echo "You must use Python 2.7. You are using $VERSION" - return 1 -else - echo -e "You are using Python $VERSION" -fi +# VERSION=`python2 -V | awk '{print $2}'` +# if [ "${VERSION:0:1}" -ne "2" ] || [ "${VERSION:2:1}" -ne "7" ]; then +# echo "You must use Python 2.7. You are using $VERSION" +# return 1 +# else +# echo -e "You are using Python $VERSION" +# fi virtualenv --python=python2.7 venv . venv/bin/activate @@ -39,11 +39,43 @@ fi FILE=${PWD}/api/settings.py if test -f "$FILE"; then echo "$FILE exists" -else +else touch $FILE echo "$FILE created" fi echo "Remember to edit your mail settings in $FILE" +pip install -U Werkzeug==0.16.0 +pip install Flask +pip install peewee +pip install pyyaml +# For security, for LDAP +pip install pyopenssl ndg-httpsclient pyasn1 +pip install ldap3 +# For docs +pip install mkdocs +pip install gunicorn +pip install tornado + +# additional python library +pip install XlsxWriter + +#for login +pip install Flask-Login +pip install PyMySQL +# For QR Codes +pip install flask-wtf +pip install wtf-peewee +#flask-mail library +pip install Flask-Mail +#pip install sqlite-web +#pip install pyotp +#pip install qrcode +#pip install Pillow +#pip install git+git://github.com/ojii/pymaging.git#egg=pymaging +#pip install git+git://github.com/ojii/pymaging-png.git#egg=pymaging-png + +# Database setup +# python recreate_dynamic.py # To deactivate the venv, use # @@ -53,4 +85,3 @@ echo "Remember to edit your mail settings in $FILE" # To set up the venv again, then type # # $ source setup.sh - From 571e6f12c9e265a4eff387e9a24048602f0e01af Mon Sep 17 00:00:00 2001 From: sreynitkhatt Date: Wed, 6 Apr 2022 15:00:30 -0400 Subject: [PATCH 4/4] edit readme for setup --- README.md | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3abec7e..4b3e784 100755 --- a/README.md +++ b/README.md @@ -15,25 +15,19 @@ 5. Go to your Phpmyadmin interface and log in with your credentials - Located here: `http://0.0.0.0/phpmyadmin/` Make sure to replace 0.0.0.0 with your server's IP address -6. Create a new database named `urcpp_flask_v2` +6. Create a new database named `urcpp_flask` - If a database of that name already exists, drop it and create it again -7. Create a user named `urcpp-flask` with password `DanforthLabor123!` -8. Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask` +7. Create a user named `urcpp_flask` with password `DanforthLabor123!` +8. Grant all permissions on the database `urcpp_flask` to `urcpp_flask` Continue to step 14. -## Create database with MySQL Workbench and Terminal +## Create database using MYSQL commands 9. In your terminal use the command `mysql -u root -p`. You will be prompted to enter your password -10. To create the database: `CREATE DATABASE urcpp_flask_v2;` (Make sure you include the ;) -11. To create a user named `urcpp-flask` with password `DanforthLabor123!`: `CREATE USER 'urcpp-flask'@localhost IDENTIFIED BY 'DanforthLabor123!'; ` -12. To Grant all permissions on the database `urcpp_flask_v2` to `urcpp-flask`: ` GRANT ALL PRIVILEGES ON `urcpp_flask_v2` . * TO 'urcpp-flask'@localhost; ` -13. To make sure permissions take effect: ` flush privileges; ` +10. Create the database: ` CREATE DATABASE urcpp_flask; ` +11. Create a user with given password: ` CREATE USER 'urcpp_flask'@localhost IDENTIFIED BY 'DanforthLabor123!'; ` +12. Grant all permissions: ` GRANT ALL PRIVILEGES ON 'urcpp_flask' . * TO 'urcpp_flask'@localhost; ` +13. Make sure permissions take effect: ` flush privileges; ` ## Continue from here again -14. Create a file named `secret_key` in the `api` folder -- `secret_key` MUST contain some alphanumeric characters. Anything will work including `AnythignWillWork` -15. Comment out lines 20-27 in `api/__init__.py` -16. Run `python recreate_static.py` -17. Run `python recreate_dynamic.py` -18. Comment lines 20-27 in `api/__init__.py` back in -19. Run `python api.py` +14. Run `python api.py`