Ejemplo n.º 1
0
def main():
  """The main command dispatcher."""

  start_time = time.time()

  from importlib import import_module
  command_modules = [
      import_module(name + '_commands') for name in [
          'apidocs',
          'bom',
          'changelog',
          'container',
          'debian',
          'halyard',
          'image',
          'rpm',
          'source',
          'spinnaker',
          'inspection',
          'spin',
      ]]

  GitRunner.stash_and_clear_auth_env_vars()
  options, command_registry = init_options_and_registry(
      sys.argv[1:], command_modules)

  logging.basicConfig(
      format='%(levelname).1s %(asctime)s.%(msecs)03d'
             ' [%(threadName)s.%(process)d] %(message)s',
      datefmt='%H:%M:%S',
      level=STANDARD_LOG_LEVELS[options.log_level])

  logging.debug(
      'Running with options:\n   %s',
      '\n   '.join(yaml.safe_dump(vars(options), default_flow_style=False)
                   .split('\n')))

  factory = command_registry.get(options.command)
  if not factory:
    logging.error('Unknown command "%s"', options.command)
    return -1

  MetricsManager.startup_metrics(options)
  labels = {'command': options.command}
  success = False
  try:
    command = factory.make_command(options)
    command()
    success = True
  finally:
    labels['success'] = success
    MetricsManager.singleton().observe_timer(
        'BuildTool_Outcome', labels,
        time.time() - start_time)
    MetricsManager.shutdown_metrics()

  return 0
Ejemplo n.º 2
0
def main():
  """The main command dispatcher."""

  start_time = time.time()

  from importlib import import_module
  command_modules = [
      import_module(name + '_commands') for name in [
          'apidocs',
          'bom',
          'changelog',
          'container',
          'debian',
          'halyard',
          'image',
          'rpm',
          'source',
          'spinnaker',
          'inspection',
          'spin',
      ]]

  GitRunner.stash_and_clear_auth_env_vars()
  options, command_registry = init_options_and_registry(
      sys.argv[1:], command_modules)

  logging.basicConfig(
      format='%(levelname).1s %(asctime)s.%(msecs)03d'
             ' [%(threadName)s.%(process)d] %(message)s',
      datefmt='%H:%M:%S',
      level=STANDARD_LOG_LEVELS[options.log_level])

  logging.debug(
      'Running with options:\n   %s',
      '\n   '.join(yaml.safe_dump(vars(options), default_flow_style=False)
                   .split('\n')))

  factory = command_registry.get(options.command)
  if not factory:
    logging.error('Unknown command "%s"', options.command)
    return -1

  MetricsManager.startup_metrics(options)
  labels = {'command': options.command}
  success = False
  try:
    command = factory.make_command(options)
    command()
    success = True
  finally:
    labels['success'] = success
    MetricsManager.singleton().observe_timer(
        'BuildTool_Outcome', labels,
        time.time() - start_time)
    MetricsManager.shutdown_metrics()

  return 0
Ejemplo n.º 3
0
def main():
    """The main command dispatcher."""

    start_time = time.time()

    from importlib import import_module

    command_modules = [
        import_module(name + "_commands") for name in [
            "apidocs",
            "bom",
            "changelog",
            "halyard",
            "image",
            "source",
            "spinnaker",
            "inspection",
        ]
    ]

    GitRunner.stash_and_clear_auth_env_vars()
    options, command_registry = init_options_and_registry(
        sys.argv[1:], command_modules)

    logging.basicConfig(
        format="%(levelname).1s %(asctime)s.%(msecs)03d"
        " [%(threadName)s.%(process)d] %(message)s",
        datefmt="%H:%M:%S",
        level=STANDARD_LOG_LEVELS[options.log_level],
    )

    logging.debug(
        "Running with options:\n   %s",
        "\n   ".join(
            yaml.safe_dump(vars(options),
                           default_flow_style=False).split("\n")),
    )

    factory = command_registry.get(options.command)
    if not factory:
        logging.error('Unknown command "%s"', options.command)
        return -1

    MetricsManager.startup_metrics(options)
    labels = {"command": options.command}
    success = False
    try:
        command = factory.make_command(options)
        command()
        success = True
    finally:
        labels["success"] = success
        MetricsManager.singleton().observe_timer("BuildTool_Outcome", labels,
                                                 time.time() - start_time)
        MetricsManager.shutdown_metrics()

    return 0
Ejemplo n.º 4
0
def main():
  """The main command dispatcher."""

  GitRunner.stash_and_clear_auth_env_vars()

  import buildtool.source_commands
  import buildtool.build_commands
  import buildtool.bom_commands
  import buildtool.changelog_commands
  import buildtool.apidocs_commands
  import buildtool.image_commands
  command_modules = [
      buildtool.source_commands,
      buildtool.build_commands,
      buildtool.bom_commands,
      buildtool.changelog_commands,
      buildtool.apidocs_commands,
      buildtool.image_commands
  ]

  options, command_registry = init_options_and_registry(
      sys.argv[1:], command_modules)

  logging.basicConfig(
      format='%(levelname).1s %(asctime)s.%(msecs)03d'
             ' [%(threadName)s.%(process)d] %(message)s',
      datefmt='%H:%M:%S',
      level=STANDARD_LOG_LEVELS[options.log_level])

  logging.debug(
      'Running with options:\n   %s',
      '\n   '.join(yaml.dump(vars(options), default_flow_style=False)
                   .split('\n')))

  factory = command_registry.get(options.command)
  if not factory:
    logging.error('Unknown command "%s"', options.command)
    return -1

  MetricsManager.startup_metrics(options)
  try:
    command = factory.make_command(options)
    command()
  finally:
    MetricsManager.shutdown_metrics()

  return 0
Ejemplo n.º 5
0
def wrapped_main():
    options = get_options(sys.argv[1:])

    logging.basicConfig(format='%(levelname).1s %(asctime)s.%(msecs)03d'
                        ' [%(threadName)s.%(process)d] %(message)s',
                        datefmt='%H:%M:%S',
                        level=STANDARD_LOG_LEVELS[options.log_level])

    logging.debug(
        'Running with options:\n   %s', '\n   '.join(
            yaml.dump(vars(options), default_flow_style=False).split('\n')))

    metrics = MetricsManager.startup_metrics(options)
    try:
        return main(options, metrics)
    finally:
        MetricsManager.shutdown_metrics()