Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Test Xdevice
提交
9041b0ca
T
Test Xdevice
项目概览
OpenHarmony
/
Test Xdevice
8 个月 前同步成功
通知
6
Star
23
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Test Xdevice
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9041b0ca
编写于
9月 16, 2021
作者:
A
alex_hold
提交者:
Gitee
9月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update extension/src/xdevice_extension/_core/environment/dmlib.py.
Signed-off-by: <hejian3@huawei.com>
上级
08979ee7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
26 deletion
+39
-26
extension/src/xdevice_extension/_core/environment/dmlib.py
extension/src/xdevice_extension/_core/environment/dmlib.py
+39
-26
未找到文件。
extension/src/xdevice_extension/_core/environment/dmlib.py
浏览文件 @
9041b0ca
...
...
@@ -217,14 +217,17 @@ class HdcMonitor:
self
.
main_hdc_connection
)
if
self
.
main_hdc_connection
and
not
self
.
monitoring
:
LOG
.
debug
(
"start monitoring list targets"
)
self
.
monitoring_list_targets
()
len_buf
=
HdcHelper
.
read
(
self
.
main_hdc_connection
,
DATA_UNIT_LENGTH
)
length
=
struct
.
unpack
(
"!I"
,
len_buf
)[
0
]
LOG
.
debug
(
"had received length is: %s"
%
length
)
if
length
>=
0
:
self
.
monitoring
=
True
self
.
process_incoming_target_data
(
length
)
except
(
HdcError
,
Exception
)
as
_
:
LOG
.
debug
(
"loop_monitor happened error: %s"
%
_
)
self
.
handle_exception_monitor_loop
()
break
...
...
@@ -273,22 +276,21 @@ class HdcMonitor:
def
process_incoming_target_data
(
self
,
length
):
local_array_list
=
[]
if
length
>
0
:
data_buf
=
HdcHelper
.
read
(
self
.
main_hdc_connection
,
length
)
data_str
=
HdcHelper
.
reply_to_string
(
data_buf
)
if
'Empty'
not
in
data_str
:
lines
=
data_str
.
split
(
'
\n
'
)
for
line
in
lines
:
items
=
line
.
strip
().
split
(
'
\t
'
)
if
not
items
[
0
]
:
continue
items
.
append
(
DeviceState
.
ONLINE
.
value
)
device_instance
=
self
.
_get_device_instance
(
items
,
DeviceOsType
.
default
)
local_array_list
.
append
(
device_instance
)
else
:
LOG
.
debug
(
"please check device actually.[%s]"
%
data_str
)
data_buf
=
HdcHelper
.
read
(
self
.
main_hdc_connection
,
length
)
data_str
=
HdcHelper
.
reply_to_string
(
data_buf
)
if
'Empty'
not
in
data_str
:
lines
=
data_str
.
split
(
'
\n
'
)
for
line
in
lines
:
items
=
line
.
strip
().
split
(
'
\t
'
)
if
not
items
[
0
]
:
continue
items
.
append
(
DeviceState
.
ONLINE
.
value
)
device_instance
=
self
.
_get_device_instance
(
items
,
DeviceOsType
.
default
)
local_array_list
.
append
(
device_instance
)
else
:
LOG
.
debug
(
"please check device actually.[%s]"
%
data_str
)
LOG
.
debug
(
"process target data, local_array_list"
%
local_array_list
)
self
.
update_devices
(
local_array_list
)
def
_get_device_instance
(
self
,
items
,
os_type
):
...
...
@@ -751,7 +753,7 @@ class HdcHelper:
if
not
os
.
path
.
exists
(
local
):
raise
HdcError
(
"Local path doesn't exist."
)
sock
=
HdcHelper
.
socket
(
host
=
device
.
host
,
port
=
device
.
port
,
timeout
=
DEFAULT_TIMEOUT
)
timeout
=
timeout
)
HdcHelper
.
handle_shake
(
sock
,
device
.
device_sn
)
request
=
HdcHelper
.
form_hdc_request
(
"file send %s %s"
%
(
local
,
remote
))
...
...
@@ -760,6 +762,7 @@ class HdcHelper:
length
=
struct
.
unpack
(
"!I"
,
reply
)[
0
]
data_buf
=
HdcHelper
.
read
(
sock
,
length
)
data_str
=
HdcHelper
.
reply_to_string
(
data_buf
)
device
.
log
.
info
(
data_str
)
@
staticmethod
def
pull_file
(
device
,
remote
,
local
,
is_create
=
False
,
...
...
@@ -769,7 +772,7 @@ class HdcHelper:
(
convert_serial
(
device
.
device_sn
),
remote
,
local
))
sock
=
HdcHelper
.
socket
(
host
=
device
.
host
,
port
=
device
.
port
,
timeout
=
DEFAULT_TIMEOUT
)
timeout
=
timeout
)
HdcHelper
.
handle_shake
(
sock
,
device
.
device_sn
)
request
=
HdcHelper
.
form_hdc_request
(
"file recv %s %s"
%
(
local
,
remote
))
...
...
@@ -778,6 +781,7 @@ class HdcHelper:
length
=
struct
.
unpack
(
"!I"
,
reply
)[
0
]
data_buf
=
HdcHelper
.
read
(
sock
,
length
)
data_str
=
HdcHelper
.
reply_to_string
(
data_buf
)
device
.
log
.
info
(
data_str
)
@
staticmethod
def
_install_remote_package
(
device
,
remote_file_path
,
command
):
...
...
@@ -844,6 +848,8 @@ class HdcHelper:
output_flag
=
kwargs
.
get
(
"output_flag"
,
True
)
timeout_msg
=
''
if
(
timeout
/
1000
)
==
300.0
else
\
" with timeout %ss"
%
str
(
timeout
/
1000
)
end_mark
=
kwargs
.
get
(
"end_mark"
,
""
)
read_timeout
=
kwargs
.
get
(
"read_timeout"
,
None
)
if
device
.
usb_type
==
DeviceConnectorType
.
hdc
:
message
=
"%s execute command: hdc shell %s%s"
%
\
(
convert_serial
(
device
.
device_sn
),
command
,
...
...
@@ -856,26 +862,31 @@ class HdcHelper:
HdcHelper
.
handle_shake
(
sock
,
device
.
device_sn
)
request
=
HdcHelper
.
form_hdc_request
(
"shell %s"
%
command
)
HdcHelper
.
write
(
sock
,
request
)
len_buf
=
HdcHelper
.
read
(
sock
,
DATA_UNIT_LENGTH
)
if
len_buf
:
length
=
struct
.
unpack
(
"!I"
,
len_buf
)[
0
]
resp
=
HdcResponse
()
resp
.
okay
=
True
from
xdevice
import
Scheduler
data
=
sock
.
recv
(
SOCK_DATA_MAX
)
while
data
!=
b
''
:
start_time
=
int
(
time
.
time
())
while
True
:
len_buf
=
HdcHelper
.
read
(
sock
,
DATA_UNIT_LENGTH
)
if
len_buf
:
length
=
struct
.
unpack
(
"!I"
,
len_buf
)[
0
]
else
:
break
data
=
sock
.
recv
(
length
)
ret
=
HdcHelper
.
reply_to_string
(
data
)
if
ret
:
if
receiver
:
receiver
.
__read__
(
ret
)
else
:
LOG
.
debug
(
ret
)
if
end_mark
and
end_mark
in
ret
:
break
if
read_timeout
and
\
int
(
time
.
time
())
-
start_time
>
read_timeout
:
break
if
not
Scheduler
.
is_execute
:
raise
ExecuteTerminate
()
data
=
HdcHelper
.
read
(
sock
,
SOCK_DATA_MAX
)
return
resp
except
socket
.
timeout
as
_
:
device
.
log
.
error
(
"%s shell %s timeout[%sS]"
%
(
...
...
@@ -905,6 +916,8 @@ class HdcHelper:
Create an ASCII string preceded by four hex digits.
"""
try
:
if
not
req
.
endswith
(
'
\0
'
):
req
=
"%s
\0
"
%
req
req
=
req
.
encode
(
"utf-8"
)
fmt
=
"!I%ss"
%
len
(
req
)
result
=
struct
.
pack
(
fmt
,
len
(
req
),
req
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录