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


Python platform.isWindows方法代码示例

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


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

示例1: test_invalidDescriptor

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def test_invalidDescriptor(self):
        """
        An implementation of L{IReactorSocket.adoptStreamPort} raises
        L{socket.error} if passed an integer which is not associated with a
        socket.
        """
        reactor = self.buildReactor()

        probe = socket.socket()
        fileno = probe.fileno()
        probe.close()

        exc = self.assertRaises(
            socket.error,
            reactor.adoptStreamPort, fileno, socket.AF_INET, ServerFactory())
        if platform.isWindows() and _PY3:
            self.assertEqual(exc.args[0], errno.WSAENOTSOCK)
        else:
            self.assertEqual(exc.args[0], errno.EBADF) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_socket.py

示例2: getInodeNumber

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getInodeNumber(self):
        """
        Retrieve the file serial number, also called inode number, which
        distinguishes this file from all other files on the same device.

        @raise NotImplementedError: if the platform is Windows, since the
            inode number would be a dummy value for all files in Windows
        @return: a number representing the file serial number
        @rtype: L{int}
        @since: 11.0
        """
        if platform.isWindows():
            raise NotImplementedError

        st = self._statinfo
        if not st:
            self.restat()
            st = self._statinfo
        return st.st_ino 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:filepath.py

示例3: getNumberOfHardLinks

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getNumberOfHardLinks(self):
        """
        Retrieves the number of hard links to the file.

        This count keeps track of how many directories have entries for this
        file. If the count is ever decremented to zero then the file itself is
        discarded as soon as no process still holds it open.  Symbolic links
        are not counted in the total.

        @raise NotImplementedError: if the platform is Windows, since Windows
            doesn't maintain a link count for directories, and L{os.stat} does
            not set C{st_nlink} on Windows anyway.
        @return: the number of hard links to the file
        @rtype: L{int}
        @since: 11.0
        """
        if platform.isWindows():
            raise NotImplementedError

        st = self._statinfo
        if not st:
            self.restat()
            st = self._statinfo
        return st.st_nlink 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:filepath.py

示例4: getUserID

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getUserID(self):
        """
        Returns the user ID of the file's owner.

        @raise NotImplementedError: if the platform is Windows, since the UID
            is always 0 on Windows
        @return: the user ID of the file's owner
        @rtype: L{int}
        @since: 11.0
        """
        if platform.isWindows():
            raise NotImplementedError

        st = self._statinfo
        if not st:
            self.restat()
            st = self._statinfo
        return st.st_uid 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:filepath.py

示例5: getGroupID

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getGroupID(self):
        """
        Returns the group ID of the file.

        @raise NotImplementedError: if the platform is Windows, since the GID
            is always 0 on windows
        @return: the group ID of the file
        @rtype: L{int}
        @since: 11.0
        """
        if platform.isWindows():
            raise NotImplementedError

        st = self._statinfo
        if not st:
            self.restat()
            st = self._statinfo
        return st.st_gid 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:filepath.py

示例6: _cbLostConns

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def _cbLostConns(self, results):
        (sSuccess, sResult), (cSuccess, cResult) = results

        self.assertFalse(sSuccess)
        self.assertFalse(cSuccess)

        acceptableErrors = [SSL.Error]

        # Rather than getting a verification failure on Windows, we are getting
        # a connection failure.  Without something like sslverify proxying
        # in-between we can't fix up the platform's errors, so let's just
        # specifically say it is only OK in this one case to keep the tests
        # passing.  Normally we'd like to be as strict as possible here, so
        # we're not going to allow this to report errors incorrectly on any
        # other platforms.

        if platform.isWindows():
            from twisted.internet.error import ConnectionLost
            acceptableErrors.append(ConnectionLost)

        sResult.trap(*acceptableErrors)
        cResult.trap(*acceptableErrors)

        return self.serverPort.stopListening() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:test_ssl.py

