/usr/share/pyshared/zope/applicationcontrol/runtimeinfo.py is in python-zope.applicationcontrol 3.5.5-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | ##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Runtime Information
$Id: runtimeinfo.py 107931 2010-01-09 14:42:28Z faassen $
"""
__docformat__ = 'restructuredtext'
import sys
import os
import time
try:
import locale
except ImportError:
locale = None
import platform
from zope.component import getUtility, ComponentLookupError
from zope.interface import implements
from zope.applicationcontrol.interfaces import IRuntimeInfo
from zope.applicationcontrol.interfaces import IApplicationControl
from zope.applicationcontrol.interfaces import IZopeVersion
try:
from zope.app.appsetup import appsetup
except ImportError:
appsetup = None
class RuntimeInfo(object):
"""Runtime information."""
implements(IRuntimeInfo)
__used_for__ = IApplicationControl
def __init__(self, context):
self.context = context
def getDeveloperMode(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
if appsetup is None:
return 'undefined'
cc=appsetup.getConfigContext()
if cc == None: # make the test run
return 'undefined'
if cc.hasFeature('devmode'):
return 'On'
return 'Off'
def getPreferredEncoding(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
if locale is not None:
try:
return locale.getpreferredencoding()
except locale.Error:
pass
return sys.getdefaultencoding()
def getFileSystemEncoding(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
enc = sys.getfilesystemencoding()
if enc is None:
enc = self.getPreferredEncoding()
return enc
def getZopeVersion(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
try:
version_utility = getUtility(IZopeVersion)
except ComponentLookupError:
return "Unavailable"
return version_utility.getZopeVersion()
def getPythonVersion(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
return unicode(sys.version, self.getPreferredEncoding())
def getPythonPath(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
enc = self.getFileSystemEncoding()
return tuple([unicode(path, enc) for path in sys.path])
def getSystemPlatform(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
info = []
enc = self.getPreferredEncoding()
for item in platform.uname():
try:
t = unicode(item, enc)
except ValueError:
continue
info.append(t)
return u" ".join(info)
def getCommandLine(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
return unicode(" ".join(sys.argv), self.getPreferredEncoding())
def getProcessId(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
return os.getpid()
def getUptime(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
return time.time() - self.context.getStartTime()
|