Beispiel #1
0
def create_parser():
    '''
  Main parser
  :return:
  '''
    parser = hrc_parse.HeronArgumentParser(
        prog='heron',
        epilog=HELP_EPILOG,
        formatter_class=config.SubcommandHelpFormatter,
        add_help=False,
        fromfile_prefix_chars='@')

    subparsers = parser.add_subparsers(title="Available commands",
                                       metavar='<command> <options>')

    activate.create_parser(subparsers)
    deactivate.create_parser(subparsers)
    cli_help.create_parser(subparsers)
    kill.create_parser(subparsers)
    restart.create_parser(subparsers)
    submit.create_parser(subparsers)
    update.create_parser(subparsers)
    version.create_parser(subparsers)

    return parser
Beispiel #2
0
  def test_parser_rolecmdspecific(self):

    parser = hr_argparser.HeronArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False,
        rcfile=self.testrcfile,
        rccommand="activate",
        rcclusterrole="devcluster/ads/PROD")

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    activate.create_parser(subparsers)
    args, _ = parser.parse_known_args(["activate", "devcluster/ads/PROD",
                                       "12313"])
    self.assertEqual(['e=f', 'ooo=ppp', 'hi=wee', 'foo=bar'], args.config_property)
    hr_argparser.HeronArgumentParser.clear()
Beispiel #3
0
  def test_parser_norcfile(self):
    sys.argv = []

    parser = hr_argparser.HeronArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False,
        rcfile='INVALID',
        rccommand="activate",
        rcclusterrole="devcluster/ads/PROD")

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    activate.create_parser(subparsers)
    args, _ = parser.parse_known_args(["activate", "devcluster/ads/PROD",
                                       "12313", "--config-property", "a=b"])

    self.assertEqual(['a=b'], args.config_property)
    hr_argparser.HeronArgumentParser.clear()
Beispiel #4
0
  def test_parser_commandline_positional_withrc(self):
    sys.argv = []

    parser = hr_argparser.HeronArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False,
        rcfile=self.testrcfile,
        rccommand="submit",
        rcclusterrole="local")

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    submit.create_parser(subparsers)
    args, _ = parser.parse_known_args(["submit", "local", "~/.heron/examples/heron-examples.jar",
                                       "com.twitter.heron.examples.ExclamationTopology",
                                       "ExclamationTopology"])
    namespace = vars(args)
    self.assertEqual('True', namespace['verbose'])
    hr_argparser.HeronArgumentParser.clear()
Beispiel #5
0
  def test_parser_commandline_positional_error(self):
    sys.argv = []

    parser = hr_argparser.HeronArgumentParser(
        prog='heron',
        epilog=help_epilog,
        formatter_class=config.SubcommandHelpFormatter,
        fromfile_prefix_chars='@',
        add_help=False,
        rcfile=self.testrcfile,
        rccommand="submit",
        rcclusterrole="ilocal")

    subparsers = parser.add_subparsers(
        title="Available commands",
        metavar='<command> <options>')
    submit.create_parser(subparsers)
    try:
      _, _ = parser.parse_known_args(["submit", "ilocal"])
    except ValueError:
      pass
    else:
      self.fail('ValueError expected for test_parser_commandline_positional_error')
    hr_argparser.HeronArgumentParser.clear()