示例7: getDevice

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getDevice(self):
        """
        Retrieves the device containing the file.  The inode number and device
        number together uniquely identify the file, but the device number is
        not necessarily consistent across reboots or system crashes.

        @raise NotImplementedError: if the platform is Windows, since the
            device number would be 0 for all partitions on a Windows platform

        @return: a number representing the device
        @rtype: L{int}

        @since: 11.0
        """
        if platform.isWindows():
            raise NotImplementedError

        st = self._statinfo
        if not st:
            self.restat()
            st = self._statinfo
        return st.st_dev 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:24,代码来源:filepath.py

示例8: _cbLostConns

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def _cbLostConns(self, results):
        (sSuccess, sResult), (cSuccess, cResult) = results

        self.failIf(sSuccess)
        self.failIf(cSuccess)

        acceptableErrors = [SSL.Error]

        # Rather than getting a verification failure on Windows, we are getting
        # a connection failure.  Without something like sslverify proxying
        # in-between we can't fix up the platform's errors, so let's just
        # specifically say it is only OK in this one case to keep the tests
        # passing.  Normally we'd like to be as strict as possible here, so
        # we're not going to allow this to report errors incorrectly on any
        # other platforms.

        if platform.isWindows():
            from twisted.internet.error import ConnectionLost
            acceptableErrors.append(ConnectionLost)

        sResult.trap(*acceptableErrors)
        cResult.trap(*acceptableErrors)

        return self.serverPort.stopListening() 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:26,代码来源:test_ssl.py

示例9: processEnded

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def processEnded(self, reason):
        """
        Check that the process exited in the way expected and that the required
        text has been found in its output and fire the result L{Deferred} with
        either a value or a failure.
        """
        self._complete, result = None, self._complete
        if self._success:
            if platform.isWindows() or (
                # Windows can't tell that we SIGTERM'd it, so sorry.
                reason.check(ProcessTerminated) and
                reason.value.signal == signal.SIGTERM):
                result.callback(None)
                return
        # Something went wrong.
        result.errback(reason) 
开发者ID:twisted,项目名称:axiom,代码行数:18,代码来源:test_axiomatic.py

示例10: getArguments

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getArguments(self, store, args):
        run = store.dbdir.child("run")
        logs = run.child("logs")
        handleLogfile = True
        handlePidfile = True

        for arg in args:
            if arg.startswith("--logfile=") or arg in (
                "-l", "--logfile", "-n", "--nodaemon"
            ):
                handleLogfile = False
            elif arg.startswith("--pidfile=") or arg == "--pidfile":
                handlePidfile = False

        if handleLogfile:
            if not logs.exists():
                logs.makedirs()
            args.extend(["--logfile", logs.child("axiomatic.log").path])

        if not platform.isWindows() and handlePidfile:
            args.extend(["--pidfile", run.child("axiomatic.pid").path])
        args.extend(["axiomatic-start", "--dbdir", store.dbdir.path])
        if store.journalMode is not None:
            args.extend(['--journal-mode', store.journalMode.encode('ascii')])
        return args 
开发者ID:twisted,项目名称:axiom,代码行数:27,代码来源:axiomatic.py

示例11: test_stopOnlyCloses

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def test_stopOnlyCloses(self):
        """
        When the L{IListeningPort} returned by
        L{IReactorSocket.adoptStreamPort} is stopped using
        C{stopListening}, the underlying socket is closed but not
        shutdown.  This allows another process which still has a
        reference to it to continue accepting connections over it.
        """
        reactor = self.buildReactor()

        portSocket = socket.socket()
        self.addCleanup(portSocket.close)

        portSocket.bind(("127.0.0.1", 0))
        portSocket.listen(1)
        portSocket.setblocking(False)

        # The file descriptor is duplicated by adoptStreamPort
        port = reactor.adoptStreamPort(
            portSocket.fileno(), portSocket.family, ServerFactory())
        d = port.stopListening()
        def stopped(ignored):
            # Should still be possible to accept a connection on
            # portSocket.  If it was shutdown, the exception would be
            # EINVAL instead.
            exc = self.assertRaises(socket.error, portSocket.accept)
            if platform.isWindows() and _PY3:
                self.assertEqual(exc.args[0], errno.WSAEWOULDBLOCK)
            else:
                self.assertEqual(exc.args[0], errno.EAGAIN)
        d.addCallback(stopped)
        d.addErrback(err, "Failed to accept on original port.")

        needsRunningReactor(
            reactor,
            lambda: d.addCallback(lambda ignored: reactor.stop()))

        reactor.run() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:40,代码来源:test_socket.py

