Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requirements.txt文件abdutils版本错误 #55

Open
niuxd opened this issue Sep 2, 2021 · 0 comments
Open

requirements.txt文件abdutils版本错误 #55

niuxd opened this issue Sep 2, 2021 · 0 comments

Comments

@niuxd
Copy link

niuxd commented Sep 2, 2021

Centos7.9 python 3.7 nodejs 8系统运行提示:

File "/data/xxx/work/atxserver2-android-provider/device.py", line 155, in _install_apk
self._device.install(path, force=True)
TypeError: install() got an unexpected keyword argument 'force'

requirements.txt文件adbutils版本
adbutils>=0.8.1,<1.0
解决思路:
1修改代码依赖高版本
def _install_apk(self, path: str):
assert path, "Invalid %s" % path
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']:
logger.debug("%s already installed %s", self, path)
else:
print(info, ":", m.version_code, m.version_name)
logger.debug("%s install %s", self, path)
self._device.install(path, uninstall=True)
2.限制adbutils版本

adbutils 0.9.1
def install(self, apk_path: str, force: bool = False):
"""
sdk = self.getprop('ro.build.version.sdk')
sdk > 23 support -g

    Args:
        force (bool): uninstall package before install

    Raises:
        AdbInstallError
    """
    dst = "/data/local/tmp/tmp-{}.apk".format(int(time.time() * 1000))

    self.sync.push(apk_path, dst)
    if force:
        apk = apkutils2.APK(apk_path)
        package_name = apk.manifest.package_name
        self.uninstall(package_name)
    self.install_remote(dst, clean=True)

adbutils 0.11.0
def install(self,
path_or_url: str,
nolaunch: bool = False,
uninstall: bool = False,
silent: bool = False,
callback: typing.Callable[[str], None] = None):
"""
Install APK to device

    Args:
        path_or_url: local path or http url
        nolaunch: do not launch app after install
        uninstall: uninstall app before install
        silent: disable log message print
        callback: only two event now: <"BEFORE_INSTALL" | "FINALLY">
    
    Raises:
        AdbInstallError
    """
    if re.match(r"^https?://", path_or_url):
        resp = requests.get(path_or_url, stream=True)
        resp.raise_for_status()
        length = int(resp.headers.get("Content-Length", 0))
        r = ReadProgress(resp.raw, length)
        print("tmpfile path:", r.filepath())
    else:
        length = os.stat(path_or_url).st_size
        fd = open(path_or_url, "rb")
        r = ReadProgress(fd, length, source_path=path_or_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant