From 9388eda466fedc03f229da9f9dc61aad5023348b Mon Sep 17 00:00:00 2001 From: jakobsn Date: Thu, 30 Jan 2020 16:10:32 +0100 Subject: [PATCH 1/3] typo --- src/app/models/user.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/models/user.py b/src/app/models/user.py index 0ba3839..b372802 100644 --- a/src/app/models/user.py +++ b/src/app/models/user.py @@ -69,7 +69,6 @@ def get_user_name_by_id(userid): finally: cursor.close() db.close() - cursor.close() return username def match_user(username, password): From 978b6a75badeead01e2d495c9a55ebe632531372 Mon Sep 17 00:00:00 2001 From: jakobsn Date: Thu, 30 Jan 2020 16:18:29 +0100 Subject: [PATCH 2/3] Update readme --- README.md | 59 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 1930b04..9e23141 100644 --- a/README.md +++ b/README.md @@ -2,34 +2,34 @@ Python webpy application running on uswgi server with nginx using docker connected to another docker-runned mysql database. -Web Server image: https://github.com/tiangolo/uwsgi-nginx-docker -webpy framework: http://webpy.org/ - - -## Prerequisites: - -Docker https://www.docker.com/ +Web Server image base: https://github.com/tiangolo/uwsgi-nginx-docker -IMPORTANT Windows users use: -> git clone --repositoryURL-- --config core.autocrlf=input - -On linux docker is started with +webpy framework: http://webpy.org/ -$ sudo systemctl start docker -To run docker-compose without sudo the user must be added to the usergroup: +## Installation: -https://docs.docker.com/install/linux/linux-postinstall/ +1. Install docker: https://www.docker.com/ +2. Install docker-compose: https://docs.docker.com/compose/install/ +3. Launch docker +4. Clone this repository: +> git clone \ -## Run +IMPORTANT Windows users must use: +> git clone \ --config core.autocrlf=input +5. Run the application: +> docker-compose up -$ docker-compose up +6. The application should become available on URL: +http://0.0.0.0:80\
+Or if you are running docker-toolbox : +http://192.168.99.100:80\ ### Build / Rebuild Upon changes in the code the docker image must be built again for the changes to take effect. Some changes might not get reflected even on build, which is when the --force-recreate attribute can be used. -$ docker-compose up --build --force-recreate +$ docker-compose up --build ### Prune / Recreate If you need a completely fresh rebuild (WARNING this will remove all your docker images). This will reset the images including the database which is not necessary affected by only rebuilding the images @@ -38,19 +38,23 @@ $ docker system prune -a $ docker-compose up -# Deploy locally +### Config -Running the application outside of containers might be useful for development because the images does not need to be rebuilt for every change in the code. +The ip and ports for the web server and database is set with the .env file using the groupid variable. + +## Deploy locally -## Prerequisites: +Running the application outside of containers might be useful for development because the images does not need to be rebuilt for every change in the code. This is optional. -mysql +### Prerequisites: -python 3.6.8 or higher +mysql server -src/app/requirements.txt +python =< 3.6.8 -## Run Datatbase: +python packages: src/app/requirements.txt + +### Run Datatbase: Launch mysql at default port (3306) @@ -70,11 +74,9 @@ SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'); GRANT ALL PRIVILEGES ON db.* TO 'root'@'localhost'; - Then populate databse by posting mysql/sql/init.sql into mysql - -## Run app +### Run app Edit src/app/models/database.py to point at local database server @@ -82,6 +84,3 @@ $ cd src/app/ $ python3 src/app/main.py -# Config - -The ip and ports for the web server and database is set with the .env file using the groupid variable. From 2ef59fd8404ad517e2d2e890dc285c3c0b5ac5e2 Mon Sep 17 00:00:00 2001 From: jakobsn Date: Thu, 30 Jan 2020 16:18:32 +0100 Subject: [PATCH 3/3] Bug in exceptionhandler --- src/app/models/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/models/project.py b/src/app/models/project.py index e23fb65..91a58e3 100644 --- a/src/app/models/project.py +++ b/src/app/models/project.py @@ -277,7 +277,7 @@ def update_task_status(taskid, status): try: cursor.execute(query) db.commit() - except: + except mysql.connector.Error as err: print("Failed executing query: {}".format(err)) cursor.fetchall() exit(1)