From 3629f86c2d1df6fdd385f057a54300c552796588 Mon Sep 17 00:00:00 2001 From: neo-dl Date: Mon, 22 May 2023 18:39:28 +0200 Subject: [PATCH] autotest on logout tbt --- src/lib/db/models/archive.py | 2 +- src/main.py | 18 ++++++++++++------ src/ui/test/test.py | 8 +++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/lib/db/models/archive.py b/src/lib/db/models/archive.py index bd1be74..1aae510 100644 --- a/src/lib/db/models/archive.py +++ b/src/lib/db/models/archive.py @@ -23,7 +23,7 @@ class Archive(BaseModel): @db.atomic() def archive(cls, test_data, result, overridden): time=datetime.now() - test_data["time"]=time.strftime("%Y/%m/%dT %H:%M:%S") + test_data["time"]=time.strftime("%d/%m/%Y %H:%M:%S") test_data["user"]=Users.get_session().username return cls.create( time=time, diff --git a/src/main.py b/src/main.py index a5c0a8e..d779608 100644 --- a/src/main.py +++ b/src/main.py @@ -68,7 +68,7 @@ try: from lib.helpers import ConfigReader from PyQt5.QtCore import QObject, QThread, pyqtSignal from PyQt5.QtWidgets import QApplication, QMessageBox - from ui import About, Archive, Login, Main_Window, Test, Users_Management + from ui import About, Archive, Login, Main_Window, Test, Users_Management, Recipe_Selection if "--vision" in sys.argv: from components import GalaxyCamera, NeoPixels, UVCCamera, Vision, VisionSaver @@ -218,17 +218,23 @@ try: else: self.main_window.admin_m.menuAction().setVisible(False) # open test - self.main_window.open_tab(Test(self.config, self.components)) + self.main_window.open_tab(Test(self.config, self.components,self)) else: self.main_window.admin_m.menuAction().setVisible(False) def logout(self): - if type(self.main_window.centralWidget) is Test: - self.main_window.centralWidget.change_recipe() - self.main_window.centralWidget.request_autotest("logout") Users.logout() self.main_window.admin_m.menuAction().setVisible(False) - self.open_login() + if type(self.main_window.centralWidget().centralWidget.widget) is Recipe_Selection: + # LOGOUT IMMEDIATELY IF NOT TESTING + self.open_login() + else: + if not self.main_window.centralWidget().autotesting: + self.main_window.centralWidget().change_recipe() # STOP CURRENT TEST + self.main_window.centralWidget().request_autotest("logout") + else: + # LOGOUT IMMEDIATELY IF AUTOTESTING + self.open_login() def set_recipe_mode_table(self): self.main_window.centralWidget().set_recipe_mode_table() diff --git a/src/ui/test/test.py b/src/ui/test/test.py index 5d11dd3..b86a50b 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -29,8 +29,9 @@ from ui.widget import Widget class Test(Widget): - def __init__(self, config, components=None): + def __init__(self, config, components=None,main_window=None): super().__init__() + self.main_window=main_window self.config = config self.components = components # GET LOGGER @@ -506,6 +507,11 @@ class Test(Widget): self.pieces["ok"] += 1 else: self.pieces["ko"] += 1 + else: + if self.autotesting_reason == "logout": + if ok: + self.main_window.show_login() + return archived @staticmethod