當前位置: 首頁>>代碼示例>>Python>>正文


Python winerror.ERROR_ALREADY_EXISTS屬性代碼示例

本文整理匯總了Python中winerror.ERROR_ALREADY_EXISTS屬性的典型用法代碼示例。如果您正苦於以下問題:Python winerror.ERROR_ALREADY_EXISTS屬性的具體用法?Python winerror.ERROR_ALREADY_EXISTS怎麽用?Python winerror.ERROR_ALREADY_EXISTS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在winerror的用法示例。


在下文中一共展示了winerror.ERROR_ALREADY_EXISTS屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __acquire

# 需要導入模塊: import winerror [as 別名]
# 或者: from winerror import ERROR_ALREADY_EXISTS [as 別名]
def __acquire(self):
        '''
        Attempts to acquire the mutex
        @raise MutexAlreadyAcquired
        '''

        mutex = win32event.CreateMutex(None, 1, self.MUTEX_NAME)
        if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
            raise MutexAlreadyAcquired()

        return mutex


# ================================================================
# = MutexAlreadyAcquired Exception Class
# =============================================================== 
開發者ID:sithis993,項目名稱:Crypter,代碼行數:18,代碼來源:Mutex.py

示例2: testLongLongPathNames

# 需要導入模塊: import winerror [as 別名]
# 或者: from winerror import ERROR_ALREADY_EXISTS [as 別名]
def testLongLongPathNames(self):
        # We need filename where the FQN is > 256 - simplest way is to create a
        # 250 character directory in the cwd (except - cwd may be on a drive
        # not supporting \\\\?\\ (eg, network share) - so use temp.
        import win32file
        basename = "a" * 250
        # but we need to ensure we use the 'long' version of the
        # temp dir for later comparison.
        long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir())
        fname = "\\\\?\\" + os.path.join(long_temp_dir, basename)
        try:
            win32file.CreateDirectoryW(fname, None)
        except win32api.error, details:
            if details.winerror!=winerror.ERROR_ALREADY_EXISTS:
                raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:17,代碼來源:test_win32api.py

示例3: create

# 需要導入模塊: import winerror [as 別名]
# 或者: from winerror import ERROR_ALREADY_EXISTS [as 別名]
def create(self):
        obtain_mutex = 1
        mutex = win32event.CreateMutex(None, obtain_mutex, app_name)

        # prevent the PyHANDLE from going out of scope, ints are fine
        self.mutex = int(mutex)
        mutex.Detach()

        lasterror = win32api.GetLastError()
        
        if lasterror == winerror.ERROR_ALREADY_EXISTS:
            takeover = 0

            try:
                # if the mutex already exists, discover which port to connect to.
                # if something goes wrong with that, tell us to take over the
                # role of master
                takeover = self.discover_sic_socket()
            except:
                pass
            
            if not takeover:
                raise BTFailure(_("Global mutex already created."))

        self.master = 1

        # lazy free port code
        port_limit = 50000
        while self.port < port_limit:
            try:
                controlsocket = self.rawserver.create_serversocket(self.port,
                                                                   '127.0.0.1')
                self.controlsocket = controlsocket
                break
            except socket.error, e:
                self.port += 1 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:38,代碼來源:IPC.py

示例4: IsAnotherInstanceRunning

# 需要導入模塊: import winerror [as 別名]
# 或者: from winerror import ERROR_ALREADY_EXISTS [as 別名]
def IsAnotherInstanceRunning(self):
        return winerror.ERROR_ALREADY_EXISTS == self.lasterror 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:4,代碼來源:IPC.py

示例5: aleradyrunning

# 需要導入模塊: import winerror [as 別名]
# 或者: from winerror import ERROR_ALREADY_EXISTS [as 別名]
def aleradyrunning(self):
        return (self.lasterror == ERROR_ALREADY_EXISTS) 
開發者ID:Jackeriss,項目名稱:Email_My_PC,代碼行數:4,代碼來源:singleinstance.py


注:本文中的winerror.ERROR_ALREADY_EXISTS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。