Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
6f995fa3
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f995fa3
编写于
5月 07, 2014
作者:
L
Lucas Meneghel Rodrigues
提交者:
Lucas Meneghel Rodrigues
5月 07, 2014
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #59 from avocado-framework/fix-ro-bug
avocado.core.data_dir: Contemplate read only dirs
上级
1af9ac3a
793dc5f2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
11 deletion
+51
-11
avocado/core/data_dir.py
avocado/core/data_dir.py
+51
-11
未找到文件。
avocado/core/data_dir.py
浏览文件 @
6f995fa3
...
...
@@ -58,9 +58,9 @@ USER_LOG_DIR = os.path.join(USER_BASE_DIR, 'logs')
USER_TMP_DIR
=
'/var/tmp/avocado'
def
_
is_usable
_dir
(
directory
):
def
_
usable_rw
_dir
(
directory
):
"""
Verify wether we can use this dir.
Verify wether we can use this dir
(read/write)
.
Checks for appropriate permissions, and creates missing dirs as needed.
...
...
@@ -84,16 +84,56 @@ def _is_usable_dir(directory):
return
False
def
_get_dir
(
settings_location
,
system_location
,
user_location
):
def
_usable_ro_dir
(
directory
):
"""
Verify whether dir exists and we can access its contents.
If a usable RO is there, use it no questions asked. If not, let's at
least try to create one.
:param directory: Directory
"""
cwd
=
os
.
getcwd
()
if
os
.
path
.
isdir
(
directory
):
try
:
os
.
chdir
(
directory
)
os
.
chdir
(
cwd
)
return
True
except
OSError
:
pass
else
:
try
:
os
.
makedirs
(
directory
)
return
True
except
OSError
:
pass
return
False
def
_get_rw_dir
(
settings_location
,
system_location
,
user_location
):
if
not
settings
.
intree
:
if
_usable_rw_dir
(
settings_location
):
return
settings_location
if
_usable_rw_dir
(
system_location
):
return
system_location
user_location
=
os
.
path
.
expanduser
(
user_location
)
if
_usable_rw_dir
(
user_location
):
return
user_location
def
_get_ro_dir
(
settings_location
,
system_location
,
user_location
):
if
not
settings
.
intree
:
if
_
is_usable
_dir
(
settings_location
):
if
_
usable_ro
_dir
(
settings_location
):
return
settings_location
if
_
is_usable
_dir
(
system_location
):
if
_
usable_ro
_dir
(
system_location
):
return
system_location
user_location
=
os
.
path
.
expanduser
(
user_location
)
if
_
is_usable
_dir
(
user_location
):
if
_
usable_ro
_dir
(
user_location
):
return
user_location
...
...
@@ -109,7 +149,7 @@ def get_base_dir():
* Data directory
* Tests directory
"""
return
_get_dir
(
SETTINGS_BASE_DIR
,
SYSTEM_BASE_DIR
,
USER_BASE_DIR
)
return
_get_
rw_
dir
(
SETTINGS_BASE_DIR
,
SYSTEM_BASE_DIR
,
USER_BASE_DIR
)
def
get_test_dir
():
...
...
@@ -120,7 +160,7 @@ def get_test_dir():
"""
if
settings
.
intree
:
return
_IN_TREE_TESTS_DIR
return
_get_dir
(
SETTINGS_TEST_DIR
,
SYSTEM_TEST_DIR
,
USER_TEST_DIR
)
return
_get_
ro_
dir
(
SETTINGS_TEST_DIR
,
SYSTEM_TEST_DIR
,
USER_TEST_DIR
)
def
get_data_dir
():
...
...
@@ -136,7 +176,7 @@ def get_data_dir():
* VM images
* Reference bitmaps
"""
return
_get_dir
(
SETTINGS_DATA_DIR
,
SYSTEM_DATA_DIR
,
USER_DATA_DIR
)
return
_get_
rw_
dir
(
SETTINGS_DATA_DIR
,
SYSTEM_DATA_DIR
,
USER_DATA_DIR
)
def
get_logs_dir
():
...
...
@@ -145,7 +185,7 @@ def get_logs_dir():
The log dir is where we store job/test logs in general.
"""
return
_get_dir
(
SETTINGS_LOG_DIR
,
SYSTEM_LOG_DIR
,
USER_LOG_DIR
)
return
_get_
rw_
dir
(
SETTINGS_LOG_DIR
,
SYSTEM_LOG_DIR
,
USER_LOG_DIR
)
def
get_job_logs_dir
(
args
=
None
):
...
...
@@ -185,7 +225,7 @@ def get_tmp_dir():
* Copies of a test suite source code
* Compiled test suite source code
"""
return
_get_dir
(
SETTINGS_TMP_DIR
,
SYSTEM_TMP_DIR
,
USER_TMP_DIR
)
return
_get_
rw_
dir
(
SETTINGS_TMP_DIR
,
SYSTEM_TMP_DIR
,
USER_TMP_DIR
)
def
clean_tmp_files
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录