Example #1
0
def display_warning(warning):    
    """Shows a warning in fancy colours if supported"""
    term = TerminalController()
    try:
        print term.render('${YELLOW}%s${NORMAL}' % warning)
    except ValueError:
        print warning
Example #2
0
 def __init__(self, value=""):
     """Set's the message on instantiation"""
     self.term = TerminalController()
     
     if not hasattr(self, "message_prefix"):
         self.message_prefix = "Suitcase Error:"
     self.message = "%s %s" % (self.message_prefix, value)
Example #3
0
class SuitcaseException(Exception):
    
    """The generic suitcase exception class
    
    This exception is raised when your suitcase falls open and spills 
    everything on the floor!
    
    """
    
    def __init__(self, value=""):
        """Set's the message on instantiation"""
        self.term = TerminalController()
        
        if not hasattr(self, "message_prefix"):
            self.message_prefix = "Suitcase Error:"
        self.message = "%s %s" % (self.message_prefix, value)
        
    def __str__(self):
        """Returns the error message"""
        try:
            return self.term.render('${RED}%s${NORMAL}' % self.message)
        except ValueError:
            return self.message