def __init__(self, adb_path, aapt_path, apk_folder, logger): self.adb_path = adb_path self.aapt_path = aapt_path self.adb_hp = adbhelper.AdbHelper(self.adb_path) self.aapt_hp = AAPTHelper(self.aapt_path) self.apk_folder = apk_folder self.logger = logger
def AnyDevice(): adb_obj = adbhelper.AdbHelper(r'%s\platform-tools\adb.exe' % Davinci_folder) output = adb_obj.adb_execution("devices", 120) output = output[0].split('\r\n') header_found = False any_device = False index = 0 devices = [] for line in output: index += 1 if line.find("List of devices attached") >= 0: header_found = True continue if header_found: if line.strip(): devices.append(line) any_device = True if not devices: print "No available devices." return devices
def __init__(self, *args, **kwargs): super(StorageTest, self).__init__(*args, **kwargs) self.adb_path = os.path.join(self.kwargs['dvc_path'], "platform-tools", "adb.exe") self.device_id = self.kwargs['device_id'] self.test_type = self.storage_test_type[ self.kwargs['storage_test_type'] - 1] self.running_times = self.kwargs.get('running_times', 1) self.tmp_file_size = self.kwargs.get('tmp_file_size', 100) self.apk_folder = self.kwargs.get("apk_folder") self.worker = dvcsubprocess.DVCSubprocess() self.adb = adbhelper.AdbHelper(self.adb_path) self.adb.device_id = self.device_id self.adb.timeout = 600 self.work_dir = os.path.join( os.path.abspath(self.apk_folder), "Storage_Test_" + dvcutility.Enviroment.get_cur_time_str()) self.logger = dvcutility.DVCLogger() self.logger.config( outfile=os.path.join(self.work_dir, 'powertest_log.txt')) self.writeresult = [] self.readresult = [] self.files_to_del = []
def __init__(self, *args, **kwargs): super(InstallationTest, self).__init__(*args, **kwargs) self.dvc_folder = os.path.abspath(self.kwargs['dvc_path']) self.dvc = os.path.join(self.dvc_folder, "DaVinci.exe") self.adb_path = os.path.join(self.kwargs['dvc_path'], "platform-tools", "adb.exe") self.aapt_path = os.path.join(self.kwargs['dvc_path'], "platform-tools", "aapt.exe") self.device_id = self.kwargs['device_id'] self.running_times = self.kwargs.get('running_times', 1) self.interval = int(self.kwargs.get('interval', 30)) self.apk_folder = self.kwargs.get("apk_folder") self.worker = dvcsubprocess.DVCSubprocess() self.adb = adbhelper.AdbHelper(self.adb_path) self.aapt = dvcutility.AAPTHelper(self.aapt_path) self.adb.device_id = self.device_id self.dvc_timeout = 300 self.work_dir = os.path.join( os.path.abspath(self.apk_folder), "Installation_Test_" + dvcutility.Enviroment.get_cur_time_str()) self.logger = dvcutility.DVCLogger() self.logger.config( outfile=os.path.join(self.work_dir, 'installation_log.txt')) self.qs = '[Configuration]\nCameraPresetting=HIGH_RES\nPackageName=\nActivityName=\nIconName=\nAPKName=\n' \ 'PushData= \nStatusBarHeight=33-33\nNavigationBarHeight=64-64\nStartOrientation=portrait\n' \ 'CameraType=\nVideoRecording=\nMultiLayerMode=False\nRecordedVideoType=\nReplayVideoType=\n' \ '[Events and Actions]\n' \ '1 504.8290: OPCODE_INSTALL_APP 0 \n' \ '2 852.6450: OPCODE_EXIT'
def __init__(self, adb_path, DaVinci_script_path, logger): self.adb_path = adb_path self.adb_hp = adbhelper.AdbHelper(self.adb_path) self.DaVinci_script_path = DaVinci_script_path self.logger = logger
def __init__(self, adb_path): self.adb_path = adb_path self.adb_hp = adbhelper.AdbHelper(self.adb_path)
def __init__(self, adb_path, device_name, logger): self.adb_path = adb_path self.adb_hp = adbhelper.AdbHelper(self.adb_path) self.adb_hp.device_id = device_name self.logger = logger
def GetDevInfo(self, info_name): try: adb_hp = adbhelper.AdbHelper(self.adb_path) adb_hp.device_id = self.device_name value = 'NA' if info_name.lower() == 'osver': value = adb_hp.adb_execution( 'shell getprop ro.build.version.release', 30, shell_flag=True)[0] value = value.strip().strip('\n').strip('\r') if info_name.lower() == 'model': value = adb_hp.adb_execution('shell getprop ro.product.model', 30, shell_flag=True)[0] value = value.strip().strip('\n').strip('\r') if info_name.lower() == 'dpi': temp_value = adb_hp.adb_execution('shell wm density', 30, shell_flag=True)[0] temp_value = temp_value.strip().strip('\n').strip('\r') if temp_value.lower().find('override density:') > -1: info_value = temp_value.split(':') if info_value[0].strip().lower() == 'override density': value = info_value[1].strip().lower() elif temp_value.lower().find('physical density:') > -1: info_value = temp_value.split(':') if info_value[0].strip().lower() == 'physical density': value = info_value[1].strip().lower() else: value = 'NA' else: temp_value = adb_hp.adb_execution('shell dumpsys window', 30, shell_flag=True)[0] lines = temp_value.strip().split('\r') flag = False for line in lines: if line.strip().startswith('DisplayContents:'): flag = True continue if flag and line.strip().startswith('init='): temp_value = line.split('=')[1].strip().lower() if temp_value.find('dpi') > -1: value = temp_value.split(' ')[1].replace( 'dpi', '') if info_name.lower() == 'resolution': value = adb_hp.adb_execution('shell wm size', 30, shell_flag=True)[0] value = value.strip().strip('\n').strip('\r') if value.lower().find('physical size:') > -1: info_value = value.split(':') if info_value[0].strip().lower() == 'physical size': value = info_value[1].strip().lower() else: value = 'NA' else: temp_value = adb_hp.adb_execution('shell dumpsys window', 30, shell_flag=True)[0] lines = temp_value.strip().split('\r') flag = False for line in lines: if line.strip().startswith('DisplayContents:'): flag = True continue if flag and line.strip().startswith('init='): temp_value = line.split('=')[1].strip().lower() value = temp_value.split(' ')[0] except Exception, e: s = sys.exc_info() print("[Error@%s]:%s" % ( str(s[2].tb_lineno), s[1], )) sys.exit(-1)
def DeviceSelection(): changed = False all_dev = [] bad_dev = [] adb_obj = adbhelper.AdbHelper(r'%s\platform-tools\adb.exe' % Davinci_folder) devices = AnyDevice() if not devices: sys.exit(-1) for line in devices: device_name = line.split('\t')[0] adb_obj.device_id = device_name status_info = adb_obj.adb_execution("get-state", 120) device_status = ("".join(status_info)).strip() if device_status.strip() != "device": changed = True bad_dev.append("%s\t%s" % (device_name, device_status)) continue all_dev.append(device_name) if bad_dev: print "\nWARNING: Please make sure devices below are power on and connected correctly!!!" print "-" * 70 print "Device Name \tStatus:" print "-" * 70 for bad_info in bad_dev: print bad_info if not all_dev: print("\n\nNo available device.") sys.exit(-1) print "\n\nReading information of attached devices. Please wait ......" all_dev = ShowDevTable(all_dev, "Device Group Information") config_items = [] target_name = '' complete = False group_dict = {} while not complete: test_dev = raw_input( "\n# Please choose one device to test. Input index:") try: int(test_dev) except: print "[Error]: Invalid number {0}".format(test_dev) continue if int(test_dev.strip()) < 1 or int(test_dev.strip()) > len(all_dev): print "[Error]: Invalid number {0}".format(test_dev) else: target_name = all_dev[int(test_dev) - 1] storage_obj = dvcutility.StorageInfo(r'%s\platform-tools\adb.exe' % Davinci_folder) free_ram_status = 'na' free_storage_status = 'na' free_storage_val_str, free_ram_val_str = storage_obj.CheckFreeStorage( target_name) if free_ram_val_str != '': free_ram_unit = re.search(r'(\d+) (\w+)', free_ram_val_str).group(2) free_ram_val = int( re.search(r'(\d+) (\w+)', free_ram_val_str).group(1)) if (free_ram_unit == "kB"): free_ram_val = float(free_ram_val / float(1000)) if (free_ram_unit == "G"): free_ram_val = float(free_ram_val * 1000) print 'Free Memory: {}M'.format(str(free_ram_val)) if free_ram_val > 12: # checking if free ram > 12M free_ram_status = 'ok' else: free_ram_status = 'low' print "[Warning]: Selected target device has less than 12M free memory. There may random error during testing." else: print "[Warning]:Failed to get memory information." if free_storage_val_str != '': free_storage_val = float( re.search(r'([\d.]+)([\w])', free_storage_val_str).group(1)) if (re.search(r'([\d.]+)([\w])', free_storage_val_str).group(2)) == 'M': free_storage_val = float(free_storage_val / float(1000)) print "Free Storage: {}G".format(str(free_storage_val)) if free_storage_val > 0.512: # checking if free storage > 0.512G free_storage_status = 'ok' else: free_storage_status = 'low' print "[Warning]: Selected target device has less than 512M free storage. There may random error during testing." else: print "[Warning]:Failed to get storage information." if (free_ram_status == 'low' or free_storage_status == 'low'): option = raw_input( "Press Enter to re-select. Press 'a' to accept this device: " ) if option.lower() == '': continue config_items.append(target_name) group_dict[1] = [] group_dict[1].append("NA") # Group name group_dict[1].append(target_name) # Device name complete = True break Treadmill.add(target_name, "Target", "DeviceID") device_id_selected.append(target_name)