diff options
Diffstat (limited to 'lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/python/runtime.py')
-rwxr-xr-x | lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/python/runtime.py | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/python/runtime.py b/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/python/runtime.py deleted file mode 100755 index da078bf5..00000000 --- a/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/python/runtime.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- test-case-name: twisted.python.test.test_runtime -*- -# Copyright (c) Twisted Matrix Laboratories. -# See LICENSE for details. - - -# System imports -import os -import sys -import time -import imp - - - -def shortPythonVersion(): - """ - 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', - } - - - -_timeFunctions = { - #'win32': time.clock, - 'win32': time.time, - } - - - -class Platform: - """Gives us information about the platform we're running on""" - - type = knownPlatforms.get(os.name) - seconds = staticmethod(_timeFunctions.get(type, time.time)) - _platform = sys.platform - - def __init__(self, name=None, platform=None): - if name is not None: - self.type = knownPlatforms.get(name) - self.seconds = _timeFunctions.get(self.type, time.time) - if platform is not None: - self._platform = platform - - - def isKnown(self): - """Do we know about this platform?""" - return self.type != None - - - def getType(self): - """Return 'posix', 'win32' or 'java'""" - return self.type - - - def isMacOSX(self): - """Check if current platform is Mac OS X. - - @return: C{True} if the current platform has been detected as OS X - @rtype: C{bool} - """ - return self._platform == "darwin" - - - def isWinNT(self): - """Are we running in Windows NT?""" - if self.getType() == 'win32': - import _winreg - try: - k = _winreg.OpenKeyEx( - _winreg.HKEY_LOCAL_MACHINE, - r'Software\Microsoft\Windows NT\CurrentVersion') - _winreg.QueryValueEx(k, 'SystemRoot') - return 1 - except WindowsError: - return 0 - # not windows NT - return 0 - - - def isWindows(self): - return self.getType() == 'win32' - - - def isVista(self): - """ - Check if current platform is Windows Vista or Windows Server 2008. - - @return: C{True} if the current platform has been detected as Vista - @rtype: C{bool} - """ - if getattr(sys, "getwindowsversion", None) is not None: - return sys.getwindowsversion()[0] == 6 - else: - return False - - - def isLinux(self): - """ - Check if current platform is Linux. - - @return: C{True} if the current platform has been detected as Linux. - @rtype: C{bool} - """ - return self._platform.startswith("linux") - - - def supportsThreads(self): - """Can threads be created? - """ - try: - return imp.find_module('thread')[0] is None - except ImportError: - return False - - - def supportsINotify(self): - """ - 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() -seconds = platform.seconds |