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):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
app_open = False
|
||||||
|
num_opens = 0
|
||||||
for process in psutil.process_iter(['pid', 'name', 'cmdline']):
|
for process in psutil.process_iter(['pid', 'name', 'cmdline']):
|
||||||
name = process.info['name']
|
name = process.info['name']
|
||||||
cmdline = process.info['cmdline']
|
cmdline = process.info['cmdline']
|
||||||
if name == PROCESS_NAME or (isinstance(cmdline, list) and 'pospro' in cmdline):
|
if name == PROCESS_NAME and OS_NAME == 'posix':
|
||||||
logger.error('La aplicación ya esta en ejecución')
|
app_open = True
|
||||||
self.show_already_running_dialog()
|
elif OS_NAME == 'nt' and isinstance(cmdline, list) and 'pospro' in cmdline):
|
||||||
sys.exit(1)
|
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):
|
def show_already_running_dialog(self):
|
||||||
msg = QMessageBox()
|
msg = QMessageBox()
|
||||||
|
|
Loading…
Reference in New Issue