summaryrefslogtreecommitdiff
path: root/portato.py
diff options
context:
space:
mode:
authornecoro <>2007-08-12 04:21:38 +0000
committernecoro <>2007-08-12 04:21:38 +0000
commitade10e0b8e5571e45cdd4800927c24597e2f7315 (patch)
treeff2d39f0366a7238366abd3c77b739996ed8937a /portato.py
parenta6a5cace4864c37b7a820c89540f85069d842521 (diff)
downloadportato-ade10e0b8e5571e45cdd4800927c24597e2f7315.tar.gz
portato-ade10e0b8e5571e45cdd4800927c24597e2f7315.tar.bz2
portato-ade10e0b8e5571e45cdd4800927c24597e2f7315.zip
added listener/notify
Diffstat (limited to '')
-rwxr-xr-xportato.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/portato.py b/portato.py
index e318411..f90fd69 100755
--- a/portato.py
+++ b/portato.py
@@ -12,9 +12,11 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from portato.constants import VERSION, FRONTENDS, STD_FRONTEND, XSD_LOCATION, LOCALE_DIR, APP
+from portato import listener
+from portato.constants import VERSION, FRONTENDS, STD_FRONTEND, XSD_LOCATION, LOCALE_DIR, APP, SU_COMMAND
from optparse import OptionParser
-import sys, os
+from subprocess import call
+import sys, os, socket
import gettext, locale
def get_frontend_list ():
@@ -46,6 +48,9 @@ def main ():
parser.add_option("-x", "--validate", action = "store", dest = "validate", metavar="PLUGIN",
help = _("validates the given plugin xml instead of launching Portato"))
+ parser.add_option("-L", "--no-listener", action = "store_true", dest = "nolistener", default = False,
+ help = _("do not start listener"))
+
# run parser
(options, args) = parser.parse_args()
@@ -83,8 +88,32 @@ def main ():
else:
print _("Validation succeeded.")
return
- else:
+ elif options.nolistener:
+ try:
+ # move this process into a new process group
+ # this is to be able to kill emerge et al w/o killing ourselves :)
+ os.setsid()
+ except OSError:
+ pass
+ listener.set_send()
run()
+ else: # start listener and start us again in root modus
+ if os.fork() == 0:
+ listener.set_recv()
+ else:
+ additional = []
+ if options.check:
+ additional.append("-c")
+ if options.frontend:
+ additional.extend(["-f", options.frontend])
+
+ try:
+ if os.getuid() == 0:
+ call([SU_COMMAND, "%s --no-listener %s" % (sys.argv[0], " ".join(additional))], env = os.environ)
+ else:
+ call([sys.argv[0], "--no-listener"]+additional, env = os.environ)
+ except KeyboardInterrupt:
+ pass
if __name__ == "__main__":
main()