mirror of
https://github.com/onionshare/onionshare.git
synced 2025-08-24 05:49:27 -04:00
Support handling events by monitoring an events folder for changes
This commit is contained in:
parent
d78d67adf6
commit
e7c683528d
7 changed files with 152 additions and 23 deletions
|
@ -23,9 +23,11 @@ import sys
|
|||
import platform
|
||||
import argparse
|
||||
import signal
|
||||
import psutil
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
if platform.system() == "Linux":
|
||||
import psutil
|
||||
|
||||
from onionshare.common import Common
|
||||
|
||||
from .gui_common import GuiCommon
|
||||
|
@ -122,28 +124,30 @@ def main():
|
|||
sys.exit()
|
||||
|
||||
# Is there another onionshare-gui running?
|
||||
existing_pid = None
|
||||
for proc in psutil.process_iter(attrs=["pid", "name", "cmdline"]):
|
||||
if proc.info["pid"] == os.getpid():
|
||||
continue
|
||||
if common.platform == "Linux":
|
||||
existing_pid = None
|
||||
for proc in psutil.process_iter(attrs=["pid", "name", "cmdline"]):
|
||||
if proc.info["pid"] == os.getpid():
|
||||
continue
|
||||
|
||||
if proc.info["name"] == "onionshare-gui":
|
||||
existing_pid = proc.info["pid"]
|
||||
break
|
||||
else:
|
||||
# Dev mode onionshare?
|
||||
if proc.info["cmdline"] and len(proc.info["cmdline"]) >= 2:
|
||||
if (
|
||||
os.path.basename(proc.info["cmdline"][0]).lower() == "python"
|
||||
and os.path.basename(proc.info["cmdline"][1]) == "onionshare-gui"
|
||||
):
|
||||
existing_pid = proc.info["pid"]
|
||||
break
|
||||
if proc.info["name"] == "onionshare-gui":
|
||||
existing_pid = proc.info["pid"]
|
||||
break
|
||||
else:
|
||||
# Dev mode onionshare?
|
||||
if proc.info["cmdline"] and len(proc.info["cmdline"]) >= 2:
|
||||
if (
|
||||
os.path.basename(proc.info["cmdline"][0]).lower() == "python"
|
||||
and os.path.basename(proc.info["cmdline"][1])
|
||||
== "onionshare-gui"
|
||||
):
|
||||
existing_pid = proc.info["pid"]
|
||||
break
|
||||
|
||||
if existing_pid:
|
||||
print(f"Opening tab in existing OnionShare window (pid {proc.info['pid']})")
|
||||
# TODO: open tab
|
||||
return
|
||||
if existing_pid:
|
||||
print(f"Opening tab in existing OnionShare window (pid {proc.info['pid']})")
|
||||
# TODO: open tab
|
||||
return
|
||||
|
||||
# Attach the GUI common parts to the common object
|
||||
common.gui = GuiCommon(common, qtapp, local_only)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue