当前位置: 首页>>代码示例>>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;未经允许,请勿转载。