diff --git a/lyse/__main__.py b/lyse/__main__.py index be6c02c..79440dd 100644 --- a/lyse/__main__.py +++ b/lyse/__main__.py @@ -115,11 +115,13 @@ def __init__(self, qapplication): # Forth: start remote communication server self.port = int(self.exp_config.get('ports', 'lyse')) self.server = lyse.communication.WebServer(self, self.port) + self.logger.info(f'Started lyse server on port {self.port}') # Last: UI setup self.qapplication = qapplication loader = UiLoader() self.ui = loader.load(os.path.join(lyse.utils.LYSE_DIR, 'user_interface/main.ui'), LyseMainWindow(self)) + self.logger.info('UI loaded') self.connect_signals() @@ -138,6 +140,7 @@ def __init__(self, qapplication): self, to_multishot, from_multishot, self.output_box.port, multishot=True) self.filebox = lyse.filebox.FileBox(self, self.ui.verticalLayout_filebox, self.exp_config, to_singleshot, from_singleshot, to_multishot, from_multishot) + self.logger.info('Boxes loaded') self.last_save_config_file = None self.last_save_data = None @@ -188,6 +191,7 @@ def load_the_config_file(): # Success - skip loading window geometry in load_configuration: restore_window_geometry = False self.ui.firstPaint.connect(lambda: QtCore.QTimer.singleShot(50, load_the_config_file)) + self.logger.info('lyse configuration loaded') self.ui.show() @@ -522,7 +526,7 @@ def delete_items(self, confirm): signal.signal(signal.SIGINT, lambda *args: qapplication.exit()) splash.hide() - qapplication.exec_() + qapplication.exec() # Shutdown the webserver. app.server.shutdown() diff --git a/lyse/analysis_subprocess.py b/lyse/analysis_subprocess.py index 0a0f100..7021162 100644 --- a/lyse/analysis_subprocess.py +++ b/lyse/analysis_subprocess.py @@ -475,5 +475,5 @@ def reset_figs(self): if qapplication is None: qapplication = QtWidgets.QApplication(sys.argv) worker = AnalysisWorker(filepath, to_parent, from_parent) - qapplication.exec_() + qapplication.exec() diff --git a/lyse/filebox.py b/lyse/filebox.py index 8cf23d3..b2e135b 100644 --- a/lyse/filebox.py +++ b/lyse/filebox.py @@ -142,7 +142,7 @@ def on_treeView_context_menu_requested(self, point): menu = QtWidgets.QMenu(self.ui) menu.addAction(self.action_set_selected_visible) menu.addAction(self.action_set_selected_hidden) - menu.exec_(QtGui.QCursor.pos()) + menu.exec(QtGui.QCursor.pos()) def on_set_selected_triggered(self, visible): selected_indexes = self.ui.treeView.selectedIndexes() @@ -373,7 +373,7 @@ def mark_selection_not_done(self): def on_view_context_menu_requested(self, point): menu = QtWidgets.QMenu(self._view) menu.addAction(self.action_remove_selected) - menu.exec_(QtGui.QCursor.pos()) + menu.exec(QtGui.QCursor.pos()) def on_double_click(self, index): filepath_item = self._model.item(index.row(), self.COL_FILEPATH) diff --git a/lyse/routines.py b/lyse/routines.py index e638af3..1f4aa7a 100644 --- a/lyse/routines.py +++ b/lyse/routines.py @@ -54,12 +54,14 @@ def __init__(self, app, container, exp_config, filebox, from_filebox, to_filebox self.to_filebox = to_filebox self.output_box_port = output_box_port - self.logger = logging.getLogger('lyse.RoutineBox.%s'%('multishot' if multishot else 'singleshot')) + self.logger = logging.getLogger('lyse.RoutineBox.%s'%('multishot' if multishot else 'singleshot')) + self.logger.info('starting') loader = UiLoader() loader.registerCustomWidget(lyse.widgets.TreeView) self.ui = loader.load(os.path.join(lyse.utils.LYSE_DIR, 'user_interface/routinebox.ui')) container.addWidget(self.ui) + self.logger.info('UI loaded') if multishot: self.ui.groupBox.setTitle('Multishot routines') @@ -110,6 +112,7 @@ def __init__(self, app, container, exp_config, filebox, from_filebox, to_filebox self.connect_signals() + self.logger.info('starting analysis loop') self.analysis = threading.Thread(target = self.analysis_loop) self.analysis.daemon = True self.analysis.start() @@ -170,7 +173,9 @@ def add_routines(self, routine_files, clear_existing=False): if filepath in [routine.filepath for routine in self.routines]: self.app.output_box.output('Warning: Ignoring duplicate analysis routine %s\n'%filepath, red=True) continue - routine = AnalysisRoutine(self.app, filepath, self.model, self.output_box_port, checked) + self.logger.info(f'adding routine for {filepath}') + routine = AnalysisRoutine(self.app, filepath, self.model, self.output_box_port, + QtCore.Qt.CheckState(checked)) self.routines.append(routine) self.update_select_all_checkstate() @@ -215,6 +220,7 @@ def remove_selection(self, confirm=True): if routine.filepath in filepaths: routine.remove() self.routines.remove(routine) + self.logger.info(f'removing routine for {routine.filepath}') self.update_select_all_checkstate() def on_model_item_changed(self, item): @@ -237,7 +243,7 @@ def on_treeView_context_menu_requested(self, point): menu.addAction(self.action_set_selected_inactive) menu.addAction(self.action_restart_selected) menu.addAction(self.action_remove_selected) - menu.exec_(QtGui.QCursor.pos()) + menu.exec(QtGui.QCursor.pos()) def on_set_selected_triggered(self, active): selected_indexes = self.ui.treeView.selectedIndexes() @@ -423,8 +429,12 @@ def __init__(self, app, filepath, model, output_box_port, checked=QtCore.Qt.Chec self.error = False self.done = False - + + self.logger = logging.getLogger(f'lyse.AnalysisRoutine.{self.shortname}') + + self.logger.info('starting worker') self.to_worker, self.from_worker, self.worker = self.start_worker() + self.logger.info('analysis_subprocess started') # Make a row to put into the model: active_item = QtGui.QStandardItem() diff --git a/lyse/utils/gui.py b/lyse/utils/gui.py index c52cc7b..f882382 100644 --- a/lyse/utils/gui.py +++ b/lyse/utils/gui.py @@ -103,8 +103,8 @@ def get_screen_geometry(qapplication): """Return the a list of the geometries of each screen: each a tuple of left, top, width and height""" geoms = [] - desktop = qapplication.desktop() - for i in range(desktop.screenCount()): - sg = desktop.screenGeometry(i) - geoms.append((sg.left(), sg.top(), sg.width(), sg.height())) + screens = qapplication.screens() + for screen in screens: + sg = screen.geometry() + geoms.append((sg.x(), sg.y(), sg.width(), sg.height())) return geoms \ No newline at end of file diff --git a/lyse/utils/tempfile2clipboard.py b/lyse/utils/tempfile2clipboard.py index 224f112..e50bc4b 100644 --- a/lyse/utils/tempfile2clipboard.py +++ b/lyse/utils/tempfile2clipboard.py @@ -65,7 +65,7 @@ def main(): # Keep running until the clipboard contents change to something else: app.clipboard().dataChanged.connect(app.quit) - app.exec_() + app.exec() if __name__ == '__main__':