def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], '6A:p:Sv') except getopt.error: sys.exit(USAGE) if not arguments: sys.exit(USAGE) prefer_ipv6 = 0 address = '127.0.0.1' sslconfig = 0 port = 80 level = logging.INFO for name, value in options: if name == '-6': prefer_ipv6 = 1 elif name == '-A': address = value elif name == '-p': port = int(value) elif name == '-S': sslconfig = 1 elif name == '-v': level = logging.DEBUG logging.getLogger().setLevel(level) handler = HttpClientSmpl(POLLER) handler.connect((address, port), prefer_ipv6, sslconfig, (address, port, collections.deque(arguments), [0])) POLLER.loop()
def main(args): ''' Run the API server ''' try: options, arguments = getopt.getopt(args[1:], 'O:v') except getopt.error: sys.exit('usage: neubot background_api [-v] [-O setting]') if arguments: sys.exit('usage: neubot background_api [-v] [-O setting]') settings = [] for name, value in options: if name == '-O': settings.append(value) elif name == '-v': LOG.verbose() settings = utils_rc.parse_safe(iterable=settings) if not 'address' in settings: settings['address'] = '127.0.0.1 ::1' if not 'port' in settings: settings['port'] = '9774' start(settings['address'], settings['port']) POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], '6A:p:v') except getopt.error: sys.exit('usage: neubot skype_negotiate [-6v] [-A address] [-p port]') if arguments: sys.exit('usage: neubot skype_negotiate [-6v] [-A address] [-p port]') prefer_ipv6 = 0 address = '127.0.0.1' port = 8080 level = logging.INFO for name, value in options: if name == '-6': prefer_ipv6 = 1 elif name == '-A': address = value elif name == '-p': port = int(value) elif name == '-v': level = logging.DEBUG logging.getLogger().setLevel(level) handler = SkypeNegotiate() handler.connect((address, port), prefer_ipv6, 0, {}) POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], '6A:p:Sv') except getopt.error: sys.exit('usage: neubot skype_clnt [-6Sv] [-A address] [-p port]') if arguments: sys.exit('usage: neubot skype_clnt [-6Sv] [-A address] [-p port]') prefer_ipv6 = 0 address = '127.0.0.1' port = 45678 sslconfig = False verbose = 0 for name, value in options: if name == '-6': prefer_ipv6 = 1 elif name == '-A': address = value elif name == '-p': port = int(value) elif name == '-S': sslconfig = True elif name == '-v': verbose += 1 level = logging.INFO if verbose > 0: level = logging.DEBUG logging.getLogger().setLevel(level) handler = SkypeClient() handler.connect((address, port), prefer_ipv6, sslconfig, {}) POLLER.loop()
def main(args): ''' main() function ''' try: options, arguments = getopt.getopt(args[1:], 'vy') except getopt.error: sys.exit('neubot updater_runner [-vy] [version]') if len(arguments) > 1: sys.exit('neubot updater_runner [-vy] [version]') privacy = False for tpl in options: if tpl[0] == '-v': LOG.verbose() elif tpl[0] == '-y': privacy = True # Honor -y and force privacy permissions if privacy: CONFIG.conf.update({'privacy.informed': 1, 'privacy.can_collect': 1, 'privacy.can_publish': 1}) updater = UpdaterRunner('win32', os.path.dirname(ROOTDIR)) if arguments: updater.retrieve_files(arguments[0]) else: # Enable automatic updates if we arrive here CONFIG.conf['win32_updater'] = 1 updater.retrieve_versioninfo() POLLER.loop()
def main(args): """ Main function """ try: options, arguments = getopt.getopt(args[1:], "6A:p:Sv") except getopt.error: sys.exit("usage: neubot raw_clnt [-6Sv] [-A address] [-p port]") if arguments: sys.exit("usage: neubot raw_clnt [-6Sv] [-A address] [-p port]") prefer_ipv6 = 0 address = "127.0.0.1" port = 12345 sslconfig = False verbose = 0 for name, value in options: if name == "-6": prefer_ipv6 = 1 elif name == "-A": address = value elif name == "-p": port = int(value) elif name == "-S": sslconfig = True elif name == "-v": verbose += 1 level = logging.INFO if verbose > 0: level = logging.DEBUG logging.getLogger().setLevel(level) handler = RawClient() handler.connect((address, port), prefer_ipv6, sslconfig, {}) POLLER.loop()
def main(args): ''' Main() function ''' try: options, arguments = getopt.getopt(args[1:], '') except getopt.error: sys.exit('usage: neubot background_win32') if options or arguments: sys.exit('usage: neubot background_win32') # Read settings from database CONFIG.merge_database(DATABASE.connection()) # # Save logs into the database, to easily access # and show them via the web user interface. # LOG.use_database() # Complain if privacy settings are not OK privacy.complain_if_needed() background_api.start('127.0.0.1 ::1', '9774') BACKGROUND_RENDEZVOUS.start() __start_updater() POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], '6A:P:p:Sv') except getopt.error: sys.exit(USAGE) if arguments: sys.exit(USAGE) prefer_ipv6 = 0 address = 'mlab-ns.appspot.com' policy = '' port = 80 sslconfig = 0 level = logging.INFO for name, value in options: if name == '-6': prefer_ipv6 = 1 elif name == '-A': address = value elif name == '-P': policy = value elif name == '-p': port = int(value) elif name == '-S': sslconfig = 1 elif name == '-v': level = logging.DEBUG logging.getLogger().setLevel(level) handler = RunnerMlabns() extra = {'policy': policy} handler.connect((address, port), prefer_ipv6, sslconfig, extra) POLLER.loop()
def main(args): ''' main() function ''' CONFIG['verbose'] = 1 ctx = {'uri': args[1]} RunnerDload(ctx) POLLER.loop()
def main(args): """ main() function """ logger = logging.getLogger() logger.setLevel(logging.DEBUG) LOG.verbose() ctx = {"uri": args[1]} RunnerDload(ctx) POLLER.loop()
def main(args): """ Main function """ try: options, arguments = getopt.getopt(args[1:], "6A:np:vy") except getopt.error: sys.exit("usage: neubot skype [-6nvy] [-A address] [-p port]") if arguments: sys.exit("usage: neubot skype [-6nvy] [-A address] [-p port]") prefer_ipv6 = 0 # address = 'master.neubot.org' address = "localhost" runner = 1 port = 8080 noisy = 0 fakeprivacy = 0 for name, value in options: if name == "-6": prefer_ipv6 = 1 elif name == "-A": address = value elif name == "-n": runner = 0 elif name == "-p": port = int(value) elif name == "-v": noisy = 1 elif name == "-y": fakeprivacy = 1 if os.path.isfile(DATABASE.path): DATABASE.connect() CONFIG.merge_database(DATABASE.connection()) else: logging.warning("skype: database file is missing: %s", DATABASE.path) BACKEND.use_backend("null") if noisy: log.set_verbose() if runner: result = runner_clnt.runner_client( CONFIG["agent.api.address"], CONFIG["agent.api.port"], CONFIG["verbose"], "skype" ) if result: sys.exit(0) logging.info("skype: running the test in the local process context...") if not fakeprivacy and not privacy.allowed_to_run(): privacy.complain() logging.info("skype: otherwise use -y option to temporarily provide " "privacy permissions") sys.exit(1) handler = SkypeNegotiate() handler.connect((address, port), prefer_ipv6, 0, {}) POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], '6A:fp:v') except getopt.error: sys.exit('usage: neubot raw [-6fv] [-A address] [-p port]') if arguments: sys.exit('usage: neubot raw [-6fv] [-A address] [-p port]') prefer_ipv6 = 0 address = 'master.neubot.org' force = 0 port = 8080 noisy = 0 for name, value in options: if name == '-6': prefer_ipv6 = 1 elif name == '-A': address = value elif name == '-f': force = 1 elif name == '-p': port = int(value) elif name == '-v': noisy = 1 if os.path.isfile(DATABASE.path): DATABASE.connect() CONFIG.merge_database(DATABASE.connection()) else: logging.warning('raw: database file is missing: %s', DATABASE.path) BACKEND.use_backend('null') if noisy: log.set_verbose() if not force: result = runner_clnt.runner_client(CONFIG['agent.api.address'], CONFIG['agent.api.port'], CONFIG['verbose'], 'raw') if result: sys.exit(0) logging.warning('raw: failed to contact Neubot; is Neubot running?') sys.exit(1) logging.info('raw: run the test in the local process context...') handler = RawNegotiate() handler.connect((address, port), prefer_ipv6, 0, {}) POLLER.loop()
def main(args): ''' Main() function ''' try: options, arguments = getopt.getopt(args[1:], '') except getopt.error: sys.exit('usage: neubot background_win32') if options or arguments: sys.exit('usage: neubot background_win32') # Read settings from database CONFIG.merge_database(DATABASE.connection()) BACKEND.use_backend("neubot") BACKEND.datadir_init() # # Save logs into the database, to easily access # and show them via the web user interface. # LOG.use_database() logging.info('%s for Windows: starting up', utils_version.PRODUCT) # Complain if privacy settings are not OK privacy.complain_if_needed() background_api.start_api() BACKGROUND_RENDEZVOUS.start() __start_updater() POLLER.loop() logging.info('%s for Windows: shutting down', utils_version.PRODUCT) LOG.writeback() # # Make sure that we do not leave the database # in an inconsistent state. # DATABASE.close()
def main(args): ''' Main() function ''' try: options, arguments = getopt.getopt(args[1:], 'nO:vy') except getopt.error: sys.exit('usage: neubot background_rendezvous [-nvy] [-O setting]') if arguments: sys.exit('usage: neubot background_rendezvous [-nvy] [-O setting]') notest = False fakeprivacy = False settings = [] for name, value in options: if name == '-n': notest = True elif name == '-O': settings.append(value) elif name == '-v': LOG.verbose() elif name == '-y': fakeprivacy = True # Fake privacy settings if fakeprivacy: CONFIG.conf.update({ 'privacy.informed': 1, 'privacy.can_collect': 1, 'privacy.can_publish': 1 }) if notest: CONFIG.conf.update({'enabled': 0}) settings = utils_rc.parse_safe(iterable=settings) if 'interval' in settings: CONFIG.conf['agent.interval'] = settings['interval'] BACKGROUND_RENDEZVOUS.run() POLLER.loop()
def main(args): ''' main() function ''' try: options, arguments = getopt.getopt(args[1:], 'C:O:vy') except getopt.error: sys.exit(USAGE) if len(arguments) > 1: sys.exit(USAGE) sysname = 'win32' channel = CONFIG['win32_updater_channel'] privacy = False for tpl in options: if tpl[0] == '-C': channel = tpl[1] elif tpl[0] == '-O': sysname = tpl[1] elif tpl[0] == '-v': CONFIG['verbose'] = 1 elif tpl[0] == '-y': privacy = True # Honor -y and force privacy permissions if privacy: CONFIG.conf.update({'privacy.informed': 1, 'privacy.can_collect': 1, 'privacy.can_publish': 1}) CONFIG['win32_updater_channel'] = channel updater = UpdaterRunner(sysname, utils_hier.BASEDIR) if arguments: updater.retrieve_files({}, arguments[0]) else: # Enable automatic updates if we arrive here CONFIG.conf['win32_updater'] = 1 updater.retrieve_versioninfo() POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], 'A:p:v') except getopt.error: sys.exit('usage: neubot background_api [-v] [-A address] [-p port]') if arguments: sys.exit('usage: neubot background_api [-v] [-A address] [-p port]') address = None port = None for name, value in options: if name == '-A': address = value elif name == '-p': port = int(value) elif name == '-v': CONFIG['verbose'] = 1 start_api(address, port) POLLER.loop()
def main(args): ''' Main() function ''' try: options, arguments = getopt.getopt(args[1:], 'ni:vy') except getopt.error: sys.exit('usage: neubot background_rendezvous [-nvy] [-i interval]') if arguments: sys.exit('usage: neubot background_rendezvous [-nvy] [-i interval]') notest = False fakeprivacy = False interval = 0 for name, value in options: if name == '-n': notest = True elif name == '-i': interval = int(value) elif name == '-v': CONFIG['verbose'] = 1 elif name == '-y': fakeprivacy = True # Fake privacy settings if fakeprivacy: CONFIG['privacy.informed'] = 1 CONFIG['privacy.can_collect'] = 1 CONFIG['privacy.can_publish'] = 1 if notest: CONFIG['enabled'] = 0 if interval: CONFIG['agent.interval'] = interval BACKGROUND_RENDEZVOUS.run() POLLER.loop()
def main(args): """ Main() function """ try: options, arguments = getopt.getopt(args[1:], "ni:vy") except getopt.error: sys.exit("usage: neubot background_rendezvous [-nvy] [-i interval]") if arguments: sys.exit("usage: neubot background_rendezvous [-nvy] [-i interval]") notest = False fakeprivacy = False interval = 0 for name, value in options: if name == "-n": notest = True elif name == "-i": interval = int(value) elif name == "-v": CONFIG["verbose"] = 1 elif name == "-y": fakeprivacy = True # Fake privacy settings if fakeprivacy: CONFIG["privacy.informed"] = 1 CONFIG["privacy.can_collect"] = 1 CONFIG["privacy.can_publish"] = 1 if notest: CONFIG["enabled"] = 0 if interval: CONFIG["agent.interval"] = interval BACKGROUND_RENDEZVOUS.run() POLLER.loop()
def main(args): ''' Main function ''' try: options, arguments = getopt.getopt(args[1:], '6A:p:Sv') except getopt.error: sys.exit('usage: neubot mod_raw [-6Sv] [-A address] [-p port]') if arguments: sys.exit('usage: neubot mod_raw [-6Sv] [-A address] [-p port]') prefer_ipv6 = 0 address = '127.0.0.1' port = 12345 sslconfig = False sslcert = '' verbose = 0 for name, value in options: if name == '-6': prefer_ipv6 = 1 elif name == '-A': address = value elif name == '-p': port = int(value) elif name == '-S': sslconfig = True sslcert = 'cert.pem' elif name == '-v': verbose += 1 level = logging.INFO if verbose > 0: level = logging.DEBUG logging.getLogger().setLevel(level) handler = RawServer() handler.listen((address, port), prefer_ipv6, sslconfig, sslcert) POLLER.loop()
def main(args): """ Main function """ try: options, arguments = getopt.getopt(args[1:], "6A:b:d:flnp:v") except getopt.error: sys.exit(USAGE) if arguments: sys.exit(USAGE) prefer_ipv6 = 0 address = "127.0.0.1" backend = "volatile" datadir = None # means: pick the default force = 0 listen = 0 negotiate = 1 port = 80 noisy = 0 for name, value in options: if name == "-6": prefer_ipv6 = 1 elif name == "-A": address = value elif name == "-b": backend = value elif name == "-d": datadir = value elif name == "-f": force = 1 elif name == "-l": listen = 1 elif name == "-n": negotiate = 0 elif name == "-p": port = int(value) elif name == "-v": noisy = 1 if noisy: log.set_verbose() conf = CONFIG.copy() BACKEND.use_backend(backend) BACKEND.datadir_init(None, datadir) if listen: if not negotiate: server = DASHServerSmpl(POLLER) server.configure(conf) server.listen((address, port)) else: # Code adapted from neubot/server.py conf["http.server.rootdir"] = "" server = ServerHTTP(POLLER) server.configure(conf) server.listen((address, port)) negotiate_server = NegotiateServer(POLLER) negotiate_server.configure(conf) server.register_child(negotiate_server, "/negotiate") server.register_child(negotiate_server, "/collect") dash_negotiate_server = DASHNegotiateServer() negotiate_server.register_module("dash", dash_negotiate_server) dash_server = DASHServerGlue(POLLER, dash_negotiate_server) dash_server.configure(conf) server.register_child(dash_server, "/dash") elif not force: result = runner_clnt.runner_client(CONFIG["agent.api.address"], CONFIG["agent.api.port"], CONFIG["verbose"], "dash") if result: sys.exit(0) logging.warning("dash: failed to contact Neubot; is Neubot running?") sys.exit(1) else: if negotiate: client = DASHNegotiateClient(POLLER) else: client = DASHClientSmpl(POLLER, None, DASH_RATES) client.configure(conf) client.connect((address, port)) POLLER.loop()