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
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
57d0ce54
Commit
57d0ce54
authored
Dec 02, 2020
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos/recipe: add python3 support to zero_knowledge
parent
a9289763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
4 deletions
+49
-4
slapos/recipe/zero_knowledge.py
slapos/recipe/zero_knowledge.py
+4
-4
slapos/test/recipe/test_zero_knowledge.py
slapos/test/recipe/test_zero_knowledge.py
+45
-0
No files found.
slapos/recipe/zero_knowledge.py
View file @
57d0ce54
...
...
@@ -25,7 +25,7 @@
#
##############################################################################
import
ConfigP
arser
from
six.moves
import
configp
arser
import
os
import
zc.buildout
...
...
@@ -53,7 +53,7 @@ class WriteRecipe(GenericBaseRecipe):
def
install
(
self
):
# Set up the parser, and write config file if needed
self
.
parser
=
ConfigP
arser
.
ConfigParser
()
self
.
parser
=
configp
arser
.
ConfigParser
()
try
:
self
.
parser
.
read
(
self
.
path
)
#clean_options(options)
...
...
@@ -63,7 +63,7 @@ class WriteRecipe(GenericBaseRecipe):
with
open
(
self
.
path
,
'w'
)
as
file
:
self
.
parser
.
write
(
file
)
# If the file or section do not exist
except
(
ConfigP
arser
.
NoSectionError
,
IOError
)
as
e
:
except
(
configp
arser
.
NoSectionError
,
IOError
)
as
e
:
self
.
full_install
()
def
full_install
(
self
):
...
...
@@ -94,7 +94,7 @@ class ReadRecipe(GenericBaseRecipe):
self
.
path
=
options
[
'file-path'
].
strip
()
# Set up the parser, and write config file if needed
self
.
parser
=
ConfigP
arser
.
ConfigParser
()
self
.
parser
=
configp
arser
.
ConfigParser
()
if
os
.
path
.
exists
(
self
.
path
):
self
.
parser
.
read
(
self
.
path
)
for
section
in
self
.
parser
.
sections
():
...
...
slapos/test/recipe/test_zero_knowledge.py
0 → 100644
View file @
57d0ce54
import
os
import
shutil
import
tempfile
import
unittest
import
zc.buildout.testing
from
slapos.recipe
import
zero_knowledge
class
ZeroKnowledgeTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmp_dir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
self
.
tmp_dir
)
self
.
buildout
=
zc
.
buildout
.
testing
.
Buildout
()
self
.
buildout
[
'buildout'
][
'directory'
]
=
self
.
tmp_dir
def
test_write_read
(
self
):
buildout
=
self
.
buildout
buildout
[
'zero-knowledge-write'
]
=
{
'filename'
:
'zero-knowledge.cfg'
,
'recipe'
:
'slapos.cookbook:zero-knowledge.read'
,
'secret'
:
'?'
,
}
buildout
[
'zero-knowledge-read'
]
=
{
'filename'
:
'zero-knowledge.cfg'
,
'recipe'
:
'slapos.cookbook:zero-knowledge.read'
,
}
write_recipe
=
zero_knowledge
.
WriteRecipe
(
buildout
,
'zero-knowledge-write'
,
buildout
[
'zero-knowledge-write'
],
)
write_recipe
.
install
()
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
tmp_dir
,
'zero-knowledge.cfg'
,)))
zero_knowledge
.
ReadRecipe
(
buildout
,
'zero-knowledge-read'
,
buildout
[
'zero-knowledge-read'
],
)
self
.
assertEqual
(
buildout
[
'zero-knowledge-read'
][
'secret'
],
'?'
)
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