Organize
This commit is contained in:
parent
626e9cc796
commit
9118e93b4a
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
|
run.sh
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
|
certifi==2022.12.7
|
||||||
|
charset-normalizer==3.0.1
|
||||||
dnspython==2.3.0
|
dnspython==2.3.0
|
||||||
|
idna==3.4
|
||||||
pymongo==4.3.3
|
pymongo==4.3.3
|
||||||
|
requests==2.28.2
|
||||||
|
urllib3==1.26.14
|
||||||
|
@ -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
4
src/logger.py
Normal 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)
|
16
src/main.py
16
src/main.py
@ -16,15 +16,15 @@
|
|||||||
|
|
||||||
print("main.py: Initialising db-manager")
|
print("main.py: Initialising db-manager")
|
||||||
|
|
||||||
#Imports
|
#Third Party Imports
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import pymongo
|
|
||||||
|
#Local Imports
|
||||||
|
import corpus
|
||||||
|
import mongo
|
||||||
|
import logger as log
|
||||||
|
|
||||||
#Fetch Environment Variables
|
#Fetch Environment Variables
|
||||||
corpus_user = os.getenv('OWL_LDB_CORPUSUSER')
|
log.out("main.py: Trying to print CORPUS Data", 'INFO')
|
||||||
corpus_pass = os.getenv('OWL_LDB_CORPUSPASS')
|
print(corpus.fetchCorpus())
|
||||||
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')
|
|
||||||
|
|
@ -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'))
|
Reference in New Issue
Block a user