Debian Codegraph @

tools/ffmpeg/report.py

raw symbols SCIP
1 import sys
2
3 import reports
4 import fs
5 import mpexceptions
6
7
8 def description():
9 template = ("""
10 Usage
11
12 report.py sample report_name
13
14 Generates a report from the debugging info recorded while playing sample
15
16 Arguments
17
18 sample: sample to report
19 report_name: desired report, one of
20 {reports}
21
22 The report will be written to session's output dir under reports/sample.report_name.txt
23
24 Example
25
26 report anomalies small.mp4
27
28 will write the report 'anomalies' to report/small.mp4.anomalies.txt
29 """
30 )
31 text = template.format(reports=reports.available_reports_description(line_prefix=" " * 8))
32 return text
33
34
35 def main(sample, report_name):
36 try:
37 pathserv = fs.get_path_info_for_active_session()
38 except mpexceptions.ExceptionUndefinedSamplesDir:
39 print("The env var 'pyglet_mp_samples_dir' is not defined.")
40 return 1
41 except mpexceptions.ExceptionNoSessionIsActive:
42 print("*** Error, no session active.")
43 return 1
44
45 report_sample(pathserv, sample, report_name)
46
47
48 def report_sample(pathserv, sample, report_name):
49 dbg_file = pathserv.dbg_filename(sample)
50 outfile = pathserv.report_filename(sample, report_name)
51 log_entries = fs.pickle_load(dbg_file)
52 text = reports.report_by_name(report_name)(log_entries)
53 fs.txt_save(text, outfile)
54
55
56 def sysargs_to_mainargs():
57 """builds main args from sys.argv"""
58 if len(sys.argv) < 3:
59 print(description())
60 sys.exit(1)
61 report_name, sample = sys.argv[1:]
62 return report_name, sample
63
64 if __name__ == '__main__':
65 sample, report_name = sysargs_to_mainargs()
66 main(sample, report_name)