Commit f9982b09 authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper
Browse files

Fatals on interface not found, dinamically finds home dir

parent cb8aa8ee
from datetime import datetime from datetime import datetime
from pathlib import Path
from PyQt5.QtCore import QTimer from PyQt5.QtCore import QTimer
from pyqtgraph import AxisItem, InfiniteLine, mkColor, mkPen, setConfigOption from pyqtgraph import AxisItem, InfiniteLine, mkColor, mkPen, setConfigOption
from interfaces import * from interfaces import *
...@@ -20,8 +21,9 @@ class Graph(): ...@@ -20,8 +21,9 @@ class Graph():
self.device = self.config["device"] self.device = self.config["device"]
today = datetime.now().strftime("%Y-%m-%d-%H:%M:%S") today = datetime.now().strftime("%Y-%m-%d-%H:%M:%S")
self.logFile = open("/home/phckopper/logs/{}-calib.csv".format(today), "w") home = str(Path.home())
logger("[LOGS]", "Salvando dados em: /home/phckopper/logs/{}-calib.csv".format(today)) self.logFile = open("{}/logs/{}-calib.csv".format(home, today), "w")
logger("[LOGS]", "Salvando dados em: {}/logs/{}-calib.csv".format(home, today))
self._configurePlots() self._configurePlots()
self.lastupdated = 0 self.lastupdated = 0
...@@ -29,8 +31,9 @@ class Graph(): ...@@ -29,8 +31,9 @@ class Graph():
try: try:
self.interface = INTERFACES[self.device["type"]](logger, self.device["location"], self.device["channels"]) self.interface = INTERFACES[self.device["type"]](logger, self.device["location"], self.device["channels"])
except FileNotFoundError: except:
self.running = False self.running = False
logger("[FATAL", "Erro ao abrir a interface!")
self.graph.setBackground((240, 240, 240)) self.graph.setBackground((240, 240, 240))
......
...@@ -53,6 +53,8 @@ class MainThread(): ...@@ -53,6 +53,8 @@ class MainThread():
def _log(self, tag, msg): def _log(self, tag, msg):
self.ui.consoleView.setText("{} {}\n{}".format(tag, msg, self.ui.consoleView.text())) self.ui.consoleView.setText("{} {}\n{}".format(tag, msg, self.ui.consoleView.text()))
if "FATAL" in tag:
_fatal(msg)
def _playPause(self): def _playPause(self):
if self.graph.running: if self.graph.running:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment