diff --git a/Dockerfile b/Dockerfile index d16d254..9520dd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3 +FROM python:3.8.10 RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - RUN apt-get install -y nodejs wget diff --git a/core/fetching.py b/core/fetching.py index 553a7f6..8f1b409 100644 --- a/core/fetching.py +++ b/core/fetching.py @@ -59,7 +59,7 @@ def get_stf_binaries() -> str: Tag 0.2, support to Android P Tag 0.3.0 use stf/@devicefarmer """ - version = "0.3.0" + version = "0.3.2" target_path = f"vendor/stf-binaries-{version}.zip" mirror_download( f"https://github.com/openatx/stf-binaries/archive/{version}.zip", diff --git a/core/utils.py b/core/utils.py index 3f1f759..27a2373 100644 --- a/core/utils.py +++ b/core/utils.py @@ -6,14 +6,19 @@ import re import socket import string +import settings + def current_ip(): - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect(("8.8.8.8", 80)) - ip = s.getsockname()[0] - s.close() - return ip + if settings.custom_agent_ip != "none": + return settings.custom_agent_ip + else: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect(("8.8.8.8", 80)) + ip = s.getsockname()[0] + s.close() + return ip def update_recursive(d: dict, u: dict) -> dict: diff --git a/device.py b/device.py index 59190c8..5b5404d 100644 --- a/device.py +++ b/device.py @@ -86,7 +86,7 @@ def _init_binaries(self): stf_zippath = fetching.get_stf_binaries() zip_folder, _ = os.path.splitext(os.path.basename(stf_zippath)) - prefix = zip_folder + "/node_modules/@devicefarmer/minicap-prebuilt/prebuilt/" + prefix = zip_folder + "/node_modules/minicap-prebuilt/prebuilt/" self._push_stf(prefix + abi + "/lib/android-" + sdk + "/minicap.so", "/data/local/tmp/minicap.so", mode=0o644, @@ -146,13 +146,17 @@ def _install_apk(self, path: str): try: m = apkutils.APK(path).manifest info = self._device.package_info(m.package_name) - if info and m.version_code == info[ - 'version_code'] and m.version_name == info['version_name']: + if info and str(m.version_code) == str(info[ + 'version_code']) and m.version_name == info['version_name']: logger.debug("%s already installed %s", self, path) + elif info and info['version_name'] == None : + logger.debug(f"{info}, : {m.version_code}, {m.version_name}") + logger.debug("Unable to get apk version,skip to install") + return else: - print(info, ":", m.version_code, m.version_name) + logger.debug(f"{info}, : {m.version_code}, {m.version_name}") logger.debug("%s install %s", self, path) - self._device.install(path, force=True) + self._device.install(path) except Exception as e: traceback.print_exc() logger.warning("%s Install apk %s error %s", self, path, e) diff --git a/main.py b/main.py index c93db2a..6361e65 100755 --- a/main.py +++ b/main.py @@ -287,10 +287,12 @@ async def async_main(): parser.add_argument("--atx-agent-version", default=u2.version.__atx_agent_version__, help="set atx-agent version") parser.add_argument("--owner", type=str, help="provider owner email") parser.add_argument("--owner-file", type=argparse.FileType("r"), help="provider owner email from file") + parser.add_argument("--custom-agent-ip", default='none', help="custom agent ip address") args = parser.parse_args() # yapf: enable settings.atx_agent_version = args.atx_agent_version + settings.custom_agent_ip = args.custom_agent_ip owner_email = args.owner if args.owner_file: @@ -307,6 +309,7 @@ async def async_main(): logger.info("Ret: %s", ret) return + # start local server provider_url = "http://" + current_ip() + ":" + str(args.port) app = make_app() diff --git a/requirements.txt b/requirements.txt index f29c705..6221619 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ logzero==1.5.* -adbutils>=0.8.1,<1.0 +adbutils==2.8.5 tornado requests apkutils2 -uiautomator2>=2.5.9 +uiautomator2==2.16.26 humanize diff --git a/settings.py b/settings.py index d939dee..3f2fc55 100644 --- a/settings.py +++ b/settings.py @@ -2,3 +2,5 @@ # atx_agent_version = "" # set from command line + +custom_agent_ip = "" # set from command line