~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/console.py

  • Committer: David Coles
  • Date: 2009-12-08 02:10:26 UTC
  • Revision ID: coles.david@gmail.com-20091208021026-3a27ecdzm49y39me
Configuration documentation - fixing a few references

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
class ConsoleError(Exception):
38
38
    """ The console failed in some way. This is bad. """
39
 
    pass
 
39
    def __init__(self, value):
 
40
        self.value = value
 
41
    def __str__(self):
 
42
        return repr(self.value)
40
43
 
41
44
class ConsoleException(Exception):
42
45
    """ The code being exectuted on the console returned an exception. 
43
46
    """
44
 
    pass
 
47
    def __init__(self, value):
 
48
        self.value = value
 
49
    def __str__(self):
 
50
        return repr(self.value)
45
51
 
46
52
class TruncateStringIO(StringIO.StringIO):
47
53
    """ A class that wraps around StringIO and truncates the buffer when the 
207
213
            # Couldn't decode the JSON
208
214
            raise ConsoleError(
209
215
                "Could not understand the python console response")
210
 
        except chat.ProtocolError, e:
211
 
            raise ConsoleError(*e.args)
212
216
 
213
217
        return response
214
218
 
293
297
              
294
298
        # Unpickle any exceptions
295
299
        if 'exception' in execute:
296
 
            execute['exception'] = cPickle.loads(execute['exception'])
297
 
        return execute
 
300
            return cPickle.loads(execute['exception'])
 
301
        else:
 
302
            return execute
298
303
 
299
304
 
300
305
    def set_vars(self, variables):