/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-05 11:32:59 UTC
  • mfrom: (6336.2.3 is_environment_error)
  • Revision ID: pqm@pqm.ubuntu.com-20111205113259-ias55e1z6dsn2ksp
(gz) Add is_environment_error() to check if exceptions are due to the
 process environment (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        create_buffer = ctypes.create_unicode_buffer
69
69
        suffix = 'W'
70
70
try:
71
 
    import win32file
72
71
    import pywintypes
73
 
    has_win32file = True
74
 
except ImportError:
75
 
    has_win32file = False
76
 
try:
77
 
    import win32api
78
 
    has_win32api = True
79
 
except ImportError:
80
 
    has_win32api = False
 
72
    has_pywintypes = True
 
73
except ImportError:
 
74
    has_pywintypes = has_win32file = has_win32api = False
 
75
else:
 
76
    try:
 
77
        import win32file
 
78
        has_win32file = True
 
79
    except ImportError:
 
80
        has_win32file = False
 
81
    try:
 
82
        import win32api
 
83
        has_win32api = True
 
84
    except ImportError:
 
85
        has_win32api = False
81
86
 
82
87
# pulling in win32com.shell is a bit of overhead, and normally we don't need
83
88
# it as ctypes is preferred and common.  lazy_imports and "optional"
615
620
        _CloseHandle(handle)
616
621
        return False
617
622
    is_local_pid_dead = _ctypes_is_local_pid_dead
 
623
 
 
624
 
 
625
def _is_pywintypes_error(evalue):
 
626
    """True if exception instance is an error from pywin32"""
 
627
    if has_pywintypes and isinstance(evalue, pywintypes.error):
 
628
        return True
 
629
    return False