diff --git a/.gitignore b/.gitignore index 5d381cc..de5e1bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +run.sh + # ---> Python # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/requirements.txt b/requirements.txt index dac8dca..a838dd0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,7 @@ +certifi==2022.12.7 +charset-normalizer==3.0.1 dnspython==2.3.0 -pymongo==4.3.3 \ No newline at end of file +idna==3.4 +pymongo==4.3.3 +requests==2.28.2 +urllib3==1.26.14 diff --git a/src/corpus.py b/src/corpus.py index e69de29..1778d61 100644 --- a/src/corpus.py +++ b/src/corpus.py @@ -0,0 +1,21 @@ +#Imports +import os +import requests +import logger as log + +CORPUS_URL = "https://publicdatafeeds.networkrail.co.uk/ntrod/SupportingFileAuthenticate?type=CORPUS" + +#Fetch Configuration +log.out("corpus.py: Fetching CORPUS Configuration", "INFO") +CORPUS_USER = os.getenv('OWL_LDB_CORPUSUSER') +CORPUS_PASS = os.getenv('OWL_LDB_CORPUSPASS') + +def hello(): + print("hello") + return + +def fetchCorpus(): + r = requests.get(CORPUS_URL, auth=(CORPUS_USER, CORPUS_PASS)) + ## Need to ungzip the response + ## Need to return the result + return \ No newline at end of file diff --git a/src/logger.py b/src/logger.py new file mode 100644 index 0000000..36bcc50 --- /dev/null +++ b/src/logger.py @@ -0,0 +1,4 @@ +from datetime import datetime + +def out(msg, level): + print(datetime.now().strftime("%m/%d/%Y, %H:%M:%S") + ": " + level + ": " + msg) \ No newline at end of file diff --git a/src/main.py b/src/main.py index f8f4f0c..6eb5937 100644 --- a/src/main.py +++ b/src/main.py @@ -16,15 +16,15 @@ print("main.py: Initialising db-manager") -#Imports +#Third Party Imports import os import time -import pymongo + +#Local Imports +import corpus +import mongo +import logger as log #Fetch Environment Variables -corpus_user = os.getenv('OWL_LDB_CORPUSUSER') -corpus_pass = os.getenv('OWL_LDB_CORPUSPASS') -db_url = os.getenv('OWL_DB_HOST') + ":" + os.getenv('OWL_DB_PORT') -db_user = os.getenv('OWL_DB_USER') -db_pass = os.getenv('OWL_DB_PASS') - +log.out("main.py: Trying to print CORPUS Data", 'INFO') +print(corpus.fetchCorpus()) \ No newline at end of file diff --git a/src/mongo.py b/src/mongo.py index e69de29..6f02310 100644 --- a/src/mongo.py +++ b/src/mongo.py @@ -0,0 +1,9 @@ +import os +from pymongo import MongoClient +import urllib.parse +import logger as log + +log.out("mongo.py: Fetching configuration", "INFO") +db_url = os.getenv('OWL_DB_HOST') + ":" + os.getenv('OWL_DB_PORT') +db_user = urllib.parse.quote_plus(os.getenv('OWL_DB_USER')) +db_pass = urllib.parse.quote_plus(os.getenv('OWL_DB_PASS')) \ No newline at end of file