当前位置: 首页>>代码示例>>Python>>正文


Python win32file.UnlockFileEx方法代码示例

本文整理汇总了Python中win32file.UnlockFileEx方法的典型用法代码示例。如果您正苦于以下问题:Python win32file.UnlockFileEx方法的具体用法?Python win32file.UnlockFileEx怎么用?Python win32file.UnlockFileEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32file的用法示例。


在下文中一共展示了win32file.UnlockFileEx方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unlock_and_close

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock_and_close(self):
      """Close and unlock the file using the win32 primitive."""
      if self._locked:
        try:
          hfile = win32file._get_osfhandle(self._fh.fileno())
          win32file.UnlockFileEx(hfile, 0, -0x10000, pywintypes.OVERLAPPED())
        except pywintypes.error as e:
          if e[0] != _Win32Opener.FILE_ALREADY_UNLOCKED_ERROR:
            raise
      self._locked = False
      if self._fh:
        self._fh.close() 
开发者ID:mortcanty,项目名称:earthengine,代码行数:14,代码来源:locked_file.py

示例2: unlock_and_close

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock_and_close(self):
      """Close and unlock the file using the win32 primitive."""
      if self._locked:
        try:
          hfile = win32file._get_osfhandle(self._fh.fileno())
          win32file.UnlockFileEx(hfile, 0, -0x10000, pywintypes.OVERLAPPED())
        except pywintypes.error, e:
          if e[0] != _Win32Opener.FILE_ALREADY_UNLOCKED_ERROR:
            raise 
开发者ID:splunk,项目名称:splunk-ref-pas-code,代码行数:11,代码来源:locked_file.py

示例3: _UnlockImplWin

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def _UnlockImplWin(target_file):
  hfile = win32file._get_osfhandle(target_file.fileno())
  try:
    win32file.UnlockFileEx(hfile, 0, -0x10000, _OVERLAPPED)
  except pywintypes.error, exc_value:
    if exc_value[0] == 158:
      # error: (158, 'UnlockFileEx', 'The segment is already unlocked.')
      # To match the 'posix' implementation, silently ignore this error
      pass
    else:
      # Q:  Are there exceptions/codes we should be dealing with here?
      raise 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:14,代码来源:lock.py

示例4: unlock_and_close

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock_and_close(self):
        """Close and unlock the file using the win32 primitive."""
        if self._locked:
            try:
                hfile = win32file._get_osfhandle(self._fh.fileno())
                win32file.UnlockFileEx(hfile, 0, -0x10000,
                                       pywintypes.OVERLAPPED())
            except pywintypes.error as e:
                if e[0] != _Win32Opener.FILE_ALREADY_UNLOCKED_ERROR:
                    raise
        self._locked = False
        if self._fh:
            self._fh.close() 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:15,代码来源:_win32_opener.py

示例5: unlock

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock(file):
        hfile = win32file._get_osfhandle(_getfd(file))
        try:
            win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)
        except pywintypes.error, exc_value:
            if exc_value[0] == 158:
                # error: (158, 'UnlockFileEx', 'The segment is already unlocked.')
                # To match the 'posix' implementation, silently ignore this error
                pass
            else:
                # Q:  Are there exceptions/codes we should be dealing with here?
                raise 
开发者ID:harryliu,项目名称:edwin,代码行数:14,代码来源:portalocker.py

示例6: unlock

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock(file):
        hfile = win32file._get_osfhandle(fd(file))
        win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:5,代码来源:locks.py

示例7: unlock_and_close

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock_and_close(self):
            """Close and unlock the file using the win32 primitive."""
            if self._locked:
                try:
                    hfile = win32file._get_osfhandle(self._fh.fileno())
                    win32file.UnlockFileEx(hfile, 0, -0x10000,
                                           pywintypes.OVERLAPPED())
                except pywintypes.error as e:
                    if e[0] != _Win32Opener.FILE_ALREADY_UNLOCKED_ERROR:
                        raise
            self._locked = False
            if self._fh:
                self._fh.close() 
开发者ID:luci,项目名称:luci-py,代码行数:15,代码来源:locked_file.py

示例8: unlock

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock(file_):
        try:
            savepos = file_.tell()
            if savepos:
                file_.seek(0)

            try:
                msvcrt.locking(file_.fileno(), constants.LOCK_UN, lock_length)
            except IOError as exc_value:
                if exc_value.strerror == 'Permission denied':
                    import pywintypes
                    import win32file
                    import winerror
                    __overlapped = pywintypes.OVERLAPPED()
                    hfile = win32file._get_osfhandle(file_.fileno())
                    try:
                        win32file.UnlockFileEx(
                            hfile, 0, -0x10000, __overlapped)
                    except pywintypes.error as exc_value:
                        if exc_value.winerror == winerror.ERROR_NOT_LOCKED:
                            # error: (158, 'UnlockFileEx',
                            #         'The segment is already unlocked.')
                            # To match the 'posix' implementation, silently
                            # ignore this error
                            pass
                        else:
                            # Q:  Are there exceptions/codes we should be
                            # dealing with here?
                            raise
                else:
                    raise exceptions.LockException(
                        exceptions.LockException.LOCK_FAILED,
                        exc_value.strerror,
                        fh=file_)
            finally:
                if savepos:
                    file_.seek(savepos)
        except IOError as exc_value:
            raise exceptions.LockException(
                exceptions.LockException.LOCK_FAILED, exc_value.strerror,
                fh=file_) 
开发者ID:allegroai,项目名称:trains,代码行数:43,代码来源:portalocker.py

示例9: unlock

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock(file):
        hfile = win32file._get_osfhandle(file.fileno())
        win32file.UnlockFileEx(hfile, 0, 0x7fff0000, __overlapped) 
开发者ID:uwdata,项目名称:termite-visualizations,代码行数:5,代码来源:portalocker.py

示例10: unlock

# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import UnlockFileEx [as 别名]
def unlock(file):
        hfile = win32file._get_osfhandle(file.fileno())
        try:
            win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)
        except pywintypes.error, exc_value:
            if exc_value[0] == 158:
                # error: (158, 'UnlockFileEx', 'The segment is already unlocked.')
                # To match the 'posix' implementation, silently ignore this error
                pass
            else:
                # Q:  Are there exceptions/codes we should be dealing with here?
                raise 
开发者ID:zstackio,项目名称:zstack-utility,代码行数:14,代码来源:portalocker.py


注:本文中的win32file.UnlockFileEx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。