當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。