home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1952 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  1.8 KB  |  47 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __docformat__ = 'restructuredtext en'
  5. import cPickle as pickle
  6. from twisted.python.failure import Failure
  7. from twisted.python import failure
  8. import threading
  9. import sys
  10. from IPython.kernel import pbconfig
  11. from IPython.kernel.error import PBMessageSizeError, UnpickleableException
  12.  
  13. def packageFailure(f):
  14.     f.cleanFailure()
  15.     
  16.     try:
  17.         pString = pickle.dumps(f, 2)
  18.     except pickle.PicklingError:
  19.         f.type = UnpickleableException
  20.         f.value = UnpickleableException(str(f.type) + ': ' + str(f.value))
  21.         pString = pickle.dumps(f, 2)
  22.  
  23.     return 'FAILURE:' + pString
  24.  
  25.  
  26. def unpackageFailure(r):
  27.     if isinstance(r, str):
  28.         if r.startswith('FAILURE:'):
  29.             
  30.             try:
  31.                 result = pickle.loads(r[8:])
  32.             except pickle.PickleError:
  33.                 return failure.Failure(FailureUnpickleable('Could not unpickle failure.'))
  34.  
  35.             return result
  36.         r.startswith('FAILURE:')
  37.     
  38.     return r
  39.  
  40.  
  41. def checkMessageSize(m, info):
  42.     if len(m) > pbconfig.banana.SIZE_LIMIT:
  43.         s = 'Objects too big to transfer:\nNames:            %s\nActual Size (kB): %d\nSIZE_LIMIT  (kB): %d\n* SIZE_LIMIT can be set in kernel.pbconfig' % (info, len(m) / 1024, pbconfig.banana.SIZE_LIMIT / 1024)
  44.         return Failure(PBMessageSizeError(s))
  45.     return m
  46.  
  47.