icmp ping #1

Open
fil wants to merge 6 commits from dev into main
4 changed files with 15 additions and 16 deletions
Showing only changes of commit 4f4a0ed627 - Show all commits

View file

@ -1,14 +1,9 @@
import os
import yaml
from dotenv import load_dotenv
defConfig = {
"DB_HOST": "",
"DB_DATABASE": "",
"DB_USER": "",
"DB_PASSWORD": "",
"LOCATION":""
}
with open("config.yaml") as f:
cfg = yaml.load(f, Loader=yaml.FullLoader)
class Config:
config_data: dict
@ -27,7 +22,7 @@ class Config:
def __init(self):
load_dotenv()
self.config_data = defConfig
for key in defConfig.keys():
self.config_data = cfg
for key in cfg.keys():
if key in os.environ:
self.config_data[key] = os.environ[key]

5
config.yaml Normal file
View file

@ -0,0 +1,5 @@
db_host: ""
db_database: ""
db_user: ""
db_password: ""
location: ""

View file

@ -2,7 +2,6 @@ from config import Config
import psycopg2.extras
import psycopg2
class Database():
def __init__(self):
self.config = Config()
@ -10,10 +9,10 @@ class Database():
def connect(self):
self.conn = psycopg2.connect(
host=self.config["DB_HOST"],
database=self.config["DB_DATABASE"],
user=self.config["DB_USER"],
password=self.config["DB_PASSWORD"]
host=self.config["db_host"],
database=self.config["db_database"],
user=self.config["db_user"],
password=self.config["db_password"]
)
self.cur = self.conn.cursor(
cursor_factory=psycopg2.extras.RealDictCursor)

View file

@ -29,7 +29,7 @@ class PingPong:
def start(self):
latency = {
"location": self.config["LOCATION"]
"location": self.config["location"]
}
for el in self.db.get_all_services():
state = self.db.create_state(el['id'])[0]