def main(_): """Run the main test harness.""" # For testing we use the test config file. flags.FLAGS.config = config_lib.CONFIG["Test.config"] # We are running a test so let the config system know that. config_lib.CONFIG.AddContext("Test Context", "Context applied when we run tests.") # This is a standalone program and might need to use the config # file. startup.TestInit() # Start up a server in another thread trd = DjangoThread() trd.start() try: user_ns = dict() user_ns.update(globals()) user_ns.update(locals()) # Wait in the shell so selenium IDE can be used. ipshell.IPShell(argv=[], user_ns=user_ns) finally: # Kill the server thread trd.Stop()
def main(_): """Run the main test harness.""" startup.TestInit() # Start up a server in another thread trd = DjangoThread(config_lib.CONFIG["AdminUI.port"]) trd.StartAndWaitUntilServing() user_ns = dict() user_ns.update(globals()) user_ns.update(locals()) # Wait in the shell so selenium IDE can be used. ipshell.IPShell(argv=[], user_ns=user_ns)
def main(unused_argv): """Main.""" banner = ("\nWelcome to the GRR console\n" "Type help<enter> to get help\n\n") config_lib.CONFIG.AddContext("Commandline Context") config_lib.CONFIG.AddContext( "Console Context", "Context applied when running the console binary.") startup.Init() # To make the console easier to use, we make a default token which will be # used in StartFlow operations. data_store.default_token = rdfvalue.ACLToken(username=getpass.getuser(), reason=flags.FLAGS.reason) locals_vars = { "hilfe": Help, "help": Help, "__name__": "GRR Console", "l": Lister, "o": aff4.FACTORY.Open, # Bring some symbols from other modules into the console's # namespace. "StartFlowAndWait": flow_utils.StartFlowAndWait, "StartFlowAndWorker": debugging.StartFlowAndWorker, "RunEndToEndTests": end_to_end_tests.RunEndToEndTests, } locals_vars.update(globals()) # add global variables to console if flags.FLAGS.client is not None: locals_vars["client"], locals_vars["token"] = console_utils.OpenClient( client_id=flags.FLAGS.client) if flags.FLAGS.code_to_execute: logging.info("Running code from flag: %s", flags.FLAGS.code_to_execute) exec(flags.FLAGS.code_to_execute) # pylint: disable=exec-used elif flags.FLAGS.command_file: logging.info("Running code from file: %s", flags.FLAGS.command_file) execfile(flags.FLAGS.command_file) if (flags.FLAGS.exit_on_complete and (flags.FLAGS.code_to_execute or flags.FLAGS.command_file)): return else: # We want the normal shell. locals_vars.update(globals()) # add global variables to console ipshell.IPShell(argv=[], user_ns=locals_vars, banner=banner)