This commit is contained in:
Fred Boniface 2023-02-11 15:16:25 +00:00
parent 626e9cc796
commit 9118e93b4a
6 changed files with 50 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
run.sh
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/

View File

@ -1,2 +1,7 @@
certifi==2022.12.7
charset-normalizer==3.0.1
dnspython==2.3.0
idna==3.4
pymongo==4.3.3
requests==2.28.2
urllib3==1.26.14

View File

@ -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

4
src/logger.py Normal file
View File

@ -0,0 +1,4 @@
from datetime import datetime
def out(msg, level):
print(datetime.now().strftime("%m/%d/%Y, %H:%M:%S") + ": " + level + ": " + msg)

View File

@ -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())

View File

@ -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'))