fix validate open app in platform nt
This commit is contained in:
parent
e58740f557
commit
554911ca39
16
pospro
16
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()
|
||||
|
|
Loading…
Reference in New Issue