autotest on logout tbt

This commit is contained in:
neo-dl 2023-05-22 18:39:28 +02:00
parent 068cf7b973
commit 3629f86c2d
3 changed files with 20 additions and 8 deletions

View File

@ -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,

View File

@ -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,16 +218,22 @@ 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)
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):

View File

@ -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