def get_screenshot_forMultiDisplay(self, displayId=0): tmp_img = tempfile.mktemp(suffix='.png', prefix='temp_screen_', dir='/tmp') screenshot_img = "/sdcard/screenshot.png" g_common_obj.adb_cmd_capture_msg("screencap -d %d %s" % (displayId, screenshot_img)) g_common_obj.pull_file(tmp_img, screenshot_img) g_common_obj.adb_cmd_capture_msg("rm %s" % screenshot_img) LOG.info("Save screenshot: %s" % tmp_img) return tmp_img
def pull_and_push_thumbernail(): """ pull mediaProvider generates thumbernail to Host """ os.system("cd ~/Pictures") PhotosPPImpl().refresh_sdcard() os.system("echo change to dir ~/Pictures $?") os.system("mkdir -p ~/Pictures/thumbnails") g_common_obj.pull_file("~/Pictures/thumbnails", "/sdcard/DCIM/.thumbnails") time.sleep(2) g_common_obj.push_file("~/Pictures/thumbnails", "/sdcard/thumbnails") time.sleep(2) PhotosPPImpl().refresh_sdcard()
def checkVideoRecTestfile(self, encode_type='ST_VIDEO_REC_ENCODE_001', flag=True): import re size_pattern = re.compile("sdcard_rw(.*)20") file_path = '/sdcard/' + encode_type + '*' cmd = "shell ls -l %s" % (file_path) # result = g_common_obj.adb_cmd_capture_msg(cmd) result = self.multimedia_setting.execute_adb_command(cmd) size = re.findall(size_pattern, result) assert ("No such file or directory" not in result) == flag, "Record file status error! result=%s" % (result) if size != []: assert str(0) != size[0], "Record file size is zero, error!" g_common_obj.pull_file(g_common_obj.get_user_log_dir(), file_path) logger.debug(self.tag + "record file:" + result) logger.debug(self.tag + "record file exist") return True
def verify_thermal_in_scenarial(self, scenarial): self.thermal_file_host = gen_tmp_file_path_by_time(scenarial + ".txt") self.thermal_data_result = gen_tmp_file_path_by_time(scenarial + ".xls") self.thermal.ivi_start_capture_thermal_data(self.thermal_file_remote) if scenarial == "Antutu": self.keep_running_antutu(self.wait_time) elif scenarial == "GLBenchmark": self.keep_running_glbenchmark(self.wait_time) else: time.sleep(self.wait_time) self.thermal.ivi_end_capture_thermal_data() g_common_obj.pull_file(self.thermal_file_host, self.thermal_file_remote) self.thermal.ivi_gen_temp_result(self.thermal_data_result, self.thermal_file_host, self.score_list)
def pull_package(self, apk_path, target_path=None): if not target_path: target_path = tempfile.mktemp(suffix='.apk', prefix='apk_', dir='/tmp') LOG.debug('adb pull %s' % apk_path) assert g_common_obj.pull_file(target_path, apk_path), 'Failed pull file' return target_path
def commonTest(self, config, section=None): print "[RunTest]: %s" % self.__str__() if not section: section = self.id().split('.')[-1] case_cfg = TestConfig() cfg = case_cfg.read(config, section) config_handle = ConfigHandle() cfg["artifactory_location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat', 'sys.conf') arti = Artifactory(cfg.get('artifactory_location')) stream_fullpath = arti.get(cfg.get("stream")) stream_folder, stream_file = os.path.split(stream_fullpath) stream_name = os.path.basename(stream_file).split('.')[0] local_temp = '%s/%s' % (self.conf.get("local_temp"), stream_name) base_screenshots_path = '%s/base' % (local_temp) down_screenshots_path = '%s/remote' % (local_temp) remote_path = self.conf.get("remote_temp") os.system("rm -rf %s; mkdir -p %s" % (local_temp, local_temp)) os.system("mkdir -p %s" % (base_screenshots_path)) os.system("mkdir -p %s" % (down_screenshots_path)) os.system("rm -rf %s/%s" % (stream_folder, stream_name)) os.system("tar -C %s -zxvf %s" % (stream_folder, stream_fullpath)) os.system("mv -v %s/%s/%s/* %s" \ % (stream_folder, stream_name,\ self.conf.get("screenshots_subpath"), base_screenshots_path)) check_points = [] for path, _, files in os.walk(base_screenshots_path): for _name in files: _point = int(re.findall('\d+', _name)[0]) _full_path = os.path.join(path, _name) _remote_path = '%s/%s/%s/%s'\ % (remote_path, stream_name,\ self.conf.get("screenshots_subpath"), _name) check_points.append((_point, _name, _full_path, _remote_path)) assert check_points, "check_points empty!" check_points = deque(sorted(check_points, key=lambda t: t[0])) print "Check Points\n%s" % ([p[0] for p in check_points]) g_common_obj.adb_cmd_capture_msg("rm -rf %s/%s; sync"\ % (remote_path, stream_name)) ret = g_common_obj.push_file("%s/%s" % (stream_folder, stream_name),\ "%s/%s" % (remote_path, stream_name)) assert ret, 'Failed push %s' % (stream_name) gits_player = self.conf.get("gits_player") while len(check_points) > 0: point1, name1, fullpath1, _remote_path1 = check_points.popleft() point2, name2, fullpath2, _remote_path2 =\ point1, name1, fullpath1, _remote_path1 if len(check_points) > 0: point2, name2, fullpath2, _remote_path2 =\ check_points.popleft() lenth = point2 - point1 if point2 - point1 > 0 else 1 cmd_play = '%s %s/%s --captureFrames %s-%s:%s'\ % (gits_player, remote_path, stream_name,\ point1, point2, lenth) g_common_obj.adb_cmd_capture_msg(cmd_play) pull_path1 = '%s/%s' % (down_screenshots_path, name1) ret = g_common_obj.pull_file(pull_path1, _remote_path1) assert ret, 'Failed get %s' % (_remote_path1) self._diff_imag_file(stream_name, fullpath1, pull_path1) if point1 == point2: continue pull_path2 = '%s/%s' % (down_screenshots_path, name2) ret = g_common_obj.pull_file(pull_path2, _remote_path2) assert ret, 'Failed get %s' % (_remote_path1) self._diff_imag_file(stream_name, fullpath2, pull_path2) g_common_obj.adb_cmd_capture_msg("rm -rf %s/%s; sync"\ % (remote_path, stream_name))