-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.py
executable file
·78 lines (54 loc) · 2.14 KB
/
main.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import sys
import os
import traceback
import common
import detector
def main():
print("main entry!")
workspace = os.getcwd()
print("workspace: " + workspace)
from optparse import OptionParser
parser = OptionParser(usage="./main.py -o csv_path")
parser.add_option("-c", "--configfile",
action="store", type="string", dest="config_file", default=None,
help="The config file path")
parser.add_option("-z", "--zip",
action="store", type="string", dest="seven_zip_path", default=None,
help="7z path")
parser.add_option("-p", "--pkg-dir",
action="store", type="string", dest="pkg_dir", default=None,
help="Directory that contains packages")
parser.add_option("-o", "--out-file",
action="store", type="string", dest="out_file", default=None,
help="The result file")
(opts, args) = parser.parse_args()
if opts.config_file is None:
opts.config_file = "config.json"
cfg = common.read_object_from_json_file(opts.config_file)
cfg["7z_path"]= opts.seven_zip_path
if opts.pkg_dir is not None:
cfg["package_dirs"]= [opts.pkg_dir.decode("utf-8")]
d = detector.GameEngineDetector(workspace, cfg)
d.run()
r = d.get_all_results()
out_file_name = os.path.join(workspace, "result.csv")
if opts.out_file:
out_file_name = opts.out_file
common.result_csv_output(r, out_file_name)
for e in r:
str = "package: " + e["file_name"] + ", engine: " + e["engine"] + ", version: " + e["engine_version"] + ", "
if e["sub_types"]:
for sub_type in e["sub_types"]:
str += "subtype: " + sub_type + ", "
if len(e["error_info"]) > 0:
for err in e["error_info"]:
str += ", error info: " + err + ", "
str += "matched:" + e["matched_content_file_name"]
print(str.encode('utf-8'))
if __name__ == '__main__':
try:
main()
except Exception as e:
traceback.print_exc()
sys.exit(1)