Exemple #1
0
def CMDstart_slave(args):
    """Ill named command that actually sets up the bot then start it."""
    # TODO(maruel): Rename function.
    logging_utils.prepare_logging('bot_config.log')
    logging_utils.set_console_level(logging.DEBUG)

    parser = optparse.OptionParser()
    parser.add_option(
        '--survive',
        action='store_true',
        help='Do not reboot the host even if bot_config.setup_bot() asked to')
    options, args = parser.parse_args(args)

    # User provided bot_config.py
    logging.info('importing bot_config: %s, %s', THIS_FILE,
                 zip_package.generate_version())
    try:
        import bot_main
        bot_main.setup_bot(options.survive)
    except Exception:
        logging.exception('bot_config.py is invalid.')

    logging.info('Starting the bot: %s', THIS_FILE)
    cmd = [sys.executable, THIS_FILE, 'start_bot']
    if sys.platform in ('cygwin', 'win32'):
        try:
            subprocess.Popen(cmd)
            return 0
        except Exception as e:
            logging.exception('failed to start: %s', e)
            return 1
    else:
        os.execv(cmd[0], cmd)
Exemple #2
0
def CMDstart_slave(args):
  """Ill named command that actually sets up the bot then start it."""
  # TODO(maruel): Rename function.
  logging_utils.prepare_logging('bot_config.log')
  logging_utils.set_console_level(logging.DEBUG)

  parser = optparse.OptionParser()
  parser.add_option(
      '--survive', action='store_true',
      help='Do not reboot the host even if bot_config.setup_bot() asked to')
  options, args = parser.parse_args(args)

  # User provided bot_config.py
  logging.info(
      'importing bot_config: %s, %s', THIS_FILE, zip_package.generate_version())
  try:
    import bot_main
    bot_main.setup_bot(options.survive)
  except Exception:
    logging.exception('bot_config.py is invalid.')

  logging.info('Starting the bot: %s', THIS_FILE)
  cmd = [sys.executable, THIS_FILE, 'start_bot']
  if sys.platform in ('cygwin', 'win32'):
    try:
      subprocess.Popen(cmd)
      return 0
    except Exception as e:
      logging.exception('failed to start: %s', e)
      return 1
  else:
    os.execv(cmd[0], cmd)
Exemple #3
0
def CMDstart_bot(args):
  """Starts the swarming bot."""
  logging_utils.prepare_logging(os.path.join('logs', 'swarming_bot.log'))
  logging.info(
      'importing bot_main: %s, %s', THIS_FILE, zip_package.generate_version())
  from bot_code import bot_main
  result = bot_main.main(args)
  logging.info('bot_main exit code: %d', result)
  return result
Exemple #4
0
def CMDstart_bot(args):
    """Starts the swarming bot."""
    logging_utils.prepare_logging('swarming_bot.log')
    logging_utils.set_console_level(logging.DEBUG)
    logging.info('importing bot_main: %s, %s', THIS_FILE,
                 zip_package.generate_version())
    import bot_main
    result = bot_main.main(args)
    logging.info('bot_main exit code: %d', result)
    return result
Exemple #5
0
def CMDstart_bot(args):
  """Starts the swarming bot."""
  logging_utils.prepare_logging('swarming_bot.log')
  logging_utils.set_console_level(logging.DEBUG)
  logging.info(
      'importing bot_main: %s, %s', THIS_FILE, zip_package.generate_version())
  import bot_main
  result = bot_main.main(args)
  logging.info('bot_main exit code: %d', result)
  return result
Exemple #6
0
def CMDstart_bot(args):
    """Starts the swarming bot."""
    logging_utils.prepare_logging(os.path.join('logs', 'swarming_bot.log'))
    logging.info('importing bot_main: %s, %s', THIS_FILE,
                 zip_package.generate_version())
    from bot_code import bot_main
    adb_logger = logging.getLogger('adb')
    logging_utils.prepare_logging(os.path.join('logs', 'adb.log'), adb_logger)
    adb_logger.setLevel(logging.DEBUG)
    for child in ('high', 'low', 'usb', 'cmd'):
        adb_logger.getChild(child).setLevel(logging.DEBUG)
    adb_logger.propagate = False
    result = bot_main.main(args)
    logging.info('bot_main exit code: %d', result)
    return result
Exemple #7
0
def CMDversion(_args):
    """Prints the version of this file and the hash of the code."""
    logging_utils.prepare_logging(None)
    print zip_package.generate_version()
    return 0
Exemple #8
0
def generate_version():
  """Returns the bot's code version."""
  try:
    return zip_package.generate_version()
  except Exception as e:
    return 'Error: %s' % e
Exemple #9
0
def generate_version():
    """Returns the bot's code version."""
    try:
        return zip_package.generate_version()
    except Exception as e:
        return 'Error: %s' % e
Exemple #10
0
def CMDversion(_args):
  """Prints the version of this file and the hash of the code."""
  logging_utils.prepare_logging(None)
  print zip_package.generate_version()
  return 0