Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Test Xdevice
提交
75e5dce6
T
Test Xdevice
项目概览
OpenHarmony
/
Test Xdevice
10 个月 前同步成功
通知
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 搜索 >>
未验证
提交
75e5dce6
编写于
7月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!141 修复mac os上无法识别设备的bug
Merge pull request !141 from liguangjie/master
上级
11df99e7
8412889f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
37 deletion
+58
-37
extension/src/xdevice_extension/_core/utils.py
extension/src/xdevice_extension/_core/utils.py
+15
-1
run.bat
run.bat
+4
-4
run.sh
run.sh
+3
-3
src/xdevice/_core/utils.py
src/xdevice/_core/utils.py
+36
-29
未找到文件。
extension/src/xdevice_extension/_core/utils.py
浏览文件 @
75e5dce6
...
...
@@ -101,7 +101,7 @@ def is_proc_running(pid, name=None):
proc
=
subprocess
.
Popen
([
"C:
\\
Windows
\\
System32
\\
findstr"
,
"%s"
%
pid
],
stdin
=
proc_sub
.
stdout
,
stdout
=
subprocess
.
PIPE
,
shell
=
False
)
el
se
:
el
if
platform
.
system
()
==
"Linux"
:
# /bin/ps -ef | /bin/grep -v grep | /bin/grep -w pid
proc_sub
=
subprocess
.
Popen
([
"/bin/ps"
,
"-ef"
],
stdout
=
subprocess
.
PIPE
,
...
...
@@ -113,6 +113,20 @@ def is_proc_running(pid, name=None):
proc
=
subprocess
.
Popen
([
"/bin/grep"
,
"-w"
,
"%s"
%
pid
],
stdin
=
proc_v_sub
.
stdout
,
stdout
=
subprocess
.
PIPE
,
shell
=
False
)
elif
platform
.
system
()
==
"Darwin"
:
# /bin/ps -ef | /bin/grep -v grep | /bin/grep -w pid
proc_sub
=
subprocess
.
Popen
([
"/bin/ps"
,
"-ef"
],
stdout
=
subprocess
.
PIPE
,
shell
=
False
)
proc_v_sub
=
subprocess
.
Popen
([
"/usr/bin/grep"
,
"-v"
,
"grep"
],
stdin
=
proc_sub
.
stdout
,
stdout
=
subprocess
.
PIPE
,
shell
=
False
)
proc
=
subprocess
.
Popen
([
"/usr/bin/grep"
,
"-w"
,
"%s"
%
pid
],
stdin
=
proc_v_sub
.
stdout
,
stdout
=
subprocess
.
PIPE
,
shell
=
False
)
else
:
raise
Exception
(
"Unknown system environment."
)
(
out
,
_
)
=
proc
.
communicate
()
out
=
get_decode
(
out
).
strip
()
LOG
.
debug
(
"check %s proc running output: %s"
,
pid
,
out
)
...
...
run.bat
浏览文件 @
75e5dce6
...
...
@@ -30,9 +30,9 @@ python -c "import sys; exit(1) if sys.version_info.major < 3 or sys.version_info
goto
:eof
)
python
-c
"import
easy_install
"
python
-c
"import
pip
"
@if
errorlevel
1
(
@echo
"Please install
setuptools
first
!
"
@echo
"Please install
pip
first
!
"
goto
:eof
)
...
...
@@ -42,13 +42,13 @@ if not exist %TOOLS% (
)
for
%%a
in
(
%TOOLS%
/
*
.egg
)
do
(
python
-m
easy_
install
--user
%TOOLS%
/
%%a
python
-m
pip
install
--user
%TOOLS%
/
%%a
@if
errorlevel
1
(
@echo
"Error occurs to install
%%a!
"
)
)
for
%%a
in
(
%TOOLS%
/
*
.tar.gz
)
do
(
python
-m
easy_
install
--user
%TOOLS%
/
%%a
python
-m
pip
install
--user
%TOOLS%
/
%%a
@if
errorlevel
1
(
@echo
"Error occurs to install
%%a!
"
)
...
...
run.sh
浏览文件 @
75e5dce6
...
...
@@ -32,7 +32,7 @@ fi
$PYTHON
-c
'import sys; exit(1) if sys.version_info.major < 3 or sys.version_info.minor < 7 else exit(0)'
||
\
error
"Python3.7 or higher version required!"
cd
$(
dirname
"
$0
"
)
||
error
"Failure to change directory!"
$PYTHON
-c
"import
easy_install"
||
error
"Please install setuptools
first!"
$PYTHON
-c
"import
pip"
||
error
"Please install pip
first!"
if
[
!
-d
"
$TOOLS
"
]
;
then
error
"
$TOOLS
directory not exists"
...
...
@@ -43,7 +43,7 @@ do
if
[
!
-e
"
$f
"
]
;
then
error
"Can not find xdevice package!"
fi
$PYTHON
-m
easy_
install
--user
"
$f
"
||
echo
"Error occurs to install
$f
!"
$PYTHON
-m
pip
install
--user
"
$f
"
||
echo
"Error occurs to install
$f
!"
done
for
f
in
"
$TOOLS
"
/
*
.tar.gz
...
...
@@ -51,7 +51,7 @@ do
if
[
!
-e
"
$f
"
]
;
then
error
"Can not find xdevice package!"
fi
$PYTHON
-m
easy_
install
--user
"
$f
"
||
echo
"Error occurs to install
$f
!"
$PYTHON
-m
pip
install
--user
"
$f
"
||
echo
"Error occurs to install
$f
!"
done
$PYTHON
-m
xdevice
"
$@
"
...
...
src/xdevice/_core/utils.py
浏览文件 @
75e5dce6
...
...
@@ -117,6 +117,9 @@ def is_proc_running(pid, name=None):
if
platform
.
system
()
==
"Windows"
:
list_command
=
[
"C:
\\
Windows
\\
System32
\\
tasklist"
]
find_command
=
[
"C:
\\
Windows
\\
System32
\\
findstr"
,
"%s"
%
pid
]
elif
platform
.
system
()
==
"Darwin"
:
list_command
=
[
"/bin/ps"
,
"-ef"
]
find_command
=
[
"/usr/bin/grep"
,
"%s"
%
pid
]
else
:
list_command
=
[
"/bin/ps"
,
"-ef"
]
find_command
=
[
"/bin/grep"
,
"%s"
%
pid
]
...
...
@@ -537,37 +540,41 @@ def check_path_legal(path):
def
get_local_ip
():
sys_type
=
platform
.
system
()
if
sys_type
==
"Windows"
:
_list
=
socket
.
gethostbyname_ex
(
socket
.
gethostname
())
_list
=
_list
[
2
]
for
ip_add
in
_list
:
if
ip_add
.
startswith
(
"10."
):
return
ip_add
return
socket
.
gethostbyname
(
socket
.
getfqdn
(
socket
.
gethostname
()))
elif
sys_type
==
"Darwin"
:
hostname
=
socket
.
getfqdn
(
socket
.
gethostname
())
return
socket
.
gethostbyname
(
hostname
)
elif
sys_type
==
"Linux"
:
real_ip
=
"/%s/%s"
%
(
"hostip"
,
"realip"
)
if
os
.
path
.
exists
(
real_ip
):
srw
=
None
try
:
import
codecs
srw
=
codecs
.
open
(
real_ip
,
"r"
,
"utf-8"
)
lines
=
srw
.
readlines
()
local_ip
=
str
(
lines
[
0
]).
strip
()
except
(
IOError
,
ValueError
)
as
error_message
:
LOG
.
error
(
error_message
)
try
:
sys_type
=
platform
.
system
()
if
sys_type
==
"Windows"
:
_list
=
socket
.
gethostbyname_ex
(
socket
.
gethostname
())
_list
=
_list
[
2
]
for
ip_add
in
_list
:
if
ip_add
.
startswith
(
"10."
):
return
ip_add
return
socket
.
gethostbyname
(
socket
.
getfqdn
(
socket
.
gethostname
()))
elif
sys_type
==
"Darwin"
:
hostname
=
socket
.
getfqdn
(
socket
.
gethostname
())
return
socket
.
gethostbyname
(
hostname
)
elif
sys_type
==
"Linux"
:
real_ip
=
"/%s/%s"
%
(
"hostip"
,
"realip"
)
if
os
.
path
.
exists
(
real_ip
):
srw
=
None
try
:
import
codecs
srw
=
codecs
.
open
(
real_ip
,
"r"
,
"utf-8"
)
lines
=
srw
.
readlines
()
local_ip
=
str
(
lines
[
0
]).
strip
()
except
(
IOError
,
ValueError
)
as
error_message
:
LOG
.
error
(
error_message
)
local_ip
=
"127.0.0.1"
finally
:
if
srw
is
not
None
:
srw
.
close
()
else
:
local_ip
=
"127.0.0.1"
finally
:
if
srw
is
not
None
:
srw
.
close
()
return
local_ip
else
:
local_ip
=
"127.0.0.1"
return
local_ip
else
:
return
"127.0.0.1"
except
Exception
as
error
:
LOG
.
debug
(
"Get local ip error: %s, skip!"
%
error
)
return
"127.0.0.1"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录