home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1910 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.9 KB  |  57 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import inspect
  5. import thread
  6.  
  7. try:
  8.     import ctypes
  9.     HAS_CTYPES = True
  10. except ImportError:
  11.     HAS_CTYPES = False
  12.  
  13. from IPython.genutils import Term, warn, error, flag_calls, ask_yes_no
  14. KBINT = False
  15. USE_TK = False
  16. MAIN_THREAD_ID = thread.get_ident()
  17. CODE_RUN = None
  18. if HAS_CTYPES:
  19.     
  20.     def _async_raise(tid, exctype):
  21.         if not inspect.isclass(exctype):
  22.             raise TypeError('Only types can be raised (not instances)')
  23.         inspect.isclass(exctype)
  24.         res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
  25.         if res == 0:
  26.             raise ValueError('invalid thread id')
  27.         res == 0
  28.         if res != 1:
  29.             ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0)
  30.             raise SystemError('PyThreadState_SetAsyncExc failed')
  31.         res != 1
  32.  
  33.     
  34.     def sigint_handler(signum, stack_frame):
  35.         global KBINT
  36.         if CODE_RUN:
  37.             _async_raise(MAIN_THREAD_ID, KeyboardInterrupt)
  38.         else:
  39.             KBINT = True
  40.             print '\nKeyboardInterrupt - Press <Enter> to continue.',
  41.             Term.cout.flush()
  42.  
  43. else:
  44.     
  45.     def sigint_handler(signum, stack_frame):
  46.         global KBINT
  47.         print '\nKeyboardInterrupt - Press <Enter> to continue.',
  48.         Term.cout.flush()
  49.         KBINT = True
  50.  
  51.  
  52. def run_in_frontend(src):
  53.     if src.startswith('_ip.system(') and '\n' not in src:
  54.         return True
  55.     return False
  56.  
  57.