diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-03-24 20:05:54 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-03-24 20:05:54 +0100 |
commit | e3c683f84345051612f670d2faade7ef638b406a (patch) | |
tree | 841e8115fbdc97b601044a4bfaed87bfc270ab0b /portato.py | |
parent | 9803bc511d8737703985fb00dddcafa7a687c574 (diff) | |
download | portato-e3c683f84345051612f670d2faade7ef638b406a.tar.gz portato-e3c683f84345051612f670d2faade7ef638b406a.tar.bz2 portato-e3c683f84345051612f670d2faade7ef638b406a.zip |
Added build_manpage support. Moved all the startup logic from portato.py to portato/__init__.py
Diffstat (limited to '')
-rwxr-xr-x | portato.py | 90 |
1 files changed, 2 insertions, 88 deletions
@@ -14,93 +14,7 @@ from __future__ import with_statement, absolute_import -import sys, os -import subprocess, threading -import atexit -from optparse import OptionParser, SUPPRESS_HELP - -from portato import get_listener, log, start -from portato.su import detect_su_command -from portato.helper import debug, info, error -from portato.constants import VERSION - -def main (): - start() # the first thing to do :) - - # build the parser - desc = "Portato - A Portage GUI." - usage = "%prog [options] [frontend]" - vers = "%%prog v. %s" % VERSION - - parser = OptionParser(version = vers, prog = "Portato", description = desc, usage = usage) - - parser.add_option("--shm", action = "store", nargs = 3, type="long", dest = "shm", - help = SUPPRESS_HELP) - - parser.add_option("-F", "--no-fork", "-L", action = "store_true", dest = "nofork", default = False, - help = _("do not fork off as root") + (" (%s)" % _("-L is deprecated"))) - - # run parser - (options, args) = parser.parse_args() - - # close listener at exit - atexit.register(get_listener().close) - - if options.nofork or os.getuid() == 0: # start GUI - log.start(file = True) # start logging to file - - from portato.gui import run - info("%s v. %s", _("Starting Portato"), VERSION) - - if options.shm: - get_listener().set_send(*options.shm) - else: - get_listener().set_send() - - try: - run() - except KeyboardInterrupt: - debug("Got KeyboardInterrupt.") - - else: # start us again in root modus and launch listener - - import shm_wrapper as shm - - mem = shm.create_memory(1024, permissions=0600) - sig = shm.create_semaphore(InitialValue = 0, permissions = 0600) - rw = shm.create_semaphore(InitialValue = 1, permissions = 0600) - - # start listener - lt = threading.Thread(target=get_listener().set_recv, args = (mem, sig, rw)) - lt.setDaemon(False) - lt.start() - - try: - # set DBUS_SESSION_BUS_ADDRESS to "" to make dbus work as root ;) - env = os.environ.copy() - env.update(DBUS_SESSION_BUS_ADDRESS="") - - su = detect_su_command() - if su: - debug("Using '%s' as su command.", su.bin) - cmd = su.cmd("%s --no-fork --shm %ld %ld %ld" % (sys.argv[0], mem.key, sig.key, rw.key)) - - sp = subprocess.Popen(cmd, env = env) - - # wait for process to finish - try: - sp.wait() - debug("Subprocess finished") - except KeyboardInterrupt: - debug("Got KeyboardInterrupt.") - - else: - error(_("No valid su command detected. Aborting.")) - - finally: - if lt.isAlive(): - debug("Listener is still running. Close it.") - get_listener().close() +from portato import start if __name__ == "__main__": - main() + start() |