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
Klaus Wölfel
slapos.core
Commits
bd419263
Commit
bd419263
authored
May 21, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed support for 'required=False' in config file
parent
42d75411
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
slapos/cli/config.py
slapos/cli/config.py
+13
-25
No files found.
slapos/cli/config.py
View file @
bd419263
...
...
@@ -28,34 +28,14 @@ class ConfigCommand(Command):
(
self
.
default_config_var
,
self
.
default_config_path
))
return
ap
def
_get_config
(
self
,
cfg_path
,
required
=
False
):
def
fetch_config
(
self
,
args
):
"""
Returns a configuration object if file exists/readable/valid,
None otherwise.
Will raise an error instead of returning None if required is True.
Even if required is False, may still raise an exception from the
configparser if the configuration content is very broken.
We don't catch that exception as it will clearly show what is
wrong with the file.
will raise an error otherwise. The exception may come from the
configparser itself if the configuration content is very broken,
and will clearly show what is wrong with the file.
"""
if
not
os
.
path
.
exists
(
cfg_path
):
if
required
:
raise
ConfigError
(
'Configuration file does not exist: %s'
%
cfg_path
)
else
:
return
None
configp
=
ConfigParser
.
SafeConfigParser
()
if
configp
.
read
(
cfg_path
)
!=
[
cfg_path
]:
# bad permission, etc.
if
required
:
raise
ConfigError
(
'Cannot parse configuration file: %s'
%
cfg_path
)
else
:
return
None
return
configp
def
fetch_config
(
self
,
args
):
if
args
.
cfg
:
cfg_path
=
args
.
cfg
else
:
...
...
@@ -65,7 +45,15 @@ class ConfigCommand(Command):
self
.
log
.
debug
(
'Loading config: %s'
%
cfg_path
)
return
self
.
_get_config
(
cfg_path
,
required
=
True
)
if
not
os
.
path
.
exists
(
cfg_path
):
raise
ConfigError
(
'Configuration file does not exist: %s'
%
cfg_path
)
configp
=
ConfigParser
.
SafeConfigParser
()
if
configp
.
read
(
cfg_path
)
!=
[
cfg_path
]:
# bad permission, etc.
raise
ConfigError
(
'Cannot parse configuration file: %s'
%
cfg_path
)
return
configp
class
ClientConfigCommand
(
ConfigCommand
):
...
...
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