ok-script 0.0.91__tar.gz → 0.0.93__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ok-script-0.0.91 → ok-script-0.0.93}/PKG-INFO +1 -1
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/OK.py +24 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/adb/DeviceManager.py +1 -1
- ok-script-0.0.93/ok/capture/windows/dump.py +80 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/App.py +10 -9
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/MainWindow.py +4 -16
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/StartController.py +1 -1
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/DebugTab.py +19 -17
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/LogWindow.py +23 -24
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/resources.py +433 -432
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/start/StartCard.py +9 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/task/TaskExecutor.py +3 -5
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/update/GithubMultiDownloader.py +48 -11
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/update/Updater.py +14 -5
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/Handler.py +1 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok_script.egg-info/PKG-INFO +1 -1
- {ok-script-0.0.91 → ok-script-0.0.93}/setup.py +1 -1
- ok-script-0.0.91/ok/capture/windows/dump.py +0 -31
- {ok-script-0.0.91 → ok-script-0.0.93}/README.md +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/alas/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/alas/emulator_base.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/alas/emulator_windows.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/alas/platform_base.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/alas/platform_windows.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/alas/utils.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/BaseCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/HwndWindow.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/adb/ADBCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/adb/WindowsCaptureFactory.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/image/ImageCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/image/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/BaseWindowsCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/BitBltCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/DesktopDuplicationCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/color/Color.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/color/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/config/Config.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/config/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/feature/Box.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/feature/CompressCoco.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/feature/FeatureSet.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/feature/FindFeature.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/firebase/Analytics.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/firebase/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/Communicate.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/MessageWindow.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/about/HttpTextEdit.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/about/VersionCard.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/FrameWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/Screenshot.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/overlay/OverlayWindow.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/OneTimeTaskTab.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/TaskCard.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/EmptyCard.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/StartLoadingDialog.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/interaction/ADBInteraction.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/interaction/BaseInteraction.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/interaction/DoNothingInteraction.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/interaction/Win32Interaction.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/logging/Logger.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/ocr/OCR.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Media/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Security/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/Storage/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/Windows/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/save/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/scene/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/stats/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/task/BaseTask.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/task/ExecutorOperation.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/task/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/update/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/update/gen_md5.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/exit_event.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/json.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/list.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/path.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/thread.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok/util/yaml.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok_script.egg-info/SOURCES.txt +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/setup.cfg +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/tests/__init__.py +0 -0
- {ok-script-0.0.91 → ok-script-0.0.93}/tests/test_updater.py +0 -0
|
@@ -37,6 +37,9 @@ class OK:
|
|
|
37
37
|
config['debug'] = config.get("debug", False)
|
|
38
38
|
self.debug = config['debug']
|
|
39
39
|
try:
|
|
40
|
+
if self.debug:
|
|
41
|
+
import win32api
|
|
42
|
+
win32api.SetConsoleCtrlHandler(self.console_handler, True)
|
|
40
43
|
self.config = config
|
|
41
44
|
self.init_device_manager()
|
|
42
45
|
from ok.gui.debug.Screenshot import Screenshot
|
|
@@ -59,6 +62,7 @@ class OK:
|
|
|
59
62
|
if self.config.get("use_gui"):
|
|
60
63
|
if not self.init_error:
|
|
61
64
|
self.app.show_main_window()
|
|
65
|
+
logger.debug('start app.exec()')
|
|
62
66
|
self.app.exec()
|
|
63
67
|
else:
|
|
64
68
|
self.task_executor.start()
|
|
@@ -135,6 +139,26 @@ class OK:
|
|
|
135
139
|
while not self.exit_event.is_set():
|
|
136
140
|
time.sleep(1)
|
|
137
141
|
|
|
142
|
+
def console_handler(self, event):
|
|
143
|
+
import win32con
|
|
144
|
+
if event == win32con.CTRL_C_EVENT:
|
|
145
|
+
logger.info("CTRL+C event dump threads")
|
|
146
|
+
from ok.capture.windows.dump import dump_threads
|
|
147
|
+
dump_threads()
|
|
148
|
+
self.quit()
|
|
149
|
+
elif event == win32con.CTRL_CLOSE_EVENT:
|
|
150
|
+
logger.info("Close event quit")
|
|
151
|
+
self.quit()
|
|
152
|
+
elif event == win32con.CTRL_LOGOFF_EVENT:
|
|
153
|
+
logger.info("Logoff event quit")
|
|
154
|
+
self.quit()
|
|
155
|
+
elif event == win32con.CTRL_SHUTDOWN_EVENT:
|
|
156
|
+
logger.info("Shutdown event quit")
|
|
157
|
+
self.quit()
|
|
158
|
+
else: # Perform clean-up tasks here
|
|
159
|
+
print("Performing clean-up...")
|
|
160
|
+
return True
|
|
161
|
+
|
|
138
162
|
def quit(self):
|
|
139
163
|
logger.debug('quit app')
|
|
140
164
|
self.exit_event.set()
|
|
@@ -67,7 +67,7 @@ class DeviceManager:
|
|
|
67
67
|
logger.debug(f'adb_connect already connected {addr}')
|
|
68
68
|
return device
|
|
69
69
|
if try_connect:
|
|
70
|
-
self.adb.connect(addr, timeout=
|
|
70
|
+
self.adb.connect(addr, timeout=3)
|
|
71
71
|
logger.debug(f'adb_connect {addr}')
|
|
72
72
|
return self.adb_connect(addr, try_connect=False)
|
|
73
73
|
except AdbTimeout as e:
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import signal
|
|
3
|
+
import sys
|
|
4
|
+
import threading
|
|
5
|
+
import traceback
|
|
6
|
+
|
|
7
|
+
from ok.util.path import get_path_relative_to_exe
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_thread_name(thread_id):
|
|
11
|
+
for thread in threading.enumerate():
|
|
12
|
+
if thread.ident == thread_id:
|
|
13
|
+
return thread.name
|
|
14
|
+
return "" # Return empty string if the thread name is not found
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def dump_threads():
|
|
18
|
+
# Get the stack trace for each thread
|
|
19
|
+
thread_dumps = []
|
|
20
|
+
for thread_id, frame in sys._current_frames().items():
|
|
21
|
+
thread_name = get_thread_name(thread_id)
|
|
22
|
+
thread_dump = f"Stack for thread {thread_id} (Name: {thread_name}):\n"
|
|
23
|
+
thread_dump += "".join(traceback.format_stack(frame))
|
|
24
|
+
thread_dumps.append(thread_dump)
|
|
25
|
+
|
|
26
|
+
# Write the thread dumps to a file
|
|
27
|
+
output_file = get_path_relative_to_exe(os.path.join('logs', "thread_dumps.txt"))
|
|
28
|
+
print(f'Dumping threads to {output_file}')
|
|
29
|
+
|
|
30
|
+
with open(output_file, "w") as file:
|
|
31
|
+
file.write("\n\n".join(thread_dumps))
|
|
32
|
+
# subprocess.Popen(r'explorer /select,"{}"'.format(output_file))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def kill_dump():
|
|
36
|
+
print("Killing dump")
|
|
37
|
+
dump_threads()
|
|
38
|
+
sys.exit(0)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def console_handler(event):
|
|
42
|
+
import win32con
|
|
43
|
+
if event == win32con.CTRL_C_EVENT:
|
|
44
|
+
print("CTRL+C event")
|
|
45
|
+
dump_threads()
|
|
46
|
+
sys.exit(0)
|
|
47
|
+
elif event == win32con.CTRL_CLOSE_EVENT:
|
|
48
|
+
print("Close event")
|
|
49
|
+
elif event == win32con.CTRL_LOGOFF_EVENT:
|
|
50
|
+
print("Logoff event")
|
|
51
|
+
elif event == win32con.CTRL_SHUTDOWN_EVENT:
|
|
52
|
+
print("Shutdown event")
|
|
53
|
+
# Perform clean-up tasks here
|
|
54
|
+
print("Performing clean-up...")
|
|
55
|
+
# sys.exit(0) # Exit the program
|
|
56
|
+
return True
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == '__main__':
|
|
60
|
+
|
|
61
|
+
import psutil
|
|
62
|
+
import faulthandler
|
|
63
|
+
|
|
64
|
+
# Enable the fault handler
|
|
65
|
+
faulthandler.enable()
|
|
66
|
+
|
|
67
|
+
# Iterate over all running processes
|
|
68
|
+
for proc in psutil.process_iter(['pid', 'name', 'status', 'exe']):
|
|
69
|
+
# Check if the process is unresponsive
|
|
70
|
+
# print(proc.info['exe'])
|
|
71
|
+
if proc.info['name'] == 'python.exe':
|
|
72
|
+
# Dump the traceback
|
|
73
|
+
print(f'dump {proc.pid} {proc.cmdline()} {proc.info["pid"] == os.getpid()}')
|
|
74
|
+
# faulthandler.dump_traceback(file=sys.stderr, all_threads=True)
|
|
75
|
+
# Kill the process
|
|
76
|
+
# os.kill(proc.info['pid'], signal.SIGTERM)
|
|
77
|
+
|
|
78
|
+
# faulthandler.dump_traceback(file=sys.stderr, all_threads=True)
|
|
79
|
+
# Kill the process
|
|
80
|
+
os.kill(16916, signal.SIGTERM)
|
|
@@ -13,7 +13,6 @@ from ok.gui.Communicate import communicate
|
|
|
13
13
|
from ok.gui.MainWindow import MainWindow
|
|
14
14
|
from ok.gui.MessageWindow import MessageWindow
|
|
15
15
|
from ok.gui.StartController import StartController
|
|
16
|
-
from ok.gui.debug.LogWindow import LogWindow
|
|
17
16
|
from ok.gui.i18n.path import i18n_path
|
|
18
17
|
from ok.gui.overlay.OverlayWindow import OverlayWindow
|
|
19
18
|
from ok.logging.Logger import get_logger
|
|
@@ -95,26 +94,28 @@ class App:
|
|
|
95
94
|
self.show_message_window(title, content)
|
|
96
95
|
|
|
97
96
|
def show_main_window(self):
|
|
97
|
+
|
|
98
|
+
if self.overlay and ok.gui.device_manager.hwnd is not None:
|
|
99
|
+
self.overlay_window = OverlayWindow(ok.gui.device_manager.hwnd)
|
|
100
|
+
|
|
101
|
+
if self.config.get('debug'):
|
|
102
|
+
from ok.gui.debug.LogWindow import LogWindow
|
|
103
|
+
self.log_window = LogWindow(self.config)
|
|
104
|
+
self.log_window.show()
|
|
105
|
+
logger.debug('showing log_window')
|
|
106
|
+
|
|
98
107
|
self.main_window = MainWindow(self.config, self.icon, self.title, self.version, self.overlay, self.about,
|
|
99
108
|
self.exit_event)
|
|
100
109
|
# Set the window title here
|
|
101
110
|
self.main_window.setWindowIcon(self.icon)
|
|
102
|
-
if self.overlay and ok.gui.device_manager.hwnd is not None:
|
|
103
|
-
self.overlay_window = OverlayWindow(ok.gui.device_manager.hwnd)
|
|
104
111
|
|
|
105
112
|
size = self.size_relative_to_screen(width=0.5, height=0.6)
|
|
106
113
|
self.main_window.resize(size)
|
|
107
114
|
self.main_window.setMinimumSize(size)
|
|
108
115
|
|
|
109
|
-
# Optional: Move the window to the center of the screen
|
|
110
|
-
|
|
111
116
|
self.main_window.show()
|
|
112
117
|
self.main_window.raise_()
|
|
113
118
|
self.main_window.activateWindow()
|
|
114
|
-
if self.config.get('debug'):
|
|
115
|
-
self.log_window = LogWindow(self.config)
|
|
116
|
-
self.log_window.show()
|
|
117
|
-
logger.debug('showing log_window')
|
|
118
119
|
|
|
119
120
|
def size_relative_to_screen(self, width, height):
|
|
120
121
|
screen = self.app.primaryScreen()
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import sys
|
|
3
2
|
|
|
4
3
|
from PySide6.QtCore import QObject, Signal, Qt
|
|
5
4
|
from PySide6.QtWidgets import QMenu, QSystemTrayIcon
|
|
6
|
-
from qfluentwidgets import FluentIcon, NavigationItemPosition, MSFluentWindow, InfoBar, InfoBarPosition
|
|
5
|
+
from qfluentwidgets import FluentIcon, NavigationItemPosition, MSFluentWindow, InfoBar, InfoBarPosition
|
|
7
6
|
|
|
8
7
|
import ok.gui
|
|
9
8
|
from ok.gui.Communicate import communicate
|
|
@@ -158,22 +157,11 @@ class MainWindow(MSFluentWindow):
|
|
|
158
157
|
self.comm.speak.emit("Hello, PySide6 with parameters!")
|
|
159
158
|
|
|
160
159
|
def closeEvent(self, event):
|
|
161
|
-
# Create a message box that asks the user if they really want to close the window
|
|
162
|
-
if sys.platform == 'win32' and 'shutdown' in os.environ.get('SESSIONNAME', '').lower():
|
|
163
|
-
logger.info("system shutting down")
|
|
164
|
-
ok.gui.ok.quit()
|
|
165
|
-
event.accept()
|
|
166
|
-
return
|
|
167
|
-
|
|
168
160
|
if ok.gui.ok.exit_event.is_set():
|
|
161
|
+
logger.info("Window closed exit_event.is_set")
|
|
169
162
|
event.accept()
|
|
170
163
|
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
w = MessageBox(title, content, self.window())
|
|
174
|
-
if w.exec():
|
|
175
|
-
logger.info("Window closed")
|
|
164
|
+
else:
|
|
165
|
+
logger.info("Window closed exit_event.is not set")
|
|
176
166
|
ok.gui.ok.quit()
|
|
177
167
|
event.accept()
|
|
178
|
-
else:
|
|
179
|
-
event.ignore()
|
|
@@ -39,7 +39,7 @@ class StartController(QObject):
|
|
|
39
39
|
error = self.check_device_error()
|
|
40
40
|
if error is None:
|
|
41
41
|
break
|
|
42
|
-
logger.
|
|
42
|
+
logger.error(f'waiting for game to start error {error}')
|
|
43
43
|
remaining_time = wait_until - time.time()
|
|
44
44
|
if remaining_time <= 0:
|
|
45
45
|
communicate.starting_emulator.emit(True, self.tr('Start game timeout!'), 0)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import subprocess
|
|
2
2
|
from ctypes import windll, wintypes
|
|
3
3
|
|
|
4
|
-
from PySide6.QtCore import Qt, Signal
|
|
4
|
+
from PySide6.QtCore import Qt, Signal, QCoreApplication
|
|
5
5
|
from PySide6.QtWidgets import QWidget, QFileDialog, QCompleter, QVBoxLayout, QHBoxLayout
|
|
6
6
|
from _ctypes import byref
|
|
7
7
|
from qfluentwidgets import PushButton, FlowLayout, ComboBox, SearchLineEdit, TextEdit
|
|
@@ -46,7 +46,7 @@ class DebugTab(Tab):
|
|
|
46
46
|
# self.dump_shortcut.activated.connect(dump_threads)
|
|
47
47
|
|
|
48
48
|
capture_button = PushButton(self.tr("Capture Screenshot"))
|
|
49
|
-
capture_button.clicked.connect(lambda: self.handler.post(
|
|
49
|
+
capture_button.clicked.connect(lambda: self.handler.post(capture))
|
|
50
50
|
layout.addWidget(capture_button)
|
|
51
51
|
|
|
52
52
|
ocr_button = PushButton("OCR")
|
|
@@ -202,20 +202,22 @@ class DebugTab(Tab):
|
|
|
202
202
|
self.select_screenshot_button.setText(self.tr("Drop or Select Screenshot"))
|
|
203
203
|
self.config['target_images'] = None
|
|
204
204
|
|
|
205
|
-
def capture(self):
|
|
206
|
-
if ok.gui.device_manager.capture_method is not None:
|
|
207
|
-
logger.info(f'ok.gui.device_manager.capture_method {ok.gui.device_manager.capture_method}')
|
|
208
|
-
capture = str(ok.gui.device_manager.capture_method)
|
|
209
|
-
frame = ok.gui.device_manager.capture_method.do_get_frame()
|
|
210
|
-
if frame is not None:
|
|
211
|
-
file_path = ok.gui.ok.screenshot.generate_screen_shot(frame, ok.gui.ok.screenshot.ui_dict,
|
|
212
|
-
ok.gui.ok.screenshot.screenshot_folder, capture)
|
|
213
205
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
206
|
+
def capture():
|
|
207
|
+
if ok.gui.device_manager.capture_method is not None:
|
|
208
|
+
logger.info(f'ok.gui.device_manager.capture_method {ok.gui.device_manager.capture_method}')
|
|
209
|
+
current_capture = str(ok.gui.device_manager.capture_method)
|
|
210
|
+
frame = ok.gui.device_manager.capture_method.do_get_frame()
|
|
211
|
+
if frame is not None:
|
|
212
|
+
file_path = ok.gui.ok.screenshot.generate_screen_shot(frame, ok.gui.ok.screenshot.ui_dict,
|
|
213
|
+
ok.gui.ok.screenshot.screenshot_folder,
|
|
214
|
+
current_capture)
|
|
215
|
+
|
|
216
|
+
# Use subprocess.Popen to open the file explorer and select the file
|
|
217
|
+
subprocess.Popen(r'explorer /select,"{}"'.format(file_path))
|
|
218
|
+
logger.info(f'captured screenshot: {current_capture}')
|
|
219
|
+
alert_info(QCoreApplication.translate('DebugTab', 'Capture Success'), True)
|
|
220
220
|
else:
|
|
221
|
-
alert_error(
|
|
221
|
+
alert_error(QCoreApplication.translate('DebugTab', 'Capture returned None'))
|
|
222
|
+
else:
|
|
223
|
+
alert_error(QCoreApplication.translate('DebugTab', 'No Capture Available or Selected'))
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
from PySide6.QtCore import Qt, QAbstractListModel,
|
|
1
|
+
from PySide6.QtCore import Qt, QAbstractListModel, QPoint, QModelIndex
|
|
2
2
|
from PySide6.QtGui import QColor
|
|
3
|
-
from PySide6.QtWidgets import
|
|
4
|
-
|
|
3
|
+
from PySide6.QtWidgets import QWidget, \
|
|
4
|
+
QStyledItemDelegate, QListView, QVBoxLayout, QHBoxLayout, QAbstractItemView, QComboBox, QLineEdit, QLabel, \
|
|
5
|
+
QPushButton
|
|
5
6
|
|
|
6
7
|
from ok.config.Config import Config
|
|
7
8
|
from ok.gui.Communicate import communicate
|
|
@@ -39,19 +40,19 @@ class ColorDelegate(QStyledItemDelegate):
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
class LogModel(QAbstractListModel):
|
|
42
|
-
def __init__(self
|
|
43
|
+
def __init__(self):
|
|
43
44
|
super(LogModel, self).__init__()
|
|
44
|
-
self.log_list = log_list
|
|
45
45
|
self.logs = []
|
|
46
|
-
self.filtered_logs =
|
|
46
|
+
self.filtered_logs = []
|
|
47
47
|
self.current_level = "ALL"
|
|
48
48
|
self.current_keyword = ""
|
|
49
49
|
|
|
50
50
|
def data(self, index, role):
|
|
51
|
-
if
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if 0 <= index.row() < len(self.filtered_logs):
|
|
52
|
+
if role == Qt.DisplayRole:
|
|
53
|
+
return self.filtered_logs[index.row()].text
|
|
54
|
+
elif role == Qt.ForegroundRole:
|
|
55
|
+
return self.filtered_logs[index.row()].format
|
|
55
56
|
|
|
56
57
|
def rowCount(self, index):
|
|
57
58
|
return len(self.filtered_logs)
|
|
@@ -62,15 +63,15 @@ class LogModel(QAbstractListModel):
|
|
|
62
63
|
colored_text = ColoredText(message, color_format, level)
|
|
63
64
|
self.logs.append(colored_text)
|
|
64
65
|
if len(self.logs) >= 500:
|
|
65
|
-
self.beginRemoveRows(QModelIndex(), 0, 0)
|
|
66
|
+
# self.beginRemoveRows(QModelIndex(), 0, 0)
|
|
66
67
|
self.logs.pop(0)
|
|
67
|
-
self.endRemoveRows()
|
|
68
|
-
|
|
68
|
+
# self.endRemoveRows()
|
|
69
69
|
self.beginInsertRows(QModelIndex(), self.rowCount(QModelIndex()), self.rowCount(QModelIndex()))
|
|
70
70
|
self.do_filter_logs()
|
|
71
71
|
self.endInsertRows()
|
|
72
|
-
|
|
73
|
-
self.
|
|
72
|
+
|
|
73
|
+
# self.layoutChanged.emit()
|
|
74
|
+
# self.log_list.scrollToBottom()
|
|
74
75
|
|
|
75
76
|
def do_filter_logs(self):
|
|
76
77
|
|
|
@@ -92,9 +93,10 @@ class LogModel(QAbstractListModel):
|
|
|
92
93
|
def filter_logs(self, level, keyword):
|
|
93
94
|
self.current_level = level
|
|
94
95
|
self.current_keyword = keyword
|
|
96
|
+
self.beginRemoveRows(QModelIndex(), 0, self.rowCount(QModelIndex()) - 1)
|
|
97
|
+
self.filtered_logs.clear()
|
|
98
|
+
self.endRemoveRows()
|
|
95
99
|
self.do_filter_logs()
|
|
96
|
-
self.layoutChanged.emit()
|
|
97
|
-
self.log_list.scrollToBottom()
|
|
98
100
|
|
|
99
101
|
def get_color_format(self, level):
|
|
100
102
|
# Define color codes for different levels
|
|
@@ -118,8 +120,6 @@ class LogWindow(QWidget):
|
|
|
118
120
|
app_config.get('config_folder'), 'log_window')
|
|
119
121
|
self.setGeometry(self.config['x'], self.config['y'], self.config['width'], self.config['height'])
|
|
120
122
|
|
|
121
|
-
self.refresh_signal = Signal()
|
|
122
|
-
|
|
123
123
|
self.old_pos = None
|
|
124
124
|
|
|
125
125
|
# Layouts
|
|
@@ -158,16 +158,15 @@ class LogWindow(QWidget):
|
|
|
158
158
|
|
|
159
159
|
self.setLayout(self.layout)
|
|
160
160
|
|
|
161
|
-
self.log_model = LogModel(
|
|
161
|
+
self.log_model = LogModel()
|
|
162
162
|
self.log_list.setModel(self.log_model)
|
|
163
|
-
communicate.log.connect(self.add_log)
|
|
164
163
|
|
|
165
|
-
self.
|
|
166
|
-
self.filter_logs()
|
|
164
|
+
communicate.log.connect(self.add_log)
|
|
167
165
|
|
|
168
166
|
def add_log(self, level_no, message):
|
|
169
|
-
|
|
167
|
+
# print('add_log', level_no, message)
|
|
170
168
|
self.log_model.add_log(log_levels.get(level_no, 'DEBUG'), message)
|
|
169
|
+
self.log_list.scrollToBottom()
|
|
171
170
|
|
|
172
171
|
def filter_logs(self):
|
|
173
172
|
level = self.level_filter.currentText()
|