示例12: getProgramsMenuPath

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def getProgramsMenuPath():
    """
    Get the path to the Programs menu.

    Probably will break on non-US Windows.

    @return: the filesystem location of the common Start Menu->Programs.
    @rtype: L{str}
    """
    if not platform.isWindows():
        return "C:\\Windows\\Start Menu\\Programs"
    keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders'
    hShellFolders = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
                                          keyname, 0, win32con.KEY_READ)
    return win32api.RegQueryValueEx(hShellFolders, 'Common Programs')[0] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:win32.py

示例13: setUp

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def setUp(self):
        """
        Create a file that will have known line numbers when emitting warnings.
        """
        self.package = FilePath(self.mktemp().encode("utf-8")
                                ).child(b'twisted_private_helper')
        self.package.makedirs()
        self.package.child(b'__init__.py').setContent(b'')
        self.package.child(b'module.py').setContent(b'''
"A module string"

from twisted.python import deprecate

def testFunction():
    "A doc string"
    a = 1 + 2
    return a

def callTestFunction():
    b = testFunction()
    if b == 3:
        deprecate.warnAboutFunction(testFunction, "A Warning String")
''')
        # Python 3 doesn't accept bytes in sys.path:
        packagePath = self.package.parent().path.decode("utf-8")
        sys.path.insert(0, packagePath)
        self.addCleanup(sys.path.remove, packagePath)

        modules = sys.modules.copy()
        self.addCleanup(
            lambda: (sys.modules.clear(), sys.modules.update(modules)))

        # On Windows on Python 3, most FilePath interactions produce
        # DeprecationWarnings, so flush them here so that they don't interfere
        # with the tests.
        if platform.isWindows() and _PY3:
            self.flushWarnings() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:39,代码来源:test_deprecate.py

示例14: test_getProgramsMenuPath

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def test_getProgramsMenuPath(self):
        """
        L{getProgramsMenuPath} guesses the programs menu path on non-win32
        platforms. On non-win32 it will try to figure out the path by
        examining the registry.
        """
        if not platform.isWindows():
            self.assertEqual(win32.getProgramsMenuPath(),
                "C:\\Windows\\Start Menu\\Programs")
        else:
            self.assertIsInstance(win32.getProgramsMenuPath(), str) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:test_win32.py

示例15: child

# 需要导入模块: from twisted.python.runtime import platform [as 别名]
# 或者: from twisted.python.runtime.platform import isWindows [as 别名]
def child(self, path):
        """
        Create and return a new L{FilePath} representing a path contained by
        C{self}.

        @param path: The base name of the new L{FilePath}.  If this contains
            directory separators or parent references it will be rejected.
        @type path: L{bytes} or L{unicode}

        @raise InsecurePath: If the result of combining this path with C{path}
            would result in a path which is not a direct child of this path.

        @return: The child path.
        @rtype: L{FilePath} with a mode equal to the type of C{path}.
        """
        colon = _coerceToFilesystemEncoding(path, ":")
        sep =  _coerceToFilesystemEncoding(path, os.sep)
        ourPath = self._getPathAsSameTypeAs(path)

        if platform.isWindows() and path.count(colon):
            # Catch paths like C:blah that don't have a slash
            raise InsecurePath("%r contains a colon." % (path,))

        norm = normpath(path)
        if sep in norm:
            raise InsecurePath("%r contains one or more directory separators" %
                               (path,))

        newpath = abspath(joinpath(ourPath, norm))
        if not newpath.startswith(ourPath):
            raise InsecurePath("%r is not a child of %s" %
                               (newpath, ourPath))
        return self.clonePath(newpath) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:35,代码来源:filepath.py


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