def run(self): """ Entry point. """ # get the device's serial number devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') else: self.serial = AdbHelper.get_serial(self.serial) if self.serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') else: logger.debug( 'No serial, but there are more than one device') raise Exception( 'Please specify the device by --serial option.') else: logger.debug('Setup serial to [{0}]'.format(self.serial)) if self.gaia or self.gecko: self.prepare_step() if self.serial: logger.info('Target device [{0}]'.format(self.serial)) if self.gecko: self.shallow_flash_gecko() if self.gaia: self.shallow_flash_gaia() self.final_step()
def run(self): """ Entry point. """ # get the device's serial number devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') else: self.serial = AdbHelper.get_serial(self.serial) if self.serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') else: logger.debug('No serial, but there are more than one device') raise Exception('Please specify the device by --serial option.') else: logger.debug('Setup serial to [{0}]'.format(self.serial)) if self.gaia or self.gecko: self.prepare_step() if self.serial: logger.info('Target device [{0}]'.format(self.serial)) if self.gecko: self.shallow_flash_gecko() if self.gaia: self.shallow_flash_gaia() self.final_step()
def run(self): ''' Entry point. ''' self.prepare() devices = AdbWrapper.adb_devices() is_enable = not self.args.disable if len(devices) == 0: raise Exception('No device.') elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.args.serial) if final_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') self.set_certapps(enable=is_enable, serial=final_serial) else: logger.debug( 'No serial, but there are more than one device') raise Exception( 'Please specify the device by --serial option.') else: print('Serial: {0} (State: {1})'.format( final_serial, devices[final_serial])) self.set_certapps(enable=is_enable, serial=final_serial)
def run(self): """ Entry point. """ self.devices = AdbWrapper.adb_devices() is_no_color = self.no_color if 'NO_COLOR' in os.environ: try: is_no_color = bool(util.strtobool(os.environ['NO_COLOR'].lower())) except Exception as e: logger.debug(e) logger.error('Invalid NO_COLOR value [{0}].'.format(os.environ['NO_COLOR'])) if len(self.devices) == 0: raise Exception('No device.') elif len(self.devices) >= 1: final_serial = AdbHelper.get_serial(self.serial) if final_serial is None: self.device_info_list = [] for device, state in self.devices.items(): print('Serial: {0} (State: {1})'.format(device, state)) if state == 'device': device_info = self.get_device_info(serial=device) self.print_device_info(device_info, no_color=is_no_color) self.device_info_list.append(device_info) else: print('Skipped.\n') self.device_info_list.append({'Serial': device, 'Skip': True}) else: print('Serial: {0} (State: {1})'.format(final_serial, self.devices[final_serial])) device_info = self.get_device_info(serial=final_serial) self.device_info_list = [device_info] self.print_device_info(device_info, no_color=is_no_color) self._output_log()
def run(self): """ Entry point. """ self.prepare() devices = AdbWrapper.adb_devices() is_no_color = self.args.no_color if "NO_COLOR" in os.environ: try: is_no_color = bool(util.strtobool(os.environ["NO_COLOR"].lower())) except: logger.error("Invalid NO_COLOR value [{0}].".format(os.environ["NO_COLOR"])) if len(devices) == 0: raise Exception("No device.") elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.args.serial) if final_serial is None: device_info_list = [] for device, state in devices.items(): print ("Serial: {0} (State: {1})".format(device, state)) if state == "device": device_info = self.get_device_info(serial=device) self.print_device_info(device_info, no_color=is_no_color) device_info_list.append(device_info) else: print ("Skipped.\n") device_info_list.append({"Serial": device, "Skip": True}) self.output_log(device_info_list) else: print ("Serial: {0} (State: {1})".format(final_serial, devices[final_serial])) device_info = self.get_device_info(serial=final_serial) self.print_device_info(device_info, no_color=is_no_color) self.output_log([device_info])
def run(self): """ Entry point. """ self.devices = AdbWrapper.adb_devices() logger.debug("Devices: {}".format(self.devices)) if len(self.devices) < 1: raise Exception("Can not find device, please connect your device.") elif len(self.devices) > 1: raise Exception("Find more than one device, please only connect one device.") # get device name device_name = AdbWrapper.adb_shell("getprop ro.product.device")[0] logger.info("Device found: {}".format(device_name)) if device_name not in self.SUPPORT_DEVICES.keys(): raise Exception("The {} device is not supported.".format(device_name)) # select branch branch = self.select_branch() # select build type postfix = self.select_build() # get namespace and image artifact device_info = self.SUPPORT_DEVICES.get(device_name) namespace = self.NAMESPACE_FORMAT(branch=branch, device=device_info.get("name"), postfix=postfix) artifact = self.ARTIFACT_FORMAT(build_path=self.BUILD_PATH, image=device_info.get("image")) logger.info("Device: {}".format(device_name)) logger.info("Namespace: {}".format(namespace)) logger.info("Artifact: {}".format(artifact)) ret = raw_input( '\nDownload "{artifact}" from "{namespace}".\nRight? [Y/n]'.format(artifact=artifact, namespace=namespace) ) if len(ret) > 0 and ret.lower()[0] == "n": logger.info("Stop.") exit(0) # downloading image logger.info("Downloading image...") local_image = self.download(namespace, artifact) logger.debug("Image file: {}".format(local_image)) # checking file logger.info("Checking file...") if not B2GHelper.check_b2g_image(local_image): raise Exception("This is not B2G image file: {}".format(local_image)) # flashing image logger.info("Flashing image...") self.flash_image(local_image)
def run(self): devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.args.serial) if final_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') self.get_crashreports(serial=final_serial) else: logger.debug('No serial, but there are more than one device') raise Exception('Please specify the device by --serial option.') else: print('Serial: {0} (State: {1})'.format(final_serial, devices[final_serial])) self.get_crashreports(serial=final_serial)
def run(self): devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.args.serial) if final_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') self.reset_phone(serial=final_serial) else: logger.debug('No serial, but there are more than one device') raise Exception('Please specify the device by --serial option.') else: print('Serial: {0} (State: {1})'.format(final_serial, devices[final_serial])) self.reset_phone(serial=final_serial)
def run(self): ''' Entry point. ''' self.prepare() devices = AdbWrapper.adb_devices() is_no_color = self.args.no_color if 'NO_COLOR' in os.environ: try: is_no_color = bool( util.strtobool(os.environ['NO_COLOR'].lower())) except: logger.error('Invalid NO_COLOR value [{0}].'.format( os.environ['NO_COLOR'])) if len(devices) == 0: raise Exception('No device.') elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.args.serial) if final_serial is None: device_info_list = [] for device, state in devices.items(): print('Serial: {0} (State: {1})'.format(device, state)) if state == 'device': device_info = self.get_device_info(serial=device) self.print_device_info(device_info, no_color=is_no_color) device_info_list.append(device_info) else: print('Skipped.\n') device_info_list.append({ 'Serial': device, 'Skip': True }) self.output_log(device_info_list) else: print('Serial: {0} (State: {1})'.format( final_serial, devices[final_serial])) device_info = self.get_device_info(serial=final_serial) self.print_device_info(device_info, no_color=is_no_color) self.output_log([device_info])
def run(self): """ Entry point. """ devices = AdbWrapper.adb_devices() is_enable = not self.disable if len(devices) == 0: raise Exception('No device.') elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.serial) if final_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') self.setup_certapps(enable=is_enable, serial=final_serial) else: logger.debug('No serial, but there are more than one device') raise Exception('Please specify the device by --serial option.') else: print('Serial: {0} (State: {1})'.format(final_serial, devices[final_serial])) self.setup_certapps(enable=is_enable, serial=final_serial)
def run(self): """ Entry point. """ devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') elif len(devices) >= 1: final_serial = AdbHelper.get_serial(self.serial) if final_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') self.get_crashreports(serial=final_serial) else: logger.debug( 'No serial, but there are more than one device') raise Exception( 'Please specify the device by --serial option.') else: print('Serial: {0} (State: {1})'.format( final_serial, devices[final_serial])) self.get_crashreports(serial=final_serial) self.output_log()
def run(self): # get the device's serial number devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') else: device_serial = AdbHelper.get_serial(self.args.serial) if device_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') else: logger.debug('No serial, but there are more than one device') raise Exception('Please specify the device by --serial option.') else: logger.debug('Setup serial to [{0}]'.format(device_serial)) # checking the adb root for backup/restore if not AdbWrapper.adb_root(serial=device_serial): raise Exception('No root permission for backup and resotre.') # Backup if self.args.backup: try: logger.info('Target device [{0}]'.format(device_serial)) # Create temp folder tmp_dir = tempfile.mkdtemp(prefix='backup_restore_') logger.debug('TEMP Foler: {}'.format(tmp_dir)) # Stop B2G B2GHelper.stop_b2g(serial=device_serial) # Backup User Profile self.backup_profile(local_dir=tmp_dir, serial=device_serial) # Backup SDCard if self.args.sdcard: self.backup_sdcard(local_dir=tmp_dir, serial=device_serial) # Copy backup files from temp folder to target folder if os.path.isdir(self.args.profile_dir): logger.warning('Removing [{0}] folder...'.format(self.args.profile_dir)) shutil.rmtree(self.args.profile_dir) logger.info('Copy profile from [{0}] to [{1}].'.format(tmp_dir, self.args.profile_dir)) shutil.copytree(tmp_dir, self.args.profile_dir) # Start B2G if not self.args.no_reboot: B2GHelper.start_b2g(serial=device_serial) finally: logger.debug('Removing [{0}] folder...'.format(tmp_dir)) shutil.rmtree(tmp_dir) # Restore elif self.args.restore: logger.info('Target device [{0}]'.format(device_serial)) # Checking the Version of Profile if self.check_profile_version(local_dir=self.args.profile_dir, serial=device_serial): # Stop B2G B2GHelper.stop_b2g(serial=device_serial) # Restore User Profile self.restore_profile(local_dir=self.args.profile_dir, serial=device_serial) # Restore SDCard if self.args.sdcard: self.restore_sdcard(local_dir=self.args.profile_dir, serial=device_serial) # Start B2G if not self.args.no_reboot: B2GHelper.start_b2g(serial=device_serial) else: logger.warning('The version on device is smaller than backup\'s version.')
def run(self): # get the device's serial number devices = AdbWrapper.adb_devices() if len(devices) == 0: raise Exception('No device.') else: device_serial = AdbHelper.get_serial(self.args.serial) if device_serial is None: if len(devices) == 1: logger.debug('No serial, and only one device') else: logger.debug( 'No serial, but there are more than one device') raise Exception( 'Please specify the device by --serial option.') else: logger.debug('Setup serial to [{0}]'.format(device_serial)) # checking the adb root for backup/restore if not AdbWrapper.adb_root(serial=device_serial): raise Exception('No root permission for backup and resotre.') # Backup if self.args.backup: try: logger.info('Target device [{0}]'.format(device_serial)) # Create temp folder tmp_dir = tempfile.mkdtemp(prefix='backup_restore_') logger.debug('TEMP Foler: {}'.format(tmp_dir)) # Stop B2G B2GHelper.stop_b2g(serial=device_serial) # Backup User Profile self.backup_profile(local_dir=tmp_dir, serial=device_serial) # Backup SDCard if self.args.sdcard: self.backup_sdcard(local_dir=tmp_dir, serial=device_serial) # Copy backup files from temp folder to target folder if os.path.isdir(self.args.profile_dir): logger.warning('Removing [{0}] folder...'.format( self.args.profile_dir)) shutil.rmtree(self.args.profile_dir) logger.info('Copy profile from [{0}] to [{1}].'.format( tmp_dir, self.args.profile_dir)) shutil.copytree(tmp_dir, self.args.profile_dir) # Start B2G if not self.args.no_reboot: B2GHelper.start_b2g(serial=device_serial) finally: logger.debug('Removing [{0}] folder...'.format(tmp_dir)) shutil.rmtree(tmp_dir) # Restore elif self.args.restore: logger.info('Target device [{0}]'.format(device_serial)) # Checking the Version of Profile if self.check_profile_version(local_dir=self.args.profile_dir, serial=device_serial): # Stop B2G B2GHelper.stop_b2g(serial=device_serial) # Restore User Profile self.restore_profile(local_dir=self.args.profile_dir, serial=device_serial) # Restore SDCard if self.args.sdcard: self.restore_sdcard(local_dir=self.args.profile_dir, serial=device_serial) # Start B2G if not self.args.no_reboot: B2GHelper.start_b2g(serial=device_serial) else: logger.warning( 'The version on device is smaller than backup\'s version.')