mirror of
https://gitee.com/openharmony/testfwk_xdevice
synced 2024-11-23 15:30:13 +00:00
update extension/src/xdevice_extension/_core/testkit/kit.py.
Signed-off-by: <hejian3@huawei.com>
This commit is contained in:
parent
9041b0caac
commit
0bc3f839c2
@ -152,15 +152,7 @@ class PushKit(ITestKit):
|
|||||||
LOG.warning(error, error_no=error.error_no)
|
LOG.warning(error, error_no=error.error_no)
|
||||||
continue
|
continue
|
||||||
remount(device)
|
remount(device)
|
||||||
device.push_file(real_src_path, dst)
|
device.hdc_command("file send {} {}".format(real_src_path, dst))
|
||||||
if os.path.isdir(real_src_path):
|
|
||||||
self.add_pushed_dir(real_src_path, dst)
|
|
||||||
else:
|
|
||||||
if device.is_directory(dst):
|
|
||||||
self.pushed_file.append(
|
|
||||||
os.path.join(dst, os.path.basename(real_src_path)))
|
|
||||||
else:
|
|
||||||
self.pushed_file.append(dst)
|
|
||||||
LOG.debug("Push file finished from {} to {}".format(src, dst))
|
LOG.debug("Push file finished from {} to {}".format(src, dst))
|
||||||
for command in self.post_push:
|
for command in self.post_push:
|
||||||
run_command(device, command)
|
run_command(device, command)
|
||||||
@ -573,12 +565,13 @@ class AppInstallKit(ITestKit):
|
|||||||
LOG.error("The app file {} does not exist".format(app))
|
LOG.error("The app file {} does not exist".format(app))
|
||||||
continue
|
continue
|
||||||
if app_file.endswith(".hap"):
|
if app_file.endswith(".hap"):
|
||||||
self.install_hap(device, app_file)
|
# use app install command directly
|
||||||
|
device.hdc_command("app install {}".format(app_file))
|
||||||
else:
|
else:
|
||||||
result = device.install_package(
|
result = device.install_package(
|
||||||
app_file, get_install_args(
|
app_file, get_install_args(
|
||||||
device, app_file, self.ex_args))
|
device, app_file, self.ex_args))
|
||||||
if not result.startswith("Success"):
|
if not result or not result.startswith("Success"):
|
||||||
raise AppInstallError(
|
raise AppInstallError(
|
||||||
"Failed to install %s on %s. Reason:%s" %
|
"Failed to install %s on %s. Reason:%s" %
|
||||||
(app_file, device.__get_serial__(), result))
|
(app_file, device.__get_serial__(), result))
|
||||||
@ -591,10 +584,9 @@ class AppInstallKit(ITestKit):
|
|||||||
app_name = get_app_name(app)
|
app_name = get_app_name(app)
|
||||||
|
|
||||||
if app_name:
|
if app_name:
|
||||||
result = device.uninstall_package(app_name)
|
device.hdc_command("shell bm uninstall -n {}".
|
||||||
if not result or not result.startswith("Success"):
|
format(app_name))
|
||||||
LOG.warning("error uninstalling package %s %s" %
|
time.sleep(20)
|
||||||
(device.__get_serial__(), result))
|
|
||||||
else:
|
else:
|
||||||
LOG.warning("Can't find app_name for %s" % app)
|
LOG.warning("Can't find app_name for %s" % app)
|
||||||
if self.is_pri_app:
|
if self.is_pri_app:
|
||||||
@ -682,16 +674,9 @@ class AppInstallKit(ITestKit):
|
|||||||
|
|
||||||
|
|
||||||
def remount(device):
|
def remount(device):
|
||||||
device.enable_hdc_root()
|
|
||||||
cmd = "target mount" \
|
cmd = "target mount" \
|
||||||
if device.usb_type == DeviceConnectorType.hdc else "remount"
|
if device.usb_type == DeviceConnectorType.hdc else "remount"
|
||||||
device.hdc_command(cmd)
|
device.hdc_command(cmd)
|
||||||
device.execute_shell_command("remount")
|
|
||||||
device.execute_shell_command("mount -o rw,remount /cust")
|
|
||||||
device.execute_shell_command("mount -o rw,remount /product")
|
|
||||||
device.execute_shell_command("mount -o rw,remount /hw_product")
|
|
||||||
device.execute_shell_command("mount -o rw,remount /version")
|
|
||||||
device.execute_shell_command("mount -o rw,remount /%s" % "system")
|
|
||||||
|
|
||||||
|
|
||||||
def keep_screen_on(device):
|
def keep_screen_on(device):
|
||||||
@ -735,7 +720,7 @@ def run_command(device, command):
|
|||||||
elif command.strip() == "reboot-delay":
|
elif command.strip() == "reboot-delay":
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
stdout = device.execute_shell_command(command)
|
stdout = device.hdc_command("shell {}".format(command))
|
||||||
LOG.debug("Run command result: %s" % (stdout if stdout else ""))
|
LOG.debug("Run command result: %s" % (stdout if stdout else ""))
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user