def main(args): global _retval parser = OptionParser(domain="flumotion-admin") parser.add_option('-m', '--manager', action="store", type="string", dest="manager", help="the manager to connect to, e.g. localhost:7531") parser.add_option('', '--no-ssl', action="store_false", dest="ssl", default=True, help="disable encryption when connecting to the manager") options, args = parser.parse_args(args) i18n.installGettext() if len(args) > 1: log.error('flumotion-admin', 'too many arguments: %r' % (args[1:], )) return 1 from flumotion.ui.icons import register_icons register_icons() from flumotion.admin.gtk.dialogs import exceptionHandler sys.excepthook = exceptionHandler from flumotion.admin.gtk.adminwindow import AdminWindow win = AdminWindow() if options.verbose or (options.debug and options.debug > 3): win.setDebugEnabled(True) if options.manager: d = _connectToManager(win, options.manager, options.ssl) else: d = showGreeter(win) # Printout unhandled exception to stderr d.addErrback(twistedlog.err) # Fixes a bug on widnows version of twisted that makes # the application to crash because _simtag is not defined. if not hasattr(reactor, '_simtag'): reactor._simtag = None reactor.run() return _retval
def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null', directory='/'): ''' This forks the current process into a daemon. The stdin, stdout, and stderr arguments are file names that will be opened and be used to replace the standard file descriptors in sys.stdin, sys.stdout, and sys.stderr. These arguments are optional and default to /dev/null. The fork will switch to the given directory. Used by external projects (ft). ''' # Redirect standard file descriptors. si = open(stdin, 'r') os.dup2(si.fileno(), sys.stdin.fileno()) try: log.outputToFiles(stdout, stderr) except IOError, e: if e.errno == errno.EACCES: log.error('common', 'Permission denied writing to log file %s.', e.filename)