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
Xiaowu Zhang
slapos.core
Commits
3650d673
Commit
3650d673
authored
Jan 23, 2012
by
Vincent Pelletier
Committed by
Romain Courteaud
Jan 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify exception definitions.
parent
b3595f08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
37 deletions
+26
-37
slapos/format.py
slapos/format.py
+26
-37
No files found.
slapos/format.py
View file @
3650d673
...
...
@@ -70,18 +70,35 @@ class OS(object):
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
_os
,
name
)
class
SlapError
(
Exception
):
class
UsageError
(
Exception
):
pass
class
NoAddressOnBridge
(
Exception
):
"""
Slap error
Exception raised if there's not address on the bridge to construct IPv6
address with.
Attributes:
brige: String, the name of the bridge.
"""
def
__init__
(
self
,
message
):
self
.
msg
=
message
class
UsageError
(
SlapError
):
pass
def
__init__
(
self
,
bridge
):
super
(
NoAddressOnBridge
,
self
).
__init__
(
'No IPv6 found on bridge %s to construct IPv6 with.'
%
(
bridge
,
)
)
class
ExecError
(
SlapError
):
pass
class
AddressGenerationError
(
Exception
):
"""
Exception raised if the generation of an IPv6 based on the prefix obtained
from the bridge failed.
Attributes:
addr: String, the invalid address the exception is raised for.
"""
def
__init__
(
self
,
addr
):
super
(
AddressGenerationError
,
self
).
__init__
(
'Generated IPv6 %s seems not to be a valid IP.'
%
addr
)
def
callAndRead
(
argument_list
,
raise_on_error
=
True
):
popen
=
subprocess
.
Popen
(
argument_list
,
stdout
=
subprocess
.
PIPE
,
...
...
@@ -139,34 +156,6 @@ def _getDict(instance):
except
AttributeError
:
return
instance
class
Error
(
Exception
):
"Base class for exceptions in this module."
def
__str__
(
self
):
return
self
.
message
class
NoAddressOnBridge
(
Error
):
"""
Exception raised if there's not address on the bridge to construct IPv6
address with.
Attributes:
brige: String, the name of the bridge.
"""
def
__init__
(
self
,
bridge
):
self
.
message
=
'No IPv6 found on bridge %s to construct IPv6 with.'
%
bridge
class
AddressGenerationError
(
Error
):
"""
Exception raised if the generation of an IPv6 based on the prefix obtained
from the bridge failed.
Attributes:
addr: String, the invalid address the exception is raised for.
"""
def
__init__
(
self
,
addr
):
self
.
message
=
'Generated IPv6 %s seems not to be a valid IP.'
%
addr
class
Computer
:
"Object representing the computer"
...
...
@@ -1132,5 +1121,5 @@ def main(*args):
callAndRead
=
logging_callAndRead
run
(
config
)
except
UsageError
,
err
:
print
>>
sys
.
stderr
,
err
.
m
sg
print
>>
sys
.
stderr
,
err
.
m
essage
print
>>
sys
.
stderr
,
"For help use --help"
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