ok-script 0.0.97__tar.gz → 0.0.99__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.97 → ok-script-0.0.99}/PKG-INFO +1 -1
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/adb/ADBCaptureMethod.py +1 -18
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/adb/DeviceManager.py +80 -26
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/task/TaskExecutor.py +1 -1
- {ok-script-0.0.97 → ok-script-0.0.99}/ok_script.egg-info/PKG-INFO +1 -1
- {ok-script-0.0.97 → ok-script-0.0.99}/setup.py +1 -1
- {ok-script-0.0.97 → ok-script-0.0.99}/README.md +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/OK.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/alas/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/alas/emulator_base.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/alas/emulator_windows.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/alas/platform_base.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/alas/platform_windows.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/alas/utils.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/BaseCaptureMethod.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/HwndWindow.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/adb/WindowsCaptureFactory.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/image/ImageCaptureMethod.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/image/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/BaseWindowsCaptureMethod.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/BitBltCaptureMethod.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/DesktopDuplicationCaptureMethod.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/dump.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/color/Color.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/color/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/config/Config.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/config/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/feature/Box.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/feature/CompressCoco.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/feature/FeatureSet.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/feature/FindFeature.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/firebase/Analytics.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/firebase/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/App.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/Communicate.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/MainWindow.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/MessageWindow.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/StartController.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/about/HttpTextEdit.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/about/VersionCard.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/DebugTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/FrameWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/LogWindow.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/Screenshot.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/overlay/OverlayWindow.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/resources.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/start/StartCard.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/OneTimeTaskTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/TaskCard.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/TaskTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/EmptyCard.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/StartLoadingDialog.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/interaction/ADBInteraction.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/interaction/BaseInteraction.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/interaction/DoNothingInteraction.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/interaction/Win32Interaction.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/logging/Logger.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/ocr/OCR.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Media/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Security/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Storage/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/save/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/scene/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/stats/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/task/BaseTask.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/task/ExecutorOperation.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/task/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/update/GithubMultiDownloader.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/update/Updater.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/update/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/update/gen_md5.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/Handler.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/exit_event.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/json.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/list.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/path.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/thread.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok/util/yaml.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok_script.egg-info/SOURCES.txt +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/setup.cfg +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/tests/__init__.py +0 -0
- {ok-script-0.0.97 → ok-script-0.0.99}/tests/test_updater.py +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# original https://github.com/Toufool/AutoSplit/blob/master/src/capture_method/WindowsGraphicsCaptureMethod.py
|
|
2
|
-
import cv2
|
|
3
2
|
import numpy as np
|
|
4
3
|
from typing_extensions import override
|
|
5
4
|
|
|
@@ -26,7 +25,7 @@ class ADBCaptureMethod(BaseCaptureMethod):
|
|
|
26
25
|
def screencap(self):
|
|
27
26
|
if self.exit_event.is_set():
|
|
28
27
|
return None
|
|
29
|
-
frame = do_screencap(self.device_manager.device)
|
|
28
|
+
frame = self.device_manager.do_screencap(self.device_manager.device)
|
|
30
29
|
if frame is not None:
|
|
31
30
|
self._connected = True
|
|
32
31
|
else:
|
|
@@ -37,19 +36,3 @@ class ADBCaptureMethod(BaseCaptureMethod):
|
|
|
37
36
|
if not self._connected and self.device_manager.device is not None:
|
|
38
37
|
self.screencap()
|
|
39
38
|
return self._connected and self.device_manager.device is not None
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def do_screencap(device) -> np.ndarray | None:
|
|
43
|
-
if device is None:
|
|
44
|
-
return None
|
|
45
|
-
try:
|
|
46
|
-
png_bytes = device.shell("screencap -p", encoding=None)
|
|
47
|
-
if png_bytes is not None and len(png_bytes) > 0:
|
|
48
|
-
image_data = np.frombuffer(png_bytes, dtype=np.uint8)
|
|
49
|
-
image = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
|
|
50
|
-
if image is not None:
|
|
51
|
-
return image
|
|
52
|
-
else:
|
|
53
|
-
logger.error(f"Screencap image decode error, probably disconnected")
|
|
54
|
-
except Exception as e:
|
|
55
|
-
logger.error('screencap', e)
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
import threading
|
|
3
|
+
|
|
4
|
+
import cv2
|
|
5
|
+
import numpy as np
|
|
6
|
+
from adbutils import AdbError
|
|
2
7
|
|
|
3
8
|
from ok.alas.platform_windows import get_emulator_exe
|
|
4
9
|
from ok.capture.HwndWindow import HwndWindow, find_hwnd
|
|
5
|
-
from ok.capture.adb.ADBCaptureMethod import ADBCaptureMethod
|
|
10
|
+
from ok.capture.adb.ADBCaptureMethod import ADBCaptureMethod
|
|
6
11
|
from ok.capture.adb.WindowsCaptureFactory import update_capture_method
|
|
7
12
|
from ok.config.Config import Config
|
|
8
13
|
from ok.gui.Communicate import communicate
|
|
@@ -19,6 +24,7 @@ class DeviceManager:
|
|
|
19
24
|
def __init__(self, app_config, exit_event=None):
|
|
20
25
|
self._device = None
|
|
21
26
|
self._adb = None
|
|
27
|
+
self._adb_lock = threading.Lock()
|
|
22
28
|
supported_resolution = app_config.get(
|
|
23
29
|
'supported_resolution', {})
|
|
24
30
|
self.supported_ratio = parse_ratio(supported_resolution.get('ratio'))
|
|
@@ -47,11 +53,39 @@ class DeviceManager:
|
|
|
47
53
|
|
|
48
54
|
@property
|
|
49
55
|
def adb(self):
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
with self._adb_lock:
|
|
57
|
+
if self._adb is None:
|
|
58
|
+
import adbutils
|
|
59
|
+
logger.debug(f'init adb')
|
|
60
|
+
from adbutils._utils import _get_bin_dir
|
|
61
|
+
bin_dir = _get_bin_dir()
|
|
62
|
+
exe = os.path.join(bin_dir, "adb.exe" if os.name == 'nt' else 'adb')
|
|
63
|
+
from adbutils._utils import _is_valid_exe
|
|
64
|
+
if os.path.isfile(exe) and _is_valid_exe(exe):
|
|
65
|
+
os.environ['ADBUTILS_ADB_PATH'] = exe
|
|
66
|
+
logger.info(f'set ADBUTILS_ADB_PATH {os.getenv("ADBUTILS_ADB_PATH")}')
|
|
67
|
+
else:
|
|
68
|
+
logger.error(f'set ADBUTILS_ADB_PATH failed {exe}')
|
|
69
|
+
self._adb = adbutils.AdbClient(host="127.0.0.1", socket_timeout=4)
|
|
70
|
+
try:
|
|
71
|
+
self._adb.device_list()
|
|
72
|
+
except AdbError as e:
|
|
73
|
+
self.try_kill_adb(e)
|
|
74
|
+
return self._adb
|
|
75
|
+
|
|
76
|
+
def try_kill_adb(self, e=None):
|
|
77
|
+
logger.error('try kill adb server', e)
|
|
78
|
+
import psutil
|
|
79
|
+
for proc in psutil.process_iter():
|
|
80
|
+
# Check whether the process name matches
|
|
81
|
+
if proc.name() == 'adb.exe' or proc.name() == 'adb':
|
|
82
|
+
logger.info(f'kill adb by process name {proc.cmdline()}')
|
|
83
|
+
try:
|
|
84
|
+
proc.kill()
|
|
85
|
+
except Exception as e:
|
|
86
|
+
logger.error(f'kill adb server failed', e)
|
|
87
|
+
logger.info('try kill adb end')
|
|
88
|
+
# self._adb.server_kill()
|
|
55
89
|
|
|
56
90
|
def adb_connect(self, addr, try_connect=True):
|
|
57
91
|
try:
|
|
@@ -67,11 +101,12 @@ class DeviceManager:
|
|
|
67
101
|
logger.debug(f'adb_connect already connected {addr}')
|
|
68
102
|
return device
|
|
69
103
|
if try_connect:
|
|
70
|
-
self.adb.connect(addr, timeout=
|
|
104
|
+
self.adb.connect(addr, timeout=5)
|
|
71
105
|
logger.debug(f'adb_connect {addr}')
|
|
72
106
|
return self.adb_connect(addr, try_connect=False)
|
|
73
|
-
except
|
|
74
|
-
logger.error(f"adb connect error
|
|
107
|
+
except AdbError as e:
|
|
108
|
+
logger.error(f"adb connect error {addr}", e)
|
|
109
|
+
self.try_kill_adb(e)
|
|
75
110
|
except Exception as e:
|
|
76
111
|
logger.error(f"adb connect error return none {addr}", e)
|
|
77
112
|
|
|
@@ -165,7 +200,7 @@ class DeviceManager:
|
|
|
165
200
|
if device is not None:
|
|
166
201
|
if resolution := self.resolution_dict.get(device.serial):
|
|
167
202
|
return resolution
|
|
168
|
-
frame = do_screencap(device)
|
|
203
|
+
frame = self.do_screencap(device)
|
|
169
204
|
if frame is not None:
|
|
170
205
|
height, width, _ = frame.shape
|
|
171
206
|
if self.supported_ratio is None or abs(width / height - self.supported_ratio) < 0.01:
|
|
@@ -199,15 +234,43 @@ class DeviceManager:
|
|
|
199
234
|
self.start()
|
|
200
235
|
logger.debug(f'preferred device: {preferred}')
|
|
201
236
|
|
|
202
|
-
|
|
203
|
-
|
|
237
|
+
def shell_device(self, device, *args, **kwargs):
|
|
238
|
+
kwargs.setdefault('timeout', 5)
|
|
204
239
|
try:
|
|
205
|
-
return device.shell(
|
|
206
|
-
|
|
240
|
+
return device.shell(*args, **kwargs)
|
|
241
|
+
except AdbError as e:
|
|
242
|
+
logger.error(f"adb shell AdbError try kill server {device}", e)
|
|
243
|
+
self.try_kill_adb(e)
|
|
244
|
+
addr = self.get_preferred_device()['address']
|
|
245
|
+
self.refresh_emulators()
|
|
246
|
+
self.refresh_phones()
|
|
247
|
+
new_addr = self.get_preferred_device()['address']
|
|
248
|
+
logger.error(f"shell_wrapper error occurred, try refresh_emulators {addr} {new_addr}", e)
|
|
249
|
+
device = self.adb_connect(device.serial)
|
|
250
|
+
return device.shell(*args, **kwargs)
|
|
207
251
|
except Exception as e:
|
|
208
|
-
logger.error(f"
|
|
252
|
+
logger.error(f"adb shell error maybe offline {device}", e)
|
|
209
253
|
return None
|
|
210
254
|
|
|
255
|
+
def adb_get_imei(self, device):
|
|
256
|
+
return (self.shell_device(device, "settings get secure android_id") or
|
|
257
|
+
self.shell_device(device, "service call iphonesubinfo 4") or device.prop.model)
|
|
258
|
+
|
|
259
|
+
def do_screencap(self, device) -> np.ndarray | None:
|
|
260
|
+
if device is None:
|
|
261
|
+
return None
|
|
262
|
+
try:
|
|
263
|
+
png_bytes = self.shell_device(device, "screencap -p", encoding=None)
|
|
264
|
+
if png_bytes is not None and len(png_bytes) > 0:
|
|
265
|
+
image_data = np.frombuffer(png_bytes, dtype=np.uint8)
|
|
266
|
+
image = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
|
|
267
|
+
if image is not None:
|
|
268
|
+
return image
|
|
269
|
+
else:
|
|
270
|
+
logger.error(f"Screencap image decode error, probably disconnected")
|
|
271
|
+
except Exception as e:
|
|
272
|
+
logger.error('screencap', e)
|
|
273
|
+
|
|
211
274
|
def get_preferred_device(self):
|
|
212
275
|
imei = self.config.get("preferred")
|
|
213
276
|
preferred = self.device_dict.get(imei)
|
|
@@ -332,19 +395,10 @@ class DeviceManager:
|
|
|
332
395
|
|
|
333
396
|
def shell(self, *args, **kwargs):
|
|
334
397
|
# Set default timeout to 5 if not provided
|
|
335
|
-
kwargs.setdefault('timeout', 5)
|
|
336
398
|
|
|
337
399
|
device = self.device
|
|
338
400
|
if device is not None:
|
|
339
|
-
|
|
340
|
-
return device.shell(*args, **kwargs)
|
|
341
|
-
except AdbError as e:
|
|
342
|
-
logger.debug(f'shell adb error {args} {e}')
|
|
343
|
-
except Exception as e:
|
|
344
|
-
addr = self.get_preferred_device()['address']
|
|
345
|
-
self.refresh_emulators()
|
|
346
|
-
new_addr = self.get_preferred_device()['address']
|
|
347
|
-
logger.error(f"shell_wrapper error occurred, try refresh_emulators {addr} {new_addr}", e)
|
|
401
|
+
return self.shell_device(device, *args, **kwargs)
|
|
348
402
|
else:
|
|
349
403
|
raise Exception('Device is none')
|
|
350
404
|
|
|
@@ -148,7 +148,7 @@ class TaskExecutor:
|
|
|
148
148
|
time.sleep(1)
|
|
149
149
|
if self.exit_event.is_set():
|
|
150
150
|
logger.info("Exit event set. Exiting early.")
|
|
151
|
-
|
|
151
|
+
raise FinishedException("Exit event set. Exiting early.")
|
|
152
152
|
if self._frame is None:
|
|
153
153
|
return self.next_frame()
|
|
154
154
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ok-script-0.0.97 → ok-script-0.0.99}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|