Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Carlos Ramos Carreño
slapos.core
Commits
81a46850
Commit
81a46850
authored
Jun 27, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node register: retain comments, reject non-ascii configuration templates
parent
f3825592
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
setup.py
setup.py
+1
-0
slapos/cli/register.py
slapos/cli/register.py
+12
-5
No files found.
setup.py
View file @
81a46850
...
...
@@ -45,6 +45,7 @@ setup(name=name,
'zope.interface'
,
# slap library implementes interfaces
'zc.buildout'
,
'cliff'
,
'iniparse'
,
'requests'
,
]
+
additional_install_requires
,
extra_requires
=
{
'docs'
:
(
...
...
slapos/cli/register.py
View file @
81a46850
# -*- coding: utf-8 -*-
import
ConfigParser
import
getpass
import
os
import
shutil
...
...
@@ -9,6 +8,7 @@ import sys
import
tempfile
import
subprocess
import
iniparse
import
requests
from
slapos.cli.command
import
Command
,
must_be_root
...
...
@@ -174,13 +174,21 @@ def save_former_config(conf):
shutil
.
move
(
former
,
saved
)
def
get_slapos_conf_example
():
def
get_slapos_conf_example
(
logger
):
"""
Get slapos.cfg.example and return its path
"""
_
,
path
=
tempfile
.
mkstemp
()
with
open
(
path
,
'wb'
)
as
fout
:
req
=
requests
.
get
(
'http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example'
)
try
:
req
.
content
.
decode
(
'ascii'
)
except
UnicodeDecodeError
:
# we have to reject the file because iniparse chokes on non-ascii,
# and similar packages (cfgparse, INITools etc) have issues with
# multiline values, like certificates, or do not retain comments (ConfigParser).
logger
.
critical
(
'Cannot create configuration file (bad template).'
)
sys
.
exit
(
1
)
fout
.
write
(
req
.
content
)
return
path
...
...
@@ -231,11 +239,10 @@ def slapconfig(conf):
# Put slapos configuration file
config_path
=
os
.
path
.
join
(
slap_conf_dir
,
'slapos.cfg'
)
conf
.
logger
.
info
(
'Creating slap configuration: %s'
,
config_path
)
# Get example configuration file
slapos_cfg_example
=
get_slapos_conf_example
()
new_configp
=
ConfigParser
.
RawConfigParser
()
slapos_cfg_example
=
get_slapos_conf_example
(
conf
.
logger
)
new_configp
=
iniparse
.
RawConfigParser
()
new_configp
.
read
(
slapos_cfg_example
)
os
.
remove
(
slapos_cfg_example
)
...
...
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