(argv)
Launches the device monitor.

  Polls the devices for their battery and cpu temperatures and scans the
  blacklist file every 60 seconds and dumps the data to DEVICE_FILE.
Launches the device monitor.
Launches the device monitor .
def main(argv):
  """Launches the device monitor.

  Polls the devices for their battery and cpu temperatures and scans the
  blacklist file every 60 seconds and dumps the data to DEVICE_FILE.
  """

  parser = argparse.ArgumentParser(
      description='Launches the device monitor.')
  parser.add_argument('--adb-path', help='Path to adb binary.')
  parser.add_argument('--blacklist-file', help='Path to device blacklist file.')
  args = parser.parse_args(argv)

  logger = logging.getLogger()
  logger.setLevel(logging.DEBUG)
  handler = logging.handlers.RotatingFileHandler(
      '/tmp/device_monitor.log', maxBytes=10 * 1024 * 1024, backupCount=5)
  fmt = logging.Formatter('%(asctime)s %(levelname)s %(message)s',
                          datefmt='%y%m%d %H:%M:%S')
  handler.setFormatter(fmt)
  logger.addHandler(handler)

  devil_dynamic_config = devil_env.EmptyConfig()
  if args.adb_path:
    devil_dynamic_config['dependencies'].update(
        devil_env.LocalConfigItem(
            'adb', devil_env.GetPlatform(), args.adb_path))

  devil_env.config.Initialize(configs=[devil_dynamic_config])

  blacklist = (device_blacklist.Blacklist(args.blacklist_file)
               if args.blacklist_file else None)

  logging.info('Device monitor running with pid %d, adb: %s, blacklist: %s',
               os.getpid(), args.adb_path, args.blacklist_file)
  while True:
    start = time.time()
    status_dict = get_all_status(blacklist)
    with open(DEVICE_FILE, 'wb') as f:
      json.dump(status_dict, f, indent=2, sort_keys=True)
    logging.info('Got status of all devices in %.2fs.', time.time() - start)
    time.sleep(60)
def main ( argv ) : parser = argparse . ArgumentParser ( description = 'Launches the device monitor.' ) parser . add_argument ( '--adb-path' , help = 'Path to adb binary.' ) parser . add_argument ( '--blacklist-file' , help = 'Path to device blacklist file.' ) args = parser . parse_args ( argv ) logger = logging . getLogger ( ) logger . setLevel ( logging . DEBUG ) handler = logging . handlers . RotatingFileHandler ( '/tmp/device_monitor.log' , maxBytes = 10 * 1024 * 1024 , backupCount = 5 ) fmt = logging . Formatter ( '%(asctime)s %(levelname)s %(message)s' , datefmt = '%y%m%d %H:%M:%S' ) handler . setFormatter ( fmt ) logger . addHandler ( handler ) devil_dynamic_config = devil_env . EmptyConfig ( ) if args . adb_path : devil_dynamic_config [ 'dependencies' ] . update ( devil_env . LocalConfigItem ( 'adb' , devil_env . GetPlatform ( ) , args . adb_path ) ) devil_env . config . Initialize ( configs = [ devil_dynamic_config ] ) blacklist = ( device_blacklist . Blacklist ( args . blacklist_file ) if args . blacklist_file else None ) logging . info ( 'Device monitor running with pid %d, adb: %s, blacklist: %s' , os . getpid ( ) , args . adb_path , args . blacklist_file ) while True : start = time . time ( ) status_dict = get_all_status ( blacklist ) with open ( DEVICE_FILE , 'wb' ) as f : json . dump ( status_dict , f , indent = 2 , sort_keys = True ) logging . info ( 'Got status of all devices in %.2fs.' , time . time ( ) - start ) time . sleep ( 60 )