Skip to content

Commit

Permalink
Update get-services-status.py
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGinocchio committed Oct 10, 2024
1 parent 6423df9 commit ecaa2f0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/actions/get-services-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from datetime import datetime, timezone
from requests import Response
from os import path
from os import makedirs
import requests
import json

def extendavg(avg : float, n : int, element : float):
return (avg * n + element) / (n + 1)
def extendavg(avg : float, n : int, element : float): return (avg * n + element) / (n + 1)

session = requests.Session()

Expand Down Expand Up @@ -97,7 +97,7 @@ def update(self):
self.overall['avg-downtime-percentage'] = avg_downtime_percentage

def load(self):
if not path.exists(service_path:=f'./data/services/{self.name.lower()}.json'): return
if not path.exists(service_path:=f'./data/services/{self.name.lower()}/{self.name.lower()}.json'): return
with open(service_path,'r') as f: content : dict = json.load(f)

self.metrics = content.get('metrics',self.metrics)
Expand All @@ -110,7 +110,8 @@ def add_note(self): pass
def add_report(self): pass

def save(self):
with open(f'./data/services/{self.name.lower()}.json','w') as f:
makedirs(f'./data/services/{self.name.lower()}/graphs',exist_ok=True)
with open(f'./data/services/{self.name.lower()}/{self.name.lower()}.json','w') as f:
json.dump({
'name' : self.name,
'description' : self.description,
Expand Down

0 comments on commit ecaa2f0

Please sign in to comment.