mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-25 23:14:55 +01:00
corrected some more places where ./logs was used
instead of the dynamically given logs path.
This commit is contained in:
parent
1fa3f88997
commit
fea1ba04f0
3 changed files with 6 additions and 6 deletions
|
@ -160,7 +160,7 @@ class LogController:
|
|||
for id in ids:
|
||||
# df = pd.read_csv("./logs/sensor_%s.log" % id, parse_dates=True, date_parser=dateparse, index_col='DateTime', names=['DateTime',"Values"], header=None)
|
||||
# concat all logs
|
||||
all_filenames = glob.glob(os.path.join(self.logsFolderPath,f"./logs/sensor_{id}.log*"))
|
||||
all_filenames = glob.glob(os.path.join(self.logsFolderPath,f"sensor_{id}.log*"))
|
||||
df = pd.concat([pd.read_csv(f, parse_dates=True, date_parser=dateparse, index_col='DateTime', names=['DateTime', 'Values'], header=None) for f in all_filenames])
|
||||
df = df.resample('60s').max()
|
||||
df = df.dropna()
|
||||
|
@ -179,8 +179,7 @@ class LogController:
|
|||
return [os.path.basename(x) for x in os.path.join(self.logsFolderPath, f"sensor_{name}.log*")]
|
||||
|
||||
def clear_log(self, name:str ) -> str:
|
||||
|
||||
all_filenames = os.path.join(self.logsFolderPath, f"sensor_{name}.log*")
|
||||
all_filenames = glob.glob(os.path.join(self.logsFolderPath, f"sensor_{name}.log*"))
|
||||
for f in all_filenames:
|
||||
os.remove(f)
|
||||
|
||||
|
@ -216,7 +215,7 @@ class LogController:
|
|||
"""
|
||||
|
||||
formatted_time = strftime("%Y-%m-%d-%H_%M_%S", localtime())
|
||||
file_name = os.path.join(self.logsFolderPath, f"./logs/{formatted_time}-sensor-{name}.zip" % (formatted_time, name))
|
||||
file_name = os.path.join(self.logsFolderPath, f"{formatted_time}-sensor-{name}.zip" % (formatted_time, name))
|
||||
zip = zipfile.ZipFile(file_name, 'w', zipfile.ZIP_DEFLATED)
|
||||
all_filenames = os.path.join(self.logsFolderPath, f"sensor_{name}.log*")
|
||||
for f in all_filenames:
|
||||
|
|
|
@ -2,6 +2,7 @@ from cbpi.utils.encoder import ComplexEncoder
|
|||
from aiohttp import web
|
||||
from cbpi.utils.utils import json_dumps
|
||||
from cbpi.api import request_mapping
|
||||
import os
|
||||
import json
|
||||
class LogHttpEndpoints:
|
||||
|
||||
|
@ -83,7 +84,7 @@ class LogHttpEndpoints:
|
|||
)
|
||||
await response.prepare(request)
|
||||
log_name = request.match_info['name']
|
||||
with open('./logs/%s.zip' % log_name, 'rb') as file:
|
||||
with open(os.path.join(self.cbpi.logsFolderPath, '%s.zip' % log_name), 'rb') as file:
|
||||
for line in file.readlines():
|
||||
await response.write(line)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class SystemHttpEndpoints:
|
|||
async def http_get_log(self, request):
|
||||
result = []
|
||||
file_pattern = re.compile("^(\w+.).log(.?\d*)")
|
||||
for filename in sorted(os.listdir("./logs"), reverse=True): #
|
||||
for filename in sorted(os.listdir(self.cbpi.logsFolderPath), reverse=True):
|
||||
if file_pattern.match(filename):
|
||||
result.append(filename)
|
||||
return web.json_response(result)
|
||||
|
|
Loading…
Reference in a new issue