def StartAgentTracing(self, options, _, timeout=None):
        """Starts tracing.

    Args:
        options: Tracing options.

    Raises:
        RuntimeError: If trace already in progress.
    """
        if options.update_map or not path.isfile(options.serial_map):
            battor_device_mapping.GenerateSerialMapFile(
                options.serial_map, options.hub_types)
        self._battor_wrapper = battor_wrapper.BattorWrapper(
            target_platform=options.target,
            android_device=options.device_serial_number,
            battor_path=options.battor_path,
            battor_map_file=options.serial_map)

        dev_utils = device_utils.DeviceUtils(options.device_serial_number)
        self._battery_utils = battery_utils.BatteryUtils(dev_utils)
        self._battery_utils.SetCharging(False)
        atexit.register(_reenable_charging_if_needed, self._battery_utils)
        self._battor_wrapper.StartShell()
        self._battor_wrapper.StartTracing()
        return True
Example #2
0
def main():
    options = parse_options()
    battor_device_mapping.GenerateSerialMapFile(options.out_file,
                                                options.hub_types)
  usage = 'Usage: ./update_mapping.py [options]'
  desc = ('Example: ./update_mapping.py -o mapping.json.\n'
  'This script generates and stores a file that gives the\n'
  'mapping between phone serial numbers and BattOr serial numbers\n'
  'Mapping is based on which physical ports on the USB hubs the\n'
  'devices are plugged in to. For instance, if there are two hubs,\n'
  'the phone connected to port N on the first hub is mapped to the\n'
  'BattOr connected to port N on the second hub, for each N.')
  parser = argparse.ArgumentParser(usage=usage, description=desc)
  parser.add_argument('-o', '--output', dest='out_file',
                      default='mapping.json', type=str,
                      action='store', help='mapping file name')
  parser.add_argument('-u', '--hub', dest='hub_types',
                      action='append', choices=['plugable_7port',
                                                'plugable_7port_usb3_part2',
                                                'plugable_7port_usb3_part3'],
                      help='USB hub types.')
  options = parser.parse_args()
  if not options.hub_types:
    options.hub_types = ['plugable_7port', 'plugable_7port_usb3_part2',
                         'plugable_7port_usb3_part3']
  return options

def presentation.main():
  options = parse_options()
  battor_device_mapping.GenerateSerialMapFile(options.out_file,
                                              options.hub_types)

if __name__ == "__main__":
  sys.exit(presentation.main())