Better error message on task order errors

This commit is contained in:
Anders Ingemann 2013-08-11 18:25:05 +02:00
parent 04b879a53c
commit 7318240f59
3 changed files with 15 additions and 17 deletions

View file

@ -1,7 +1,8 @@
class Phase(object):
def __init__(self, description):
def __init__(self, name, description):
self.name = name
self.description = description
def pos(self):
@ -12,7 +13,4 @@ class Phase(object):
return self.pos() - other.pos()
def __str__(self):
return '{name}'.format(name=self.__class__.__name__)
def __repr__(self):
return self.__str__()
return self.name

View file

@ -21,12 +21,12 @@ class Task(object):
for task in self.before:
if self.phase > task.phase:
msg = ("The task {self} is specified as running before {other}, "
"but its phase {phase} lies after the phase {other_phase}"
"but its phase '{phase}' lies after the phase '{other_phase}'"
.format(self=type(self), other=task, phase=self.phase, other_phase=task.phase))
raise TaskListError(msg)
for task in self.after:
if self.phase < task.phase:
msg = ("The task {self} is specified as running after {other}, "
"but its phase {phase} lies before the phase {other_phase}"
"but its phase '{phase}' lies before the phase '{other_phase}'"
.format(self=type(self), other=task, phase=self.phase, other_phase=task.phase))
raise TaskListError(msg)

View file

@ -1,15 +1,15 @@
from base import Phase
preparation = Phase('Initializing connections, fetching data etc.')
volume_creation = Phase('Creating the volume to bootstrap onto')
volume_preparation = Phase('Formatting the bootstrap volume')
volume_mounting = Phase('Mounting bootstrap volume')
os_installation = Phase('Installing the operating system')
system_modification = Phase('Installing software, modifying configuration files etc.')
system_cleaning = Phase('Removing sensitive data, temporary files and other leftovers')
volume_unmounting = Phase('Unmounting the bootstrap volume')
image_registration = Phase('Uploading/Registering with the provider')
cleaning = Phase('Removing temporary files')
preparation = Phase('Preparation', 'Initializing connections, fetching data etc.')
volume_creation = Phase('Volume creation', 'Creating the volume to bootstrap onto')
volume_preparation = Phase('Volume preparation', 'Formatting the bootstrap volume')
volume_mounting = Phase('Volume mounting', 'Mounting bootstrap volume')
os_installation = Phase('OS installation', 'Installing the operating system')
system_modification = Phase('System modification', 'Installing software, modifying configuration files etc.')
system_cleaning = Phase('System cleaning', 'Removing sensitive data, temporary files and other leftovers')
volume_unmounting = Phase('Volume unmounting', 'Unmounting the bootstrap volume')
image_registration = Phase('Image registration', 'Uploading/Registering with the provider')
cleaning = Phase('Cleaning', 'Removing temporary files')
order = [preparation,
volume_creation,