-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_wav_diff_gui.py
More file actions
93 lines (72 loc) · 2.69 KB
/
check_wav_diff_gui.py
File metadata and controls
93 lines (72 loc) · 2.69 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import os.path
import sys
import argparse
# import QCoreApplication
from PySide6.QtCore import QCoreApplication
from PySide6.QtWidgets import QApplication
from qt_material import build_stylesheet
from view.main import MainWindow
from utils import p4
from utils import diff_checker
from utils.watch_setting import WatchSetting
BASE_CONFIG_PATH = "config.json"
USER_CONFIG_PATH = "user_config.json"
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--prev", type=str, required=False)
parser.add_argument("--curr", type=str, required=False)
parser.add_argument("--clean_mode", action="store_true")
parser.add_argument("--no_gui", action="store_true")
return parser.parse_args()
def start_gui_app(ws: WatchSetting, watch_setting_save_path: str):
# init
app = QApplication([])
main_window = MainWindow(
loaded_watch_setting=ws,
watch_setting_save_path=watch_setting_save_path,
)
# style setting
stylesheet = build_stylesheet(theme="dark_teal.xml", template="material.css")
app.setStyleSheet(stylesheet)
# start app
main_window.show()
app_thread = app.exec()
# end
sys.exit(app_thread)
def start_console_app(ws: WatchSetting):
p4_client = MainWindow.create_p4_client(ws)
for watch_item in ws.watch_item_list:
print("[Start]Start checking '%s'" % watch_item.name)
checker = MainWindow.create_checker(
watch_item=watch_item,
p4_client=p4_client,
check_rules=MainWindow.get_check_rules(),
clean_mode=not ws.disable_clean_mode,
)
for file_idx, file_path in checker.check(p4_client, yield_path_flag=True):
print("\r[Checking][%d/%d]%s" % (file_idx + 1, len(checker), file_path), end="")
output_path = MainWindow.save_checker_result(
checker=checker,
watch_item=watch_item,
output_dir=ws.output_dir,
)
print("\n[End]Finish checking. Result saved to '%s'" % os.path.abspath(output_path))
if __name__ == '__main__':
# load watch setting
watch_setting = WatchSetting()
if os.path.exists(BASE_CONFIG_PATH):
watch_setting.from_json(BASE_CONFIG_PATH)
if os.path.exists(USER_CONFIG_PATH):
watch_setting.from_json(USER_CONFIG_PATH)
# parse args
args = parse_args()
for item in watch_setting.watch_item_list:
if args.prev is not None:
item.prev_stamp = args.prev
if args.curr is not None:
item.curr_stamp = args.curr
watch_setting.disable_clean_mode = not args.clean_mode
if args.no_gui:
start_console_app(watch_setting)
else:
start_gui_app(watch_setting, USER_CONFIG_PATH)