Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
3221a1de
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,发现更多精彩内容 >>
提交
3221a1de
编写于
6月 10, 2015
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #658 from ruda/avocado_conf_cmd_line_option_lukas2
Add option to read a custom configuration from a file ǘ[v2]
上级
9e95b48f
4b91276e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
16 addition
and
8 deletion
+16
-8
avocado/core/parser.py
avocado/core/parser.py
+7
-0
avocado/core/settings.py
avocado/core/settings.py
+7
-7
man/avocado.rst
man/avocado.rst
+2
-1
未找到文件。
avocado/core/parser.py
浏览文件 @
3221a1de
...
...
@@ -21,6 +21,7 @@ import sys
import
argparse
from
avocado.core
import
tree
from
avocado.core
import
settings
from
avocado.version
import
VERSION
PROG
=
'avocado'
...
...
@@ -45,6 +46,8 @@ class Parser(object):
self
.
application
.
add_argument
(
'--plugins'
,
action
=
'store'
,
help
=
'Load extra plugins from directory'
,
dest
=
'plugins_dir'
,
default
=
''
)
self
.
application
.
add_argument
(
'--config'
,
metavar
=
'CONFIG_FILE'
,
help
=
'Use custom configuration from a file'
)
def
start
(
self
):
"""
...
...
@@ -55,6 +58,10 @@ class Parser(object):
"""
self
.
args
,
_
=
self
.
application
.
parse_known_args
()
# Load settings from file, if user provides one
if
self
.
args
.
config
is
not
None
:
settings
.
settings
.
process_config_path
(
self
.
args
.
config
)
# Use parent parsing to avoid breaking the output of --help option
self
.
application
=
argparse
.
ArgumentParser
(
prog
=
PROG
,
description
=
DESCRIPTION
,
...
...
avocado/core/settings.py
浏览文件 @
3221a1de
...
...
@@ -166,30 +166,30 @@ class Settings(object):
config_path_intree
])
if
config_intree
:
# In this case, respect only the intree config
self
.
_
process_config_path
(
config_path_intree
)
self
.
process_config_path
(
config_path_intree
)
if
config_intree_extra
:
for
extra_file
in
glob
.
glob
(
os
.
path
.
join
(
_config_path_intree_extra
,
'*.conf'
)):
self
.
_
process_config_path
(
extra_file
)
self
.
process_config_path
(
extra_file
)
self
.
intree
=
True
else
:
# In this case, load first the global config, then the
# local config overrides the global one
if
config_system
:
self
.
_
process_config_path
(
config_path_system
)
self
.
process_config_path
(
config_path_system
)
if
config_system_extra
:
for
extra_file
in
glob
.
glob
(
os
.
path
.
join
(
_config_dir_system_extra
,
'*.conf'
)):
self
.
_
process_config_path
(
extra_file
)
self
.
process_config_path
(
extra_file
)
if
not
config_local
:
path
.
init_dir
(
_config_dir_local
)
with
open
(
config_path_local
,
'w'
)
as
config_local_fileobj
:
config_local_fileobj
.
write
(
'# You can use this file to override configuration values from '
'%s and %s
\n
'
%
(
config_path_system
,
_config_dir_system_extra
))
self
.
_
process_config_path
(
config_path_local
)
self
.
process_config_path
(
config_path_local
)
else
:
# Unittests
self
.
_
process_config_path
(
config_path
)
self
.
process_config_path
(
config_path
)
def
_
process_config_path
(
self
,
pth
):
def
process_config_path
(
self
,
pth
):
read_configs
=
self
.
config
.
read
(
pth
)
if
read_configs
:
self
.
config_paths
+=
read_configs
...
...
man/avocado.rst
浏览文件 @
3221a1de
...
...
@@ -6,7 +6,7 @@
SYNOPSIS
========
avocado [-h] [-v] [--plugins PLUGINS_DIR]
avocado [-h] [-v] [--plugins PLUGINS_DIR]
[--config CONFIG_FILE]
{run,list,sysinfo,multiplex,plugins,datadir} ...
DESCRIPTION
...
...
@@ -31,6 +31,7 @@ on them being loaded::
-h, --help show this help message and exit
-v, --version show program's version number and exit
--plugins PLUGINS_DIR Load extra plugins from directory
--config CONFIG_FILE Use custom configuration from a file
Real use of avocado depends on running avocado subcommands. This a typical list
of avocado subcommands::
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录