def subcommand_start(args): ''' Start subcommand ''' try: options, arguments = getopt.getopt(args[1:], 'k') except getopt.error: sys.exit('usage: neubot start [-k]') if arguments: sys.exit('usage: neubot start [-k]') kill = False for tpl in options: if tpl[0] == '-k': kill = True # # Wait for the parent to die, so that it closes the listening # socket and we can successfully bind() it. # count = 0 while kill: running = utils_ctl.is_running('127.0.0.1', '9774', quick=1) if not running: break utils_ctl.stop('127.0.0.1', '9774') count += 1 if count > 512: sys.exit('FATAL: cannot stop neubot daemon') # Lazy import from neubot import background_win32 background_win32.main(['neubot'])
def subcommand_status(args): ''' Status subcommand ''' try: options, arguments = getopt.getopt(args[1:], '') except getopt.error: sys.exit('usage: neubot status') if options or arguments: sys.exit('usage: neubot status') running = utils_ctl.is_running('127.0.0.1', '9774') if not running: sys.exit('ERROR: neubot is not running')
def subcommand_status(args): ''' Status subcommand ''' try: options, arguments = getopt.getopt(args[1:], 'v') except getopt.error: sys.exit('usage: neubot status [-v]') if arguments: sys.exit('usage: neubot status [-v]') for opt in options: if opt[0] == '-v': log.set_verbose() running = utils_ctl.is_running('127.0.0.1', '9774', log.is_verbose()) if not running: sys.exit('ERROR: neubot is not running')
def main(args): ''' Entry point for simple gtk+webkit GUI ''' try: options, arguments = getopt.getopt(args[1:], 'f:O:') except getopt.error: sys.exit('Usage: neubot viewer [-f file] [-O option]') if arguments: sys.exit('Usage: neubot viewer [-f file] [-O option]') conf = { 'address': '127.0.0.1', 'port': '9774', } settings = [] fpath = '/etc/neubot/api' for name, value in options: if name == '-f': fpath = value elif name == '-O': settings.append(value) cnf = utils_rc.parse_safe(fpath) conf.update(cnf) cnf = utils_rc.parse_safe(iterable=settings) conf.update(cnf) address, port = conf['address'], conf['port'] uri = STATIC_PAGE if utils_ctl.is_running(address, port): uri = 'http://%s:%s/' % (address, port) if not 'DISPLAY' in os.environ: sys.exit('No DISPLAY available') else: WebkitGUI(uri) gtk.main()
def subcommand_status(args): ''' Status subcommand ''' try: options, arguments = getopt.getopt(args[1:], 'v') except getopt.error: sys.exit('usage: neubot status [-v]') if arguments: sys.exit('usage: neubot status [-v]') verbose = 0 for opt in options: if opt[0] == '-v': verbose = 1 running = utils_ctl.is_running('127.0.0.1', '9774') if verbose: if not running: sys.stdout.write('Neubot is not running\n') else: sys.stdout.write('Neubot is running\n') if not running: sys.exit(1)
def subcommand_start(args): ''' Start subcommand ''' try: options, arguments = getopt.getopt(args[1:], 'k') except getopt.error: sys.exit('usage: neubot start [-k]') if arguments: sys.exit('usage: neubot start [-k]') kill = False for tpl in options: if tpl[0] == '-k': kill = True if kill: running = utils_ctl.is_running('127.0.0.1', '9774') if running: utils_ctl.stop('127.0.0.1', '9774') # Lazy import from neubot import background_win32 background_win32.main(['neubot'])
def main(args): ''' Entry point for simple gtk+webkit GUI ''' try: _, arguments = getopt.getopt(args[1:], '') except getopt.error: sys.exit('Usage: neubot viewer') if arguments: sys.exit('Usage: neubot viewer') conf = utils_rc.parse_safe(utils_hier.APIFILEPATH) address = conf.get('address', '127.0.0.1') port = conf.get('port', 9774) uri = STATIC_PAGE if utils_ctl.is_running(address, port): uri = 'http://%s/' % utils_net.format_epnt((address, port)) if not 'DISPLAY' in os.environ: sys.exit('FATAL: No DISPLAY available') else: WebkitGUI(uri) gtk.main()