Esempio n. 1
0
 def release(self):
     self.rewindable = []
     self.non_rewindable = []
     for step in self.instances:
         self.log.info(screen_header(step))
         try:
             step()
         except StopRelease as e:
             self.log.critical(
                 'Release process stopped at step {0}:\n{1}'.format(
                     step, e))
             self.rewind()
             from sys import exit
             exit(step.ERROR_CODE)
         except Exception:
             self.log.debug('Noooo!!!', exc_info=True)
             self.rewind()
             raise
         else:
             if step.success and hasattr(step, 'no_rollback'):
                 self.non_rewindable.append(step.no_rollback)
             elif step.success and hasattr(step, 'rollback'):
                 self.rewindable.append(step)
     self.log.info(
         'Successfully released version {0}. '
         'Sorry for the convenience, mcdonc!'.format(self.the_version))
Esempio n. 2
0
 def rewind(self):
     say = self.log.critical
     say('\n' + screen_header('ROLLBACK', decor='*'))
     # Some steps offer a warning because they cannot be rolled back.
     say('\n'.join(self.non_rewindable))              # Display them.
     if not self.rewindable:
         say('No steps to roll back, but the release process FAILED.')
         return
     steps = list(reversed(self.rewindable))
     print('I am about to roll back the following steps:\n{0}'.format(
         ', '.join([str(step) for step in steps])))
     if not bool_input('Continue?', default=True):
         return
     for step in steps:
         self.log.critical(screen_header('ROLLBACK {0}'.format(step)))
         try:
             step.rollback()
         except Exception as e:
             self.log.error('Could not roll back step {0}:\n{1}'
                 .format(step, str(e)))