MCPcopy Index your code
hub / github.com/StackStorm/st2 / run

Method run

st2client/st2client/shell.py:428–496  ·  view source on GitHub ↗
(self, argv)

Source from the content-addressed store, hash-verified

426 )
427
428 def run(self, argv):
429 debug = False
430
431 parser = self.parser
432
433 if len(argv) == 0:
434 # Print a more user-friendly help string if no arguments are provided
435 # Note: We only set usage variable for the main parser. If we passed "usage" argument
436 # to the main ArgumentParser class above, this would also set a custom usage string for
437 # sub-parsers which we don't want.
438 parser.usage = USAGE_STRING
439 sys.stderr.write(parser.format_help())
440 return 2
441
442 # Provide autocomplete for shell
443 argcomplete.autocomplete(self.parser)
444
445 if "--print-config" in argv:
446 # Hack because --print-config requires no command to be specified
447 argv = argv + ["action", "list"]
448
449 # Parse command line arguments.
450 args = self.parser.parse_args(args=argv)
451
452 print_config = args.print_config
453 if print_config:
454 self._print_config(args=args)
455 return 3
456
457 # Parse config and store it in the config module
458 config = self._parse_config_file(args=args, validate_config_permissions=False)
459 set_config(config=config)
460
461 self._check_locale_and_print_warning()
462
463 # Setup client and run the command
464 try:
465 debug = getattr(args, "debug", False)
466 if debug:
467 set_log_level_for_all_loggers(level=logging.DEBUG)
468
469 # Set up client.
470 self.client = self.get_client(args=args, debug=debug)
471
472 # TODO: This is not so nice work-around for Python 3 because of a breaking change in
473 # Python 3 - https://bugs.python.org/issue16308
474 try:
475 func = getattr(args, "func")
476 except AttributeError:
477 parser.print_help()
478 sys.exit(2)
479
480 # Execute command.
481 func(args)
482
483 return 0
484 except OperationFailureException:
485 if debug:

Calls 8

_print_configMethod · 0.95
set_configFunction · 0.90
writeMethod · 0.80
_parse_config_fileMethod · 0.80
get_clientMethod · 0.80
_print_debug_infoMethod · 0.80