1 # -*- test-case-name: twisted.python.test.test_runtime -*-
2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
13 def shortPythonVersion():
15 major = (hv & 0xff000000L) >> 24
16 minor = (hv & 0x00ff0000L) >> 16
17 teeny = (hv & 0x0000ff00L) >> 8
18 return "%s.%s.%s" % (major,minor,teeny)
25 'org.python.modules.os': 'java',
34 """Gives us information about the platform we're running on"""
36 type = knownPlatforms.get(os.name)
37 seconds = staticmethod(_timeFunctions.get(type, time.time))
38 _platform = sys.platform
40 def __init__(self, name=None, platform=None):
42 self.type = knownPlatforms.get(name)
43 self.seconds = _timeFunctions.get(self.type, time.time)
44 if platform is not None:
45 self._platform = platform
49 """Do we know about this platform?"""
50 return self.type != None
54 """Return 'posix', 'win32' or 'java'"""
59 """Check if current platform is Mac OS X.
61 @return: C{True} if the current platform has been detected as OS X
64 return self._platform == "darwin"
68 """Are we running in Windows NT?"""
69 if self.getType() == 'win32':
72 k=_winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE,
73 r'Software\Microsoft\Windows NT\CurrentVersion')
74 _winreg.QueryValueEx(k, 'SystemRoot')
83 return self.getType() == 'win32'
88 Check if current platform is Windows Vista or Windows Server 2008.
90 @return: C{True} if the current platform has been detected as Vista
93 if getattr(sys, "getwindowsversion", None) is not None:
94 return sys.getwindowsversion()[0] == 6
101 Check if current platform is Linux.
103 @return: C{True} if the current platform has been detected as Linux.
106 return self._platform.startswith("linux")
109 def supportsThreads(self):
110 """Can threads be created?
113 return imp.find_module('thread')[0] is None
118 def supportsINotify(self):
120 Return C{True} if we can use the inotify API on this platform.
125 from twisted.python._inotify import INotifyError, init
135 platform = Platform()
136 platformType = platform.getType()
137 seconds = platform.seconds