From da9f0583c38496310fb20b0267904854fe40169f Mon Sep 17 00:00:00 2001 From: Anjana Supun Date: Sat, 16 Mar 2019 17:11:10 +0530 Subject: [PATCH] Add console logging, Improve db config in README --- README.md | 36 +++++++++++++++++++----------------- components/core/Main.py | 15 +++++++++++++-- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index cf2463a6..c6cdb45f 100644 --- a/README.md +++ b/README.md @@ -52,27 +52,32 @@ Use python 3 instead of Python 2 Bassa has 4 main compoenents, 1. Database 2. Bassa API -3. Bassa UI -4. aria2 +3. aria2 +4. Bassa UI ## Database Setup -1. Type below in a MySql terminal. +1.Type below in a MySql terminal. ``` create database Bassa ``` -2. Type below in the root of project. +2.Type below in the root of project. ``` mysql -u root -p Bassa < Bassa.sql ``` -3. Open components/core/DBCon.py and setup database username and password. - - +3.Open components/core/DBCon.py and setup database username and password. +``` +_db=MySQLdb.connect("db", os.environ.get('YOUR_DB_USERNAME'), os.environ.get('YOUR_DB_PASSWORD'), os.environ.get('Bassa')) +``` +If you don't have environment variables setup, you can use the following line with hard coded values for testing purposes +``` +_db=MySQLdb.connect(host="localhost", user="YOUR_DB_USERNAME", passwd="YOUR_DB_PASSWORD",db= "Bassa") +``` ## Bassa API ``` $ cd components/core/ @@ -80,6 +85,13 @@ mysql -u root -p Bassa < Bassa.sql ``` ![python3main](https://user-images.githubusercontent.com/28682735/35194408-2fce9136-fed9-11e7-80e6-fac5e6f54bc7.gif) +## Run aria2 +run `aria2c --enable-rpc` + +Read more on installing `aria2` [here](https://aria2.github.io/manual/en/html/README.html) + + +![aria2c](https://user-images.githubusercontent.com/28682735/35193755-709e92ee-fecd-11e7-8dd0-412304853c8c.gif) ## Bassa UI @@ -106,16 +118,6 @@ In the first time you log in, the credentials would be as follows. ![bassaui](https://user-images.githubusercontent.com/28682735/35193753-667c7e0c-fecd-11e7-918f-13ce1d00d055.gif) - -## Make sure you have aria2 installed. -run `aria2c --enable-rpc` - -Read more on installing `aria2` [here](https://aria2.github.io/manual/en/html/README.html) - - -![aria2c](https://user-images.githubusercontent.com/28682735/35193755-709e92ee-fecd-11e7-8dd0-412304853c8c.gif) - - ## Running Tests ### API Tests diff --git a/components/core/Main.py b/components/core/Main.py index 2fae64f4..5039bc18 100644 --- a/components/core/Main.py +++ b/components/core/Main.py @@ -11,7 +11,18 @@ def main(): if __name__ == '__main__': - logging.basicConfig(filename="./debug-server.log", level=logging.DEBUG) - logging.warning("INFO: Bassa starting") + logging.basicConfig( + filename="./debug-server.log", + level=logging.DEBUG, + format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%m-%d %H:%M' + ) + + console = logging.StreamHandler() + formatter = logging.Formatter('%(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + logging.info("Bassa starting") check_conf_availability() main()