From 554911ca39b2223efc2f936839db2625982907c2 Mon Sep 17 00:00:00 2001 From: Wilson Gomez Date: Sat, 21 Oct 2023 12:26:40 -0500 Subject: [PATCH] fix validate open app in platform nt --- pospro | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pospro b/pospro index 74d0bc5..a7752e8 100755 --- a/pospro +++ b/pospro @@ -33,13 +33,21 @@ class SingleInstanceApp(QApplication): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + app_open = False + num_opens = 0 for process in psutil.process_iter(['pid', 'name', 'cmdline']): name = process.info['name'] cmdline = process.info['cmdline'] - if name == PROCESS_NAME or (isinstance(cmdline, list) and 'pospro' in cmdline): - logger.error('La aplicación ya esta en ejecución') - self.show_already_running_dialog() - sys.exit(1) + if name == PROCESS_NAME and OS_NAME == 'posix': + app_open = True + elif OS_NAME == 'nt' and isinstance(cmdline, list) and 'pospro' in cmdline): + num_opens += 1 + + if app_open or num_opens > 1: + logger.error('La aplicación ya esta en ejecución') + self.show_already_running_dialog() + sys.exit(1) + def show_already_running_dialog(self): msg = QMessageBox()