python gui fixed for reference

This commit is contained in:
Kim 2023-04-06 14:28:35 +02:00
parent 184fc8c10e
commit 171d290e36
4 changed files with 18 additions and 16 deletions

View File

@ -13,6 +13,9 @@ public static class Mailer
var config = JsonSerializer.Deserialize<SmptConfig>(File.OpenRead("./Resources/smtpConfig.json"))!; var config = JsonSerializer.Deserialize<SmptConfig>(File.OpenRead("./Resources/smtpConfig.json"))!;
var email = new MimeMessage(); var email = new MimeMessage();
try
{
email.From.Add(new MailboxAddress("InnovEnergy", "noreply@innov.energy")); email.From.Add(new MailboxAddress("InnovEnergy", "noreply@innov.energy"));
email.To.Add(new MailboxAddress(emailRecipientUser.Name, emailRecipientUser.Email)); email.To.Add(new MailboxAddress(emailRecipientUser.Name, emailRecipientUser.Email));
@ -27,8 +30,13 @@ public static class Mailer
smtp.Authenticate(config.Username, config.Password); smtp.Authenticate(config.Username, config.Password);
smtp.Send(email); smtp.Send(email);
smtp.Disconnect(true); smtp.Disconnect(true);
}
catch (Exception)
{
return false;
}
return true; return true;
} }

Binary file not shown.

View File

@ -475,12 +475,7 @@ def update_graphs(n, graphs):
# TODO GRAB NEW DATA FROM DISK OR S3 # TODO GRAB NEW DATA FROM DISK OR S3
timeData = {} timeData = {}
#Local copy of allFileNames because we loop over them at the moment #Local copy of allFileNames because we loop over them at the moment
n = allFileNames number = [item for item in allFileNames if item not in fileNames][n % len(allFileNames)-1]
number = int(list(set(n) - set(fileNames))[0])
# #TODO REMOVE ME
# if number >= 1673427558:
# number = 1673427378
fileNames.pop(0) fileNames.pop(0)
fileNames.append(str(number)) fileNames.append(str(number))
@ -527,8 +522,8 @@ def update_graphs(n, graphs):
devices[k].power[1] = fig["data"][0]['y'][0] devices[k].power[1] = fig["data"][0]['y'][0]
fig["data"][0]['x'][0] = now(filename) fig["data"][0]['x'][0] = now(filename)
fig["data"][0]['y'] = np.roll(fig["data"][0]['y'], -1) fig["data"][0]['y'] = fig["data"][0]['y'][-1:] + fig["data"][0]['y'][:-1]
fig["data"][0]['x'] = np.roll(fig["data"][0]['x'], -1) fig["data"][0]['x'] = fig["data"][0]['x'][-1:] + fig["data"][0]['x'][:-1]
continue continue
if "Dc" in id["role"].split(" ",1)[1] or "Ac" in id["role"].split(" ",1)[1] or "Alarm" in id["role"] and "Actual" not in id["role"] : if "Dc" in id["role"].split(" ",1)[1] or "Ac" in id["role"].split(" ",1)[1] or "Alarm" in id["role"] and "Actual" not in id["role"] :
@ -559,11 +554,10 @@ def update_graphs(n, graphs):
continue continue
fig["data"][0]['y'][0] = devices[k].data[list(devices[k].data.keys())[-1]][id["role"].split(" ", 1)[1]] fig["data"][0]['y'][0] = devices[k].data[list(devices[k].data.keys())[-1]][id["role"].split(" ", 1)[1]]
fig["data"][0]['y'] = np.roll(fig["data"][0]['y'], -1)
fig["data"][0]['x'][0] = now(filename) fig["data"][0]['x'][0] = now(filename)
fig["data"][0]['x'] = np.roll(fig["data"][0]['x'], -1) fig["data"][0]['y'] = fig["data"][0]['y'][-1:] + fig["data"][0]['y'][:-1]
fig["data"][0]['x'] = fig["data"][0]['x'][-1:] + fig["data"][0]['x'][:-1]
return graphs return graphs
# Main HTML Layout of the app ------------------------------------------------------------------------------------------ # Main HTML Layout of the app ------------------------------------------------------------------------------------------
@ -635,4 +629,4 @@ app.layout = html.Div(children=[
# Main App Start on specified ip (here local) # Main App Start on specified ip (here local)
if __name__ == '__main__': if __name__ == '__main__':
app.run_server(host= 'localhost', debug=False) app.run_server(host= 'localhost', debug=False, port=8080)

View File

@ -14,7 +14,7 @@ def find_Device_strict(name: str, devices):
return [dev for dev in devices if dev.name == name] return [dev for dev in devices if dev.name == name]
def now(timestamp): def now(timestamp):
#return datetime.fromtimestamp(int(timestamp.split("/")[-1])).replace(microsecond=0) # return datetime.fromtimestamp(int(timestamp.split("/")[-1])).replace(microsecond=0)
return datetime.now().replace(microsecond=0) #TODO CHANGE ME WHEN GETTING NEW FILES return datetime.now().replace(microsecond=0) #TODO CHANGE ME WHEN GETTING NEW FILES