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
Nicolas Wavrant
slapos.core
Commits
d34a193e
Commit
d34a193e
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exception handling cleanup: 'as' syntax, removed useless catch
parent
fec3622f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
32 deletions
+28
-32
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+3
-3
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+25
-29
No files found.
slapos/grid/SlapObject.py
View file @
d34a193e
...
...
@@ -368,7 +368,7 @@ class Partition(object):
self
.
logger
.
debug
(
"Copying %r to %r"
%
(
template_location
,
config_location
))
try
:
shutil
.
copy
(
template_location
,
config_location
)
except
IOError
,
e
:
except
IOError
as
e
:
# Template not found on SR, we notify user.
raise
IOError
(
'Software Release %s is not correctly installed.
\
n
'
'%s'
%
(
self
.
software_release_url
,
e
))
...
...
@@ -480,7 +480,7 @@ class Partition(object):
partition_id
=
self
.
computer_partition
.
getId
()
try
:
supervisor
.
startProcessGroup
(
partition_id
,
False
)
except
xmlrpclib
.
Fault
,
e
:
except
xmlrpclib
.
Fault
as
e
:
if
e
.
faultString
.
startswith
(
'BAD_NAME:'
):
self
.
logger
.
info
(
"Nothing to start on %s..."
%
self
.
computer_partition
.
getId
())
...
...
@@ -493,7 +493,7 @@ class Partition(object):
try
:
supervisor
=
self
.
getSupervisorRPC
()
supervisor
.
stopProcessGroup
(
partition_id
,
False
)
except
xmlrpclib
.
Fault
,
e
:
except
xmlrpclib
.
Fault
as
e
:
if
e
.
faultString
.
startswith
(
'BAD_NAME:'
):
self
.
logger
.
info
(
'Partition %s not known in supervisord, ignoring'
%
partition_id
)
else
:
...
...
slapos/grid/slapgrid.py
View file @
d34a193e
...
...
@@ -51,8 +51,7 @@ from lxml import etree
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
ServerError
from
slapos.grid.exception
import
BuildoutFailedError
from
slapos.grid.SlapObject
import
Software
,
Partition
,
WrongPermissionError
,
\
PathDoesNotExistError
from
slapos.grid.SlapObject
import
Software
,
Partition
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.utils
import
(
md5digest
,
createPrivateDirectory
,
dropPrivileges
,
setRunning
,
setFinished
,
SlapPopen
,
updateFile
)
...
...
@@ -504,7 +503,6 @@ class Slapgrid(object):
error
=
"%s does not exist."
%
self
.
instance_root
raise
OSError
(
error
)
# Creates everything needed
try
:
# Creates instance_root structure
createPrivateDirectory
(
self
.
instance_etc_directory
)
createPrivateDirectory
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
))
...
...
@@ -525,8 +523,6 @@ class Slapgrid(object):
'supervisord_logfile_backups'
:
'10'
,
'watchdog_command'
:
self
.
getWatchdogLine
(),
})
except
(
WrongPermissionError
,
PathDoesNotExistError
)
as
error
:
raise
error
def
getComputerPartitionList
(
self
):
try
:
...
...
@@ -872,7 +868,7 @@ class Slapgrid(object):
raise
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
except
BuildoutFailedError
as
exception
:
try
:
computer_partition
.
error
(
exception
)
except
(
SystemExit
,
KeyboardInterrupt
):
...
...
@@ -942,7 +938,7 @@ class Slapgrid(object):
exception
)
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
except
BuildoutFailedError
as
exception
:
clean_run
=
False
try
:
computer_partition
.
error
(
exception
)
...
...
@@ -1020,7 +1016,7 @@ class Slapgrid(object):
for
computer_partition_usage
in
computer_partition_usage_list
:
try
:
root
=
etree
.
fromstring
(
computer_partition_usage
.
usage
)
except
UnicodeError
,
e
:
except
UnicodeError
as
e
:
self
.
logger
.
info
(
"Failed to read %s."
%
(
computer_partition_usage
.
usage
))
self
.
logger
.
error
(
UnicodeError
)
...
...
@@ -1029,7 +1025,7 @@ class Slapgrid(object):
self
.
logger
.
info
(
"Failed to parse %s."
%
(
computer_partition_usage
.
usage
))
self
.
logger
.
error
(
e
)
raise
_formatXMLError
(
e
)
except
Exception
,
e
:
except
Exception
as
e
:
raise
Exception
(
"Failed to generate XML report: %s"
%
e
)
for
movement
in
root
.
findall
(
'movement'
):
...
...
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