mirror of
https://gitee.com/openharmony/testfwk_xdevice
synced 2024-11-23 07:20:44 +00:00
commit
9c4de5f3fd
@ -229,9 +229,12 @@ class HdcMonitor:
|
||||
device_instance.host = self.channel.get("host")
|
||||
device_instance.port = self.channel.get("port")
|
||||
if self.changed:
|
||||
LOG.debug("Dmlib get device instance %s %s %s" %
|
||||
(device_instance.device_sn,
|
||||
device_instance.host, device_instance.port))
|
||||
if DeviceState.get_state(items[3]) == DeviceState.CONNECTED:
|
||||
LOG.debug("Dmlib get device instance {} {} {}, status: {}".format(
|
||||
device_instance.device_sn, device_instance.host, device_instance.port, items[3]))
|
||||
else:
|
||||
LOG.debug("Dmlib ignore device instance {} {} {}, status: {}".format(
|
||||
device_instance.device_sn, device_instance.host, device_instance.port, items[3]))
|
||||
device_instance.device_state = DeviceState.get_state(items[3])
|
||||
return device_instance
|
||||
|
||||
|
@ -300,11 +300,12 @@ class PushKit(ITestKit):
|
||||
pattern = re.compile(r'^(\./)?resource/')
|
||||
if re.match(pattern, file_path) is None:
|
||||
return None
|
||||
file_path = re.sub(pattern, "", file_path)
|
||||
save_file = os.path.join(
|
||||
request_config.get(ConfigConst.resource_path), re.sub(pattern, "resource/", file_path))
|
||||
request_config.get(ConfigConst.resource_path), file_path)
|
||||
if os.path.exists(save_file):
|
||||
return save_file
|
||||
url = self.__query_resource_url(device, web_resource_url, file_path)
|
||||
url = self.__query_resource_url(device, web_resource_url, "resource/" + file_path)
|
||||
if not url:
|
||||
return None
|
||||
save_path = os.path.dirname(save_file)
|
||||
@ -336,7 +337,7 @@ class PushKit(ITestKit):
|
||||
os_type = "standard system"
|
||||
if device_class == "DeviceLite" and device.label == DeviceLabelType.ipcamera:
|
||||
os_type = "small system"
|
||||
os_version = getattr(device, "device_props", {}).get("DisplayVersion", "")
|
||||
os_version = getattr(device, "device_props", {}).get("OsFullName", "")
|
||||
test_type = self.request.config.get(ConfigConst.task, "").upper()
|
||||
if not os_type or not os_version or re.search(r'(AC|DC|HA|HI|SS)TS', test_type) is None:
|
||||
LOG.warning("query resource params is none")
|
||||
@ -348,19 +349,24 @@ class PushKit(ITestKit):
|
||||
"osVersion": os_version,
|
||||
"testType": test_type
|
||||
}
|
||||
LOG.debug(f"query resource's response params: {params}")
|
||||
try:
|
||||
import requests
|
||||
cli = requests.post(query_url, json=params, timeout=5, verify=False)
|
||||
rsp_code = cli.status_code
|
||||
rsp_body = cli.content.decode()
|
||||
LOG.debug(f"query resource's response code: {rsp_code}")
|
||||
LOG.debug(f"query resource's response body: {rsp_body}")
|
||||
if rsp_code == 200:
|
||||
try:
|
||||
url = json.loads(rsp_body).get("body")
|
||||
data = json.loads(rsp_body)
|
||||
if data.get("code") == 200:
|
||||
url = data.get("body")
|
||||
else:
|
||||
msg = data.get("msg")
|
||||
LOG.error(f"query the resource of '{file_path}' downloading url failed. {msg}")
|
||||
except ValueError:
|
||||
LOG.error("query resource's response body is not json data")
|
||||
else:
|
||||
LOG.info(f"query resource's response code: {rsp_code}")
|
||||
LOG.info(f"query resource's response body: {rsp_body}")
|
||||
except Exception as e:
|
||||
LOG.error(f"query the resource of '{file_path}' downloading url failed. {e}")
|
||||
finally:
|
||||
|
@ -149,10 +149,15 @@ class DriversThread(threading.Thread):
|
||||
"""write device to result file"""
|
||||
if not os.path.exists(result_xml) or environment is None:
|
||||
return
|
||||
root = ElementTree.parse(result_xml).getroot()
|
||||
desc = environment.get_description()
|
||||
if not desc:
|
||||
return
|
||||
try:
|
||||
root = ElementTree.parse(result_xml).getroot()
|
||||
except ElementTree.ParseError as e:
|
||||
LOG.error(f"parse result xml error! xml file {result_xml}")
|
||||
LOG.error(f"error message: {e}")
|
||||
return
|
||||
root.set("devices", literal_eval(str(desc)))
|
||||
result_fd = os.open(result_xml, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, FilePermission.mode_644)
|
||||
with os.fdopen(result_fd, mode="w", encoding="utf-8") as result_file:
|
||||
|
Loading…
Reference in New Issue
Block a user