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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. ignore_termtitle = True
  6.  
  7. try:
  8.     import ctypes
  9.     SetConsoleTitleW = ctypes.windll.kernel32.SetConsoleTitleW
  10.     SetConsoleTitleW.argtypes = [
  11.         ctypes.c_wchar_p]
  12.     
  13.     def set_term_title(title):
  14.         SetConsoleTitleW(title)
  15.  
  16. except ImportError:
  17.     
  18.     def set_term_title(title):
  19.         global ignore_termtitle
  20.         
  21.         try:
  22.             curr = os.getcwd()
  23.             os.chdir('C:')
  24.             ret = os.system('title ' + title)
  25.         finally:
  26.             os.chdir(curr)
  27.  
  28.         if ret:
  29.             ignore_termtitle = True
  30.         
  31.  
  32.  
  33.  
  34. def find_cmd(cmd):
  35.     
  36.     try:
  37.         SearchPath = SearchPath
  38.         import win32api
  39.     except ImportError:
  40.         raise ImportError('you need to have pywin32 installed for this to work')
  41.  
  42.     PATH = os.environ['PATH']
  43.     extensions = [
  44.         '.exe',
  45.         '.com',
  46.         '.bat',
  47.         '.py']
  48.     path = None
  49.     for ext in extensions:
  50.         
  51.         try:
  52.             path = SearchPath(PATH, cmd + ext)[0]
  53.         continue
  54.         continue
  55.  
  56.     
  57.     if path is None:
  58.         raise OSError('command %r not found' % cmd)
  59.     path is None
  60.     return path
  61.  
  62.  
  63. def get_long_path_name(path):
  64.     
  65.     try:
  66.         import ctypes
  67.     except ImportError:
  68.         raise ImportError('you need to have ctypes installed for this to work')
  69.  
  70.     _GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
  71.     _GetLongPathName.argtypes = [
  72.         ctypes.c_wchar_p,
  73.         ctypes.c_wchar_p,
  74.         ctypes.c_uint]
  75.     buf = ctypes.create_unicode_buffer(260)
  76.     rv = _GetLongPathName(path, buf, 260)
  77.     if rv == 0 or rv > 260:
  78.         return path
  79.     return buf.value
  80.  
  81.  
  82. def term_clear():
  83.     os.system('cls')
  84.  
  85.