1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| class LogToHtml(object): scale = 0.5 def __init__(self, script_root, log_root="", static_root="", export_dir=None, script_name="", logfile=None, lang="en", plugins=None, log_host=None): ... self.log_host = log_host def _translate_screen(self, step, code): ... for item in step["__children__"]: if item["data"]["name"] == "try_log_screen": snapshot = item["data"].get("ret", None) if isinstance(snapshot, six.text_type): src = snapshot elif isinstance(snapshot, dict): src = snapshot['screen'] screen['resolution'] = snapshot['resolution'] else: continue if self.export_dir: screen['_filepath'] = os.path.join(DEFAULT_LOG_DIR, src) else: screen['_filepath'] = os.path.abspath(os.path.join(self.log_root, src))
if self.log_host: screen['_filepath'] = self.log_host + "/" + src screen['src'] = screen['_filepath'] def report(self, template_name=HTML_TPL, output_file=HTML_FILE, record_list=None): .... if not record_list: record_list = [f for f in os.listdir(self.log_root) if f.endswith(".mp4")] data = self.report_data(output_file=output_file, record_list=record_list, log_host=self.log_host) def report_data(self, output_file=None, record_list=None, log_host=None): ... if record_list: records = [os.path.join(DEFAULT_LOG_DIR, f) if self.export_dir else os.path.abspath(os.path.join(self.log_root, f)) for f in record_list] if log_host: records = [] for i in record_list: records.append(log_host + "/" + i)
|