/
usr
/
lib
/
python3
/
dist-packages
/
twisted
/
python
/
/usr/lib/python3/dist-packages/twisted/python
mkdir
upload
Name
Size
Mode
Actions
test/
-
0755
rm
_pydoctortemplates/
-
0755
rm
__pycache__/
-
0755
rm
compat.py
16931
0644
edit
dl
rm
components.py
14199
0644
edit
dl
rm
constants.py
513
0644
edit
dl
rm
context.py
4054
0644
edit
dl
rm
deprecate.py
27668
0644
edit
dl
rm
failure.py
27007
0644
edit
dl
rm
fakepwd.py
6732
0644
edit
dl
rm
filepath.py
54023
0644
edit
dl
rm
formmethod.py
12107
0644
edit
dl
rm
htmlizer.py
3626
0644
edit
dl
rm
lockfile.py
8026
0644
edit
dl
rm
log.py
22302
0644
edit
dl
rm
logfile.py
10119
0644
edit
dl
rm
modules.py
26715
0644
edit
dl
rm
monkey.py
2164
0644
edit
dl
rm
procutils.py
1371
0644
edit
dl
rm
randbytes.py
3459
0644
edit
dl
rm
rebuild.py
7122
0644
edit
dl
rm
reflect.py
20480
0644
edit
dl
rm
release.py
1104
0644
edit
dl
rm
roots.py
7178
0644
edit
dl
rm
runtime.py
5924
0644
edit
dl
rm
sendmsg.py
2682
0644
edit
dl
rm
shortcut.py
2302
0644
edit
dl
rm
syslog.py
3652
0644
edit
dl
rm
systemd.py
2987
0644
edit
dl
rm
text.py
5417
0644
edit
dl
rm
threadable.py
3327
0644
edit
dl
rm
threadpool.py
10203
0644
edit
dl
rm
twisted-completion.zsh
1371
0644
edit
dl
rm
url.py
244
0644
edit
dl
rm
urlpath.py
8447
0644
edit
dl
rm
usage.py
34577
0644
edit
dl
rm
util.py
27432
0644
edit
dl
rm
versions.py
273
0644
edit
dl
rm
win32.py
4794
0644
edit
dl
rm
zippath.py
9028
0644
edit
dl
rm
zipstream.py
9680
0644
edit
dl
rm
_appdirs.py
820
0644
edit
dl
rm
_inotify.py
3496
0644
edit
dl
rm
_pydoctor.py
6735
0644
edit
dl
rm
_release.py
18879
0644
edit
dl
rm
_shellcomp.py
25279
0644
edit
dl
rm
_textattributes.py
9097
0644
edit
dl
rm
_tzhelper.py
3128
0644
edit
dl
rm
_url.py
228
0644
edit
dl
rm
__init__.py
598
0644
edit
dl
rm
Edit:
/usr/lib/python3/dist-packages/twisted/python/runtime.py
(5924B)
# -*- test-case-name: twisted.python.test.test_runtime -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. __all__ = [ "seconds", "shortPythonVersion", "Platform", "platform", "platformType", ] import os import sys import warnings from time import time as seconds from typing import Optional def shortPythonVersion() -> str: """ Returns the Python version as a dot-separated string. """ return "%s.%s.%s" % sys.version_info[:3] knownPlatforms = { "nt": "win32", "ce": "win32", "posix": "posix", "java": "java", "org.python.modules.os": "java", } class Platform: """ Gives us information about the platform we're running on. """ type: Optional[str] = knownPlatforms.get(os.name) seconds = staticmethod(seconds) _platform = sys.platform def __init__( self, name: Optional[str] = None, platform: Optional[str] = None ) -> None: if name is not None: self.type = knownPlatforms.get(name) if platform is not None: self._platform = platform def isKnown(self) -> bool: """ Do we know about this platform? @return: Boolean indicating whether this is a known platform or not. """ return self.type != None def getType(self) -> Optional[str]: """ Get platform type. @return: Either 'posix', 'win32' or 'java' """ return self.type def isMacOSX(self) -> bool: """ Check if current platform is macOS. @return: C{True} if the current platform has been detected as macOS. """ return self._platform == "darwin" def isWinNT(self) -> bool: """ Are we running in Windows NT? This is deprecated and always returns C{True} on win32 because Twisted only supports Windows NT-derived platforms at this point. @return: C{True} if the current platform has been detected as Windows NT. """ warnings.warn( "twisted.python.runtime.Platform.isWinNT was deprecated in " "Twisted 13.0. Use Platform.isWindows instead.", DeprecationWarning, stacklevel=2, ) return self.isWindows() def isWindows(self) -> bool: """ Are we running in Windows? @return: C{True} if the current platform has been detected as Windows. """ return self.getType() == "win32" def isVista(self) -> bool: """ Check if current platform is Windows Vista or Windows Server 2008. @return: C{True} if the current platform has been detected as Vista """ return sys.platform == "win32" and sys.getwindowsversion().major == 6 def isLinux(self) -> bool: """ Check if current platform is Linux. @return: C{True} if the current platform has been detected as Linux. """ return self._platform.startswith("linux") def isDocker(self, _initCGroupLocation: str = "/proc/1/cgroup") -> bool: """ Check if the current platform is Linux in a Docker container. @return: C{True} if the current platform has been detected as Linux inside a Docker container. """ if not self.isLinux(): return False from twisted.python.filepath import FilePath # Ask for the cgroups of init (pid 1) initCGroups = FilePath(_initCGroupLocation) if initCGroups.exists(): # The cgroups file looks like "2:cpu:/". The third element will # begin with /docker if it is inside a Docker container. controlGroups = [ x.split(b":") for x in initCGroups.getContent().split(b"\n") ] for group in controlGroups: if len(group) == 3 and group[2].startswith(b"/docker/"): # If it starts with /docker/, we're in a docker container return True return False def _supportsSymlinks(self) -> bool: """ Check for symlink support usable for Twisted's purposes. @return: C{True} if symlinks are supported on the current platform, otherwise C{False}. """ if self.isWindows(): # We do the isWindows() check as newer Pythons support the symlink # support in Vista+, but only if you have some obscure permission # (SeCreateSymbolicLinkPrivilege), which can only be given on # platforms with msc.exe (so, Business/Enterprise editions). # This uncommon requirement makes the Twisted test suite test fail # in 99.99% of cases as general users don't have permission to do # it, even if there is "symlink support". return False else: # If we're not on Windows, check for existence of os.symlink. try: os.symlink except AttributeError: return False else: return True def supportsThreads(self) -> bool: """ Can threads be created? @return: C{True} if the threads are supported on the current platform. """ try: import threading return threading is not None # shh pyflakes except ImportError: return False def supportsINotify(self) -> bool: """ Return C{True} if we can use the inotify API on this platform. @since: 10.1 """ try: from twisted.python._inotify import INotifyError, init except ImportError: return False try: os.close(init()) except INotifyError: return False return True platform = Platform() platformType = platform.getType()
Save
cmd:
run