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
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
Thomas Gambier
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
Show 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):
...
@@ -36,32 +36,36 @@ class WriteRecipe(GenericBaseRecipe):
"""
"""
"""
"""
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
if
not
"filename"
in
options
:
if
not
"filename"
in
options
and
not
"file-path"
in
options
:
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
\
"
filename
\
"
"
)
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
either
\
"
filename
\
"
or
\
"
file-path
\
"
"
)
self
.
_options
=
options
.
copy
()
if
options
.
get
(
'filename'
):
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
path
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'directory'
],
self
.
filename
)
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
.
name
=
name
self
.
options
=
options
.
copy
()
del
self
.
options
[
'filename'
]
def
install
(
self
):
del
self
.
options
[
'recipe'
]
# Set up the parser, and write config file if needed
# Set up the parser, and write config file if needed
self
.
parser
=
ConfigParser
.
ConfigParser
()
self
.
parser
=
ConfigParser
.
ConfigParser
()
try
:
try
:
self
.
parser
.
read
(
self
.
path
)
self
.
parser
.
read
(
self
.
path
)
#clean_options(options)
#clean_options(options)
for
key
in
self
.
options
:
for
key
in
self
.
_
options
:
if
key
not
in
self
.
parser
.
options
(
self
.
name
):
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
:
with
open
(
self
.
path
,
'w'
)
as
file
:
self
.
parser
.
write
(
file
)
self
.
parser
.
write
(
file
)
# If the file or section do not exist
# If the file or section do not exist
except
(
ConfigParser
.
NoSectionError
,
IOError
)
as
e
:
except
(
ConfigParser
.
NoSectionError
,
IOError
)
as
e
:
self
.
full_install
()
self
.
full_install
()
install
=
update
=
lambda
self
:
[]
def
full_install
(
self
):
def
full_install
(
self
):
"""XXX-Nicolas : when some parameter's value is changed in
"""XXX-Nicolas : when some parameter's value is changed in
buildout profile, this will override custom user defined values"""
buildout profile, this will override custom user defined values"""
...
@@ -69,21 +73,25 @@ class WriteRecipe(GenericBaseRecipe):
...
@@ -69,21 +73,25 @@ class WriteRecipe(GenericBaseRecipe):
if
self
.
parser
.
has_section
(
self
.
name
):
if
self
.
parser
.
has_section
(
self
.
name
):
self
.
parser
.
remove_section
(
self
.
name
)
self
.
parser
.
remove_section
(
self
.
name
)
self
.
parser
.
add_section
(
self
.
name
)
self
.
parser
.
add_section
(
self
.
name
)
for
key
in
self
.
options
:
for
key
in
self
.
_
options
:
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
:
with
open
(
self
.
path
,
'w'
)
as
file
:
self
.
parser
.
write
(
file
)
self
.
parser
.
write
(
file
)
update
=
install
class
ReadRecipe
(
GenericBaseRecipe
):
class
ReadRecipe
(
GenericBaseRecipe
):
"""
"""
"""
"""
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
if
not
"filename"
in
options
:
if
not
"filename"
in
options
and
not
"file-path"
in
options
:
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
\
"
filename
\
"
"
)
raise
zc
.
buildout
.
UserError
(
"You have to provide the parameter
either
\
"
filename
\
"
or file-path
"
)
if
options
.
get
(
'filename'
):
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
filename
=
options
[
'filename'
].
strip
()
self
.
path
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'directory'
],
self
.
filename
)
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
# Set up the parser, and write config file if needed
self
.
parser
=
ConfigParser
.
ConfigParser
()
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