Selaa lähdekoodia

feat(config): 5.18

runhey 3 vuotta sitten
vanhempi
sitoutus
74a27d6fe4

+ 9 - 1
README.md

@@ -6,4 +6,12 @@
 
 - ui使用这个库[FluentUI for QML](https://github.com/zhuzichu520/FluentUI), 个人发觉alas的设计思路很不错
 - 按照alas的部署 更新方式
-- ocr使用paddleocr因为cnocr对于python3.10的支持有一些问题
+- ocr使用paddleocr因为cnocr对于python3.10的支持有一些问题
+
+
+
+- 2023.5.17
+
+ui库目前还没完善,先做device
+
+![image-20230517184432630](https://runhey-img-stg1.oss-cn-chengdu.aliyuncs.com/img2/202305171844003.png)

BIN
bin/droidcast/DroidCast-debug-1.1.0.apk


BIN
bin/droidcast/DroidCastS-release-1.1.5.apk


BIN
bin/hermit/hermit.apk


+ 33 - 0
deploy/launcher/oas-gui.bat

@@ -1,3 +1,36 @@
+::[Bat To Exe Converter]
+::
+::YAwzoRdxOk+EWAjk
+::fBw5plQjdCyDJGyX8VAjFJOkoIxy0O5J9Ik47fvw++WXnkESU+1xcYzUug==
+::YAwzuBVtJxjWCl3EqQJgSA==
+::ZR4luwNxJguZRRnk
+::Yhs/ulQjdF+5
+::cxAkpRVqdFKZSDk=
+::cBs/ulQjdF+5
+::ZR41oxFsdFKZSDk=
+::eBoioBt6dFKZSDk=
+::cRo6pxp7LAbNWATEpCI=
+::egkzugNsPRvcWATEpCI=
+::dAsiuh18IRvcCxnZtBJQ
+::cRYluBh/LU+EWAnk
+::YxY4rhs+aU+JeA==
+::cxY6rQJ7JhzQF1fEqQJQ
+::ZQ05rAF9IBncCkqN+0xwdVs0
+::ZQ05rAF9IAHYFVzEqQJQ
+::eg0/rx1wNQPfEVWB+kM9LVsJDGQ=
+::fBEirQZwNQPfEVWB+kM9LVsJDGQ=
+::cRolqwZ3JBvQF1fEqQJQ
+::dhA7uBVwLU+EWDk=
+::YQ03rBFzNR3SWATElA==
+::dhAmsQZ3MwfNWATElA==
+::ZQ0/vhVqMQ3MEVWAtB9wSA==
+::Zg8zqx1/OA3MEVWAtB9wSA==
+::dhA7pRFwIByZRRnk
+::Zh4grVQjdCyDJGyX8VAjFJOkoIxy0O5J9Ik47fvw++WXnkIcR6w6YIq7
+::YB416Ek+ZG8=
+::
+::
+::978f952a14a936cc963da21a135fa983
 @rem
 @echo off
 

+ 50 - 0
module/base/decorator.py

@@ -0,0 +1,50 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from functools import wraps
+from typing import Callable, Generic, TypeVar
+
+T = TypeVar("T")
+
+class cached_property(Generic[T]):
+    """
+    cached-property from https://github.com/pydanny/cached-property
+    Add typing support
+
+    A property that is only computed once per instance and then replaces itself
+    with an ordinary attribute. Deleting the attribute resets the property.
+    Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
+    """
+
+    def __init__(self, func: Callable[..., T]):
+        self.func = func
+
+    def __get__(self, obj, cls) -> T:
+        if obj is None:
+            return self
+
+        value = obj.__dict__[self.func.__name__] = self.func(obj)
+        return value
+
+def del_cached_property(obj, name):
+    """
+    Delete a cached property safely.
+
+    Args:
+        obj:
+        name (str):
+    """
+    try:
+        del obj.__dict__[name]
+    except KeyError:
+        pass
+
+def has_cached_property(obj, name):
+    """
+    Check if a property is cached.
+
+    Args:
+        obj:
+        name (str):
+    """
+    return name in obj.__dict__

+ 164 - 0
module/base/timer.py

@@ -0,0 +1,164 @@
+# This Python file uses the following encoding: utf-8
+
+import time
+from datetime import datetime, timedelta
+from functools import wraps
+
+
+def timer(function):
+    """
+    装饰器 打印函数时间时间
+    """
+    @wraps(function)
+    def function_timer(*args, **kwargs):
+        t0 = time.time()
+
+        result = function(*args, **kwargs)
+        t1 = time.time()
+        print('%s: %s s' % (function.__name__, str(round(t1 - t0, 10))))
+        return result
+
+    return function_timer
+
+
+def future_time(string):
+    """
+    Args:
+        string (str): Such as 14:59.
+
+    Returns:
+        datetime.datetime: Time with given hour, minute in the future.
+    """
+    hour, minute = [int(x) for x in string.split(':')]
+    future = datetime.now().replace(hour=hour, minute=minute, second=0, microsecond=0)
+    future = future + timedelta(days=1) if future < datetime.now() else future
+    return future
+
+
+def past_time(string):
+    """
+    Args:
+        string (str): Such as 14:59.
+
+    Returns:
+        datetime.datetime: Time with given hour, minute in the past.
+    """
+    hour, minute = [int(x) for x in string.split(':')]
+    past = datetime.now().replace(hour=hour, minute=minute, second=0, microsecond=0)
+    past = past - timedelta(days=1) if past > datetime.now() else past
+    return past
+
+
+def future_time_range(string):
+    """
+    Args:
+        string (str): Such as 23:30-06:30.
+
+    Returns:
+        tuple(datetime.datetime): (time start, time end).
+    """
+    start, end = [future_time(s) for s in string.split('-')]
+    if start > end:
+        start = start - timedelta(days=1)
+    return start, end
+
+
+def time_range_active(time_range):
+    """
+    Args:
+        time_range(tuple(datetime.datetime)): (time start, time end).
+
+    Returns:
+        bool:
+    """
+    return time_range[0] < datetime.now() < time_range[1]
+
+
+class Timer:
+    def __init__(self, limit, count=0):
+        """
+        Args:
+            limit (int, float): Timer limit
+            count (int): Timer reach confirm count. Default to 0.
+                When using a structure like this, must set a count.
+                Otherwise it goes wrong, if screenshot time cost greater than limit.
+
+                if self.appear(MAIN_CHECK):
+                    if confirm_timer.reached():
+                        pass
+                else:
+                    confirm_timer.reset()
+
+                Also, It's a good idea to set `count`, to make alas run more stable on slow computers.
+                Expected speed is 0.35 second / screenshot.
+        """
+        self.limit = limit
+        self.count = count
+        self._current = 0
+        self._reach_count = count
+
+    def start(self):
+        if not self.started():
+            self._current = time.time()
+            self._reach_count = 0
+
+        return self
+
+    def started(self):
+        return bool(self._current)
+
+    def current(self):
+        """
+        Returns:
+            float
+        """
+        if self.started():
+            return time.time() - self._current
+        else:
+            return 0.
+
+    def reached(self):
+        """
+        Returns:
+            bool
+        """
+        self._reach_count += 1
+        return time.time() - self._current > self.limit and self._reach_count > self.count
+
+    def reset(self):
+        self._current = time.time()
+        self._reach_count = 0
+        return self
+
+    def clear(self):
+        self._current = 0
+        self._reach_count = self.count
+        return self
+
+    def reached_and_reset(self):
+        """
+        Returns:
+            bool:
+        """
+        if self.reached():
+            self.reset()
+            return True
+        else:
+            return False
+
+    def wait(self):
+        """
+        Wait until timer reached.
+        """
+        diff = self._current + self.limit - time.time()
+        if diff > 0:
+            time.sleep(diff)
+
+    def show(self):
+        from module.logger import logger
+        logger.info(str(self))
+
+    def __str__(self):
+        return f'Timer(limit={round(self.current(), 3)}/{self.limit}, count={self._reach_count}/{self.count})'
+
+    __repr__ = __str__

+ 20 - 0
module/config/config.py

@@ -0,0 +1,20 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import copy
+import datetime
+import operator
+import threading
+
+from module.config.config_updater import ConfigUpdater
+from module.config.config_manual import ConfigManual
+from module.config.config_watcher import ConfigWatcher
+from module.config.utils import *
+
+from module.logger import logger
+
+class Config(ConfigManual, ConfigWatcher, ConfigUpdater):
+    """
+    一个配置文件的集成类
+    """
+    pass

+ 27 - 0
module/config/config_manual.py

@@ -0,0 +1,27 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+class ConfigManual:
+    """
+    module.device
+    """
+    DEVICE_OVER_HTTP = False
+    FORWARD_PORT_RANGE = (20000, 21000)
+    REVERSE_SERVER_PORT = 7903
+
+    # ASCREENCAP_FILEPATH_LOCAL = './bin/ascreencap'
+    # ASCREENCAP_FILEPATH_REMOTE = '/data/local/tmp/ascreencap'
+
+    # 'DroidCast', 'DroidCast_raw'
+    DROIDCAST_VERSION = 'DroidCast'
+    DROIDCAST_FILEPATH_LOCAL = './bin/droidcast/DroidCast-debug-1.1.0.apk'
+    DROIDCAST_FILEPATH_REMOTE = '/data/local/tmp/DroidCast.apk'
+    DROIDCAST_RAW_FILEPATH_LOCAL = './bin/droidcast/DroidCastS-release-1.1.5.apk'
+    DROIDCAST_RAW_FILEPATH_REMOTE = '/data/local/tmp/DroidCastS.apk'
+
+    MINITOUCH_FILEPATH_REMOTE = '/data/local/tmp/minitouch'
+
+    HERMIT_FILEPATH_LOCAL = './bin/hermit/hermit.apk'
+
+

+ 3 - 0
module/config/config_server.py

@@ -0,0 +1,3 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey

+ 31 - 0
module/config/config_updater.py

@@ -0,0 +1,31 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import re
+from copy import deepcopy
+
+from cached_property import cached_property
+
+from deploy.utils import DEPLOY_TEMPLATE, poor_yaml_read, poor_yaml_write
+from module.base.timer import timer
+from module.config.utils import *
+
+class ConfigUpdater:
+
+    @timer
+    def update_template(self, template_name: str = "template") -> None:
+        """
+        更新模板 。从args.json更新
+        :param template_name:
+        :return:
+        """
+        pass
+
+    @timer
+    def update_config(self, config_name: str ) -> None:
+        """
+        更新配置文件.从template更新
+        :param config_name:
+        :return:
+        """
+        pass

+ 42 - 0
module/config/config_watcher.py

@@ -0,0 +1,42 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import os
+from datetime import datetime
+
+from module.config.utils import filepath_config, DEFAULT_TIME
+from module.logger import logger
+
+class ConfigWatcher:
+    """
+    监视特定配置文件修改的功能。
+    它跟踪了初始修改时间,(start_mtime)
+    并提供了方法来检查文件是否被修改(should_reload)
+    和获取当前修改时间(get_mtime)。
+    """
+    config_name = 'script'
+    start_mtime = DEFAULT_TIME
+
+    def start_watching(self) -> None:
+        self.start_mtime = self.get_mtime()
+
+    def get_mtime(self) -> datetime:
+        """
+        Last modify time of the file
+        """
+        timestamp = os.stat(filepath_config(self.config_name)).st_mtime
+        mtime = datetime.fromtimestamp(timestamp).replace(microsecond=0)
+        return mtime
+
+    def should_reload(self) -> bool:
+        """
+        Returns:
+            bool: Whether the file has been modified and configs should reload
+        """
+        mtime = self.get_mtime()
+        if mtime > self.start_mtime:
+            logger.info(f'Config "{self.config_name}" changed at {mtime}')
+            return True
+        else:
+            return False
+

+ 17 - 0
module/config/utils.py

@@ -0,0 +1,17 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+import os
+
+from datetime import datetime, timedelta, timezone
+
+DEFAULT_TIME = datetime(2023, 1, 1, 0, 0)
+
+def filepath_config(filename, mod_name='script') -> str:
+    """
+    返回配置文件的路径
+    """
+    if mod_name == 'script':
+        return os.path.join('./config', f'{filename}.json')
+    else:
+        return os.path.join('./config', f'{filename}.{mod_name}.json')

+ 6 - 0
module/device/device.py

@@ -0,0 +1,6 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+class Device:
+    pass

+ 357 - 0
module/logger.py

@@ -1,3 +1,360 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+import datetime
+import logging
+import os
+import sys
+from typing import Callable, List
+
+from rich.console import Console, ConsoleOptions, ConsoleRenderable, NewLine
+from rich.highlighter import RegexHighlighter, NullHighlighter
+from rich.logging import RichHandler
+from rich.rule import Rule
+from rich.style import Style
+from rich.theme import Theme
+from rich.traceback import Traceback
+
+
+def empty_function(*args, **kwargs):
+    pass
+
+
+# cnocr will set root logger in cnocr.utils
+# Delete logging.basicConfig to avoid logging the same message twice.
+logging.basicConfig = empty_function
+logging.raiseExceptions = True  # Set True if wanna see encode errors on console
+
+# Remove HTTP keywords (GET, POST etc.)
+RichHandler.KEYWORDS = []
+
+
+class RichFileHandler(RichHandler):
+    # Rename
+    pass
+
+
+class RichRenderableHandler(RichHandler):
+    """
+    Pass renderable into a function
+    """
+
+    def __init__(self, *args, func: Callable[[ConsoleRenderable], None] = None, **kwargs):
+        super().__init__(*args, **kwargs)
+        self._func = func
+
+    def emit(self, record: logging.LogRecord) -> None:
+        message = self.format(record)
+        traceback = None
+        if (
+            self.rich_tracebacks
+            and record.exc_info
+            and record.exc_info != (None, None, None)
+        ):
+            exc_type, exc_value, exc_traceback = record.exc_info
+            assert exc_type is not None
+            assert exc_value is not None
+            traceback = Traceback.from_exception(
+                exc_type,
+                exc_value,
+                exc_traceback,
+                width=self.tracebacks_width,
+                extra_lines=self.tracebacks_extra_lines,
+                theme=self.tracebacks_theme,
+                word_wrap=self.tracebacks_word_wrap,
+                show_locals=self.tracebacks_show_locals,
+                locals_max_length=self.locals_max_length,
+                locals_max_string=self.locals_max_string,
+            )
+            message = record.getMessage()
+            if self.formatter:
+                record.message = record.getMessage()
+                formatter = self.formatter
+                if hasattr(formatter, "usesTime") and formatter.usesTime():
+                    record.asctime = formatter.formatTime(
+                        record, formatter.datefmt)
+                message = formatter.formatMessage(record)
+
+        message_renderable = self.render_message(record, message)
+        log_renderable = self.render(
+            record=record, traceback=traceback, message_renderable=message_renderable
+        )
+
+        # Directly put renderable into function
+        self._func(log_renderable)
+
+    def handle(self, record: logging.LogRecord) -> bool:
+        if not self._func:
+            return True
+        super().handle(record)
+
+
+class HTMLConsole(Console):
+    """
+    Force full feature console
+    but not working lol :(
+    """
+    @property
+    def options(self) -> ConsoleOptions:
+        return ConsoleOptions(
+            max_height=self.size.height,
+            size=self.size,
+            legacy_windows=False,
+            min_width=1,
+            max_width=self.width,
+            encoding='utf-8',
+            is_terminal=False,
+        )
+
+
+class Highlighter(RegexHighlighter):
+    base_style = 'web.'
+    highlights = [
+        # (r'(?P<datetime>(\d{2}|\d{4})(?:\-)?([0]{1}\d{1}|[1]{1}[0-2]{1})'
+        #  r'(?:\-)?([0-2]{1}\d{1}|[3]{1}[0-1]{1})(?:\s)?([0-1]{1}\d{1}|'
+        #  r'[2]{1}[0-3]{1})(?::)?([0-5]{1}\d{1})(?::)?([0-5]{1}\d{1}).\d+\b)'),
+        (r'(?P<time>([0-1]{1}\d{1}|[2]{1}[0-3]{1})(?::)?'
+         r'([0-5]{1}\d{1})(?::)?([0-5]{1}\d{1})(.\d+\b))'),
+        r"(?P<brace>[\{\[\(\)\]\}])",
+        r"\b(?P<bool_true>True)\b|\b(?P<bool_false>False)\b|\b(?P<none>None)\b",
+        r"(?P<path>(([A-Za-z]\:)|.)?\B([\/\\][\w\.\-\_\+]+)*[\/\\])(?P<filename>[\w\.\-\_\+]*)?",
+        # r"(?<![\\\w])(?P<str>b?\'\'\'.*?(?<!\\)\'\'\'|b?\'.*?(?<!\\)\'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
+    ]
+
+
+WEB_THEME = Theme({
+    "web.brace": Style(bold=True),
+    "web.bool_true": Style(color="bright_green", italic=True),
+    "web.bool_false": Style(color="bright_red", italic=True),
+    "web.none": Style(color="magenta", italic=True),
+    "web.path": Style(color="magenta"),
+    "web.filename": Style(color="bright_magenta"),
+    "web.str": Style(color="green", italic=False, bold=False),
+    "web.time": Style(color="cyan"),
+    "rule.text": Style(bold=True),
+})
+
+
+# Logger init
+logger_debug = False
+logger = logging.getLogger('alas')
+logger.setLevel(logging.DEBUG if logger_debug else logging.INFO)
+file_formatter = logging.Formatter(
+    fmt='%(asctime)s.%(msecs)03d | %(levelname)s | %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+console_formatter = logging.Formatter(
+    fmt='%(asctime)s.%(msecs)03d │ %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+web_formatter = logging.Formatter(
+    fmt='%(asctime)s.%(msecs)03d │ %(message)s', datefmt='%H:%M:%S')
+
+# Add console logger
+# console = logging.StreamHandler(stream=sys.stdout)
+# console.setFormatter(formatter)
+# console.flush = sys.stdout.flush
+# logger.addHandler(console)
+
+# Add rich console logger
+stdout_console = console = Console()
+console_hdlr = RichHandler(
+    show_path=False,
+    show_time=False,
+    rich_tracebacks=True,
+    tracebacks_show_locals=True,
+    tracebacks_extra_lines=3,
+)
+console_hdlr.setFormatter(console_formatter)
+logger.addHandler(console_hdlr)
+
+# Ensure running in Alas root folder
+os.chdir(os.path.join(os.path.dirname(__file__), '../'))
+
+# Add file logger
+pyw_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
+
+
+def _set_file_logger(name=pyw_name):
+    if '_' in name:
+        name = name.split('_', 1)[0]
+    log_file = f'./log/{datetime.date.today()}_{name}.txt'
+    try:
+        file = logging.FileHandler(log_file, encoding='utf-8')
+    except FileNotFoundError:
+        os.mkdir('./log')
+        file = logging.FileHandler(log_file, encoding='utf-8')
+    file.setFormatter(file_formatter)
+
+    logger.handlers = [h for h in logger.handlers if not isinstance(
+        h, (logging.FileHandler, RichFileHandler))]
+    logger.addHandler(file)
+    logger.log_file = log_file
+
+
+def set_file_logger(name=pyw_name):
+    if '_' in name:
+        name = name.split('_', 1)[0]
+    log_file = f'./log/{datetime.date.today()}_{name}.txt'
+    try:
+        file = open(log_file, mode='a', encoding='utf-8')
+    except FileNotFoundError:
+        os.mkdir('./log')
+        file = open(log_file, mode='a', encoding='utf-8')
+
+    file_console = Console(
+        file=file,
+        no_color=True,
+        highlight=False,
+        width=119,
+    )
+
+    hdlr = RichFileHandler(
+        console=file_console,
+        show_path=False,
+        show_time=False,
+        show_level=False,
+        rich_tracebacks=True,
+        tracebacks_show_locals=True,
+        tracebacks_extra_lines=3,
+        highlighter=NullHighlighter(),
+    )
+    hdlr.setFormatter(file_formatter)
+
+    logger.handlers = [h for h in logger.handlers if not isinstance(
+        h, (logging.FileHandler, RichFileHandler))]
+    logger.addHandler(hdlr)
+    logger.log_file = log_file
+
+
+def set_func_logger(func):
+    console = HTMLConsole(
+        force_terminal=False,
+        force_interactive=False,
+        width=80,
+        color_system='truecolor',
+        markup=False,
+        safe_box=False,
+        highlighter=Highlighter(),
+        theme=WEB_THEME
+    )
+    hdlr = RichRenderableHandler(
+        func=func,
+        console=console,
+        show_path=False,
+        show_time=False,
+        show_level=True,
+        rich_tracebacks=True,
+        tracebacks_show_locals=True,
+        tracebacks_extra_lines=2,
+        highlighter=Highlighter(),
+    )
+    hdlr.setFormatter(web_formatter)
+    logger.handlers = [h for h in logger.handlers if not isinstance(
+        h, RichRenderableHandler)]
+    logger.addHandler(hdlr)
+
+
+def _get_renderables(
+    self: Console, *objects, sep=" ", end="\n", justify=None, emoji=None, markup=None, highlight=None,
+) -> List[ConsoleRenderable]:
+    """
+    Refer to rich.console.Console.print()
+    """
+    if not objects:
+        objects = (NewLine(),)
+
+    render_hooks = self._render_hooks[:]
+    with self:
+        renderables = self._collect_renderables(
+            objects,
+            sep,
+            end,
+            justify=justify,
+            emoji=emoji,
+            markup=markup,
+            highlight=highlight,
+        )
+        for hook in render_hooks:
+            renderables = hook.process_renderables(renderables)
+    return renderables
+
+
+def print(*objects: ConsoleRenderable, **kwargs):
+    for hdlr in logger.handlers:
+        if isinstance(hdlr, RichRenderableHandler):
+            for renderable in _get_renderables(hdlr.console, *objects, **kwargs):
+                hdlr._func(renderable)
+        elif isinstance(hdlr, RichHandler):
+            hdlr.console.print(*objects)
+
+
+def rule(title="", *, characters="─", style="rule.line", end="\n", align="center"):
+    rule = Rule(title=title, characters=characters,
+                style=style, end=end, align=align)
+    print(rule)
+
+
+def hr(title, level=3):
+    title = str(title).upper()
+    if level == 1:
+        logger.rule(title, characters='═')
+        logger.info(title)
+    if level == 2:
+        logger.rule(title, characters='─')
+        logger.info(title)
+    if level == 3:
+        logger.info(f"[bold]<<< {title} >>>[/bold]", extra={"markup": True})
+    if level == 0:
+        logger.rule(characters='═')
+        logger.rule(title, characters=' ')
+        logger.rule(characters='═')
+
+
+def attr(name, text):
+    logger.info('[%s] %s' % (str(name), str(text)))
+
+
+def attr_align(name, text, front='', align=22):
+    name = str(name).rjust(align)
+    if front:
+        name = front + name[len(front):]
+    logger.info('%s: %s' % (name, str(text)))
+
+
+def show():
+    logger.info('INFO')
+    logger.warning('WARNING')
+    logger.debug('DEBUG')
+    logger.error('ERROR')
+    logger.critical('CRITICAL')
+    logger.hr('hr0', 0)
+    logger.hr('hr1', 1)
+    logger.hr('hr2', 2)
+    logger.hr('hr3', 3)
+    logger.info(r'Brace { [ ( ) ] }')
+    logger.info(r'True, False, None')
+    logger.info(r'E:/path\\to/alas/alas.exe, /root/alas/, ./relative/path/log.txt')
+    local_var1 = 'This is local variable'
+    # Line before exception
+    raise Exception("Exception")
+    # Line below exception
+
+
+def error_convert(func):
+    def error_wrapper(msg, *args, **kwargs):
+        if isinstance(msg, Exception):
+            msg = f'{type(msg).__name__}: {msg}'
+        return func(msg, *args, **kwargs)
+
+    return error_wrapper
+
+
+logger.error = error_convert(logger.error)
+logger.hr = hr
+logger.attr = attr
+logger.attr_align = attr_align
+logger.set_file_logger = set_file_logger
+logger.set_func_logger = set_func_logger
+logger.rule = rule
+logger.print = print
+logger.log_file: str
+
+logger.set_file_logger()
+logger.hr('Start', level=0)

+ 5 - 1
requirements-in.txt

@@ -1 +1,5 @@
-pyside6==6.4.3
+pyside6==6.4.3
+adbutils==1.2.9
+uiautomator2==2.16.23
+
+rich==13.3.5

+ 30 - 4
requirements.txt

@@ -7,9 +7,35 @@
 --index-url https://pypi.tuna.tsinghua.edu.cn/simple
 --trusted-host pypi.tuna.tsinghua.edu.cn
 
-click==8.1.3              # via -r requirements-in.txt
-colorama==0.4.6           # via click
+adbutils==1.2.9         # via -r requirements-in.txt, uiautomator2
+apkutils2==1.0.0          # via adbutils
+cached-property==1.5.2    # via uiautomator2
+certifi==2023.5.7         # via requests
+charset-normalizer==3.1.0  # via requests
+cigam==0.0.3              # via apkutils2
+colorama==0.4.6           # via logzero
+decorator==5.1.1          # via retry
+deprecated==1.2.13        # via uiautomator2
+deprecation==2.1.0        # via adbutils
+filelock==3.12.0          # via uiautomator2
+idna==3.4                 # via requests
+logzero==1.7.0            # via uiautomator2
+lxml==4.9.2               # via uiautomator2
+packaging==20.9           # via deprecation, uiautomator2
+pillow==9.5.0             # via uiautomator2
+progress==1.6             # via uiautomator2
+py==1.11.0                # via retry
+pyelftools==0.29          # via apkutils2
+pyparsing==3.0.9          # via packaging
 pyside6==6.4.3            # via -r requirements-in.txt
 pyside6-addons==6.4.3     # via pyside6
-pyside6-essentials==6.4.3  # via pyside6
-shiboken6==6.4.3          # via pyside6
+pyside6-essentials==6.4.3  # via pyside6, pyside6-addons
+requests==2.30.0          # via adbutils, uiautomator2
+retry==0.9.2              # via adbutils, uiautomator2
+shiboken6==6.4.3          # via pyside6, pyside6-addons, pyside6-essentials
+six==1.16.0               # via adbutils, uiautomator2
+uiautomator2==2.16.23     # via -r requirements-in.txt
+urllib3==2.0.2            # via requests
+whichcraft==0.6.1         # via adbutils, uiautomator2
+wrapt==1.15.0             # via deprecated
+xmltodict==0.13.0         # via apkutils2

+ 18 - 0
script.py

@@ -0,0 +1,18 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+
+from cached_property import cached_property
+
+from module.device.device import Device
+
+class Script:
+    def __init__(self, config_name: str ='oas') -> None:
+        self.config_name = config_name
+
+    @cached_property
+    def device(self) -> Device:
+        pass
+
+
+