Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos
Commits
4066612b
Commit
4066612b
authored
Nov 30, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zero_knowledge: allow to set destination folder of configuration file
parent
0e789a1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
17 deletions
+25
-17
slapos/recipe/zero_knowledge.py
slapos/recipe/zero_knowledge.py
+25
-17
No files found.
slapos/recipe/zero_knowledge.py
View file @
4066612b
...
...
@@ -36,32 +36,36 @@ class WriteRecipe(GenericBaseRecipe):
"""
"""
def
__init__
(
self
,
buildout
,
name
,
options
):
if
not
"filename"
in
options
:
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
\
"
filename
\
"
"
)
if
not
"filename"
in
options
and
not
"file-path"
in
options
:
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
either
\
"
filename
\
"
or
\
"
file-path
\
"
"
)
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
path
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'directory'
],
self
.
filename
)
self
.
_options
=
options
.
copy
()
if
options
.
get
(
'filename'
):
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
path
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'directory'
],
self
.
filename
)
del
_options
[
'filename'
]
else
:
self
.
path
=
options
[
'file-path'
].
strip
()
del
options
[
'file-path'
]
del
self
.
_options
[
'recipe'
]
self
.
name
=
name
self
.
options
=
options
.
copy
()
del
self
.
options
[
'filename'
]
del
self
.
options
[
'recipe'
]
def
install
(
self
):
# Set up the parser, and write config file if needed
self
.
parser
=
ConfigParser
.
ConfigParser
()
try
:
self
.
parser
.
read
(
self
.
path
)
#clean_options(options)
for
key
in
self
.
options
:
for
key
in
self
.
_
options
:
if
key
not
in
self
.
parser
.
options
(
self
.
name
):
self
.
parser
.
set
(
self
.
name
,
key
,
self
.
options
[
key
])
self
.
parser
.
set
(
self
.
name
,
key
,
self
.
_
options
[
key
])
with
open
(
self
.
path
,
'w'
)
as
file
:
self
.
parser
.
write
(
file
)
# If the file or section do not exist
except
(
ConfigParser
.
NoSectionError
,
IOError
)
as
e
:
self
.
full_install
()
install
=
update
=
lambda
self
:
[]
def
full_install
(
self
):
"""XXX-Nicolas : when some parameter's value is changed in
buildout profile, this will override custom user defined values"""
...
...
@@ -69,21 +73,25 @@ class WriteRecipe(GenericBaseRecipe):
if
self
.
parser
.
has_section
(
self
.
name
):
self
.
parser
.
remove_section
(
self
.
name
)
self
.
parser
.
add_section
(
self
.
name
)
for
key
in
self
.
options
:
self
.
parser
.
set
(
self
.
name
,
key
,
self
.
options
[
key
])
for
key
in
self
.
_
options
:
self
.
parser
.
set
(
self
.
name
,
key
,
self
.
_
options
[
key
])
with
open
(
self
.
path
,
'w'
)
as
file
:
self
.
parser
.
write
(
file
)
update
=
install
class
ReadRecipe
(
GenericBaseRecipe
):
"""
"""
def
__init__
(
self
,
buildout
,
name
,
options
):
if
not
"filename"
in
options
:
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
\
"
filename
\
"
"
)
if
not
"filename"
in
options
and
not
"file-path"
in
options
:
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
either
\
"
filename
\
"
or file-path
"
)
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
path
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'directory'
],
self
.
filename
)
if
options
.
get
(
'filename'
):
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
path
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'directory'
],
self
.
filename
)
else
:
self
.
path
=
options
[
'file-path'
].
strip
()
# Set up the parser, and write config file if needed
self
.
parser
=
ConfigParser
.
ConfigParser
()
...
...
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