Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.buildout
Commits
2dff90e5
Commit
2dff90e5
authored
Jan 15, 2019
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a query command
for continuous integration
parent
6d4fec30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
1 deletion
+91
-1
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+26
-1
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+65
-0
No files found.
src/zc/buildout/buildout.py
View file @
2dff90e5
...
...
@@ -1238,6 +1238,27 @@ class Buildout(DictMixin):
runsetup
=
setup
# backward compat.
def
query
(
self
,
args
=
None
):
if
args
is
None
or
len
(
args
)
!=
1
:
_error
(
'The query command requires a single argument.'
)
option
=
args
[
0
]
option
=
option
.
split
(
':'
)
if
len
(
option
)
==
1
:
option
=
'buildout'
,
option
[
0
]
elif
len
(
option
)
!=
2
:
_error
(
'Invalid option:'
,
args
[
0
])
section
,
option
=
option
verbose
=
self
[
'buildout'
].
get
(
'verbosity'
,
0
)
!=
0
if
verbose
:
print_
(
'${%s:%s}'
%
(
section
,
option
))
try
:
print_
(
self
.
_raw
[
section
][
option
])
except
KeyError
:
if
section
in
self
.
_raw
:
_error
(
'Key not found:'
,
option
)
else
:
_error
(
'Section not found:'
,
section
)
def
annotate
(
self
,
args
=
None
):
verbose
=
self
[
'buildout'
].
get
(
'verbosity'
,
0
)
!=
0
section
=
None
...
...
@@ -2020,6 +2041,10 @@ Commands:
alphabetically. For each section, all key-value pairs are displayed,
sorted alphabetically, along with the origin of the value (file name or
COMPUTED_VALUE, DEFAULT_VALUE, COMMAND_LINE_VALUE).
query section:key
Display value of given section key pair.
"""
def
_help
():
...
...
@@ -2115,7 +2140,7 @@ def main(args=None):
command
=
args
.
pop
(
0
)
if
command
not
in
(
'install'
,
'bootstrap'
,
'runsetup'
,
'setup'
,
'init'
,
'annotate'
,
'annotate'
,
'query'
,
):
_error
(
'invalid command:'
,
command
)
else
:
...
...
src/zc/buildout/buildout.txt
View file @
2dff90e5
...
...
@@ -1038,6 +1038,71 @@ You can restrict the output to some sections by passing section names as argumen
DEFAULT_VALUE
<BLANKLINE>
Query values
------------
For continuous integration, it might be useful to query the buildout config.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = .
...
... [values]
... host = buildout.org
... multiline =
... first
... second
... """)
>>> print_(system(buildout+ ' query buildout:develop'), end='')
.
>>> print_(system(buildout+ ' query values:host'), end='')
buildout.org
>>> print_(system(buildout+ ' query values:multiline'), end='')
first
second
As with assignments, if the section is ommitted, 'buildout' section is assumed.
>>> print_(system(buildout+ ' query develop'), end='')
.
When used with -v option, the query command also displays section and key.
>>> print_(system(buildout+ ' -v query develop'), end='')
${buildout:develop}
.
>>> print_(system(buildout+ ' -v query values:host'), end='')
${values:host}
buildout.org
The query commands outputs proper error messages.
>>> print_(system(buildout+ ' query versions parts'), end='')
Error: The query command requires a single argument.
>>> print_(system(buildout+ ' query'), end='')
Error: The query command requires a single argument.
>>> print_(system(buildout+ ' query invalid:section:key'), end='')
Error: Invalid option: invalid:section:key
>>> print_(system(buildout+ ' -v query values:port'), end='')
${values:port}
Error: Key not found: port
>>> print_(system(buildout+ ' -v query versionx'), end='')
${buildout:versionx}
Error: Key not found: versionx
>>> print_(system(buildout+ ' -v query specific:port'), end='')
${specific:port}
Error: Section not found: specific
Variable substitutions
----------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment