[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ApplicationControl - IRuntimeInfo.py:1.1.2.1 RuntimeInfo.py:1.1.2.1
   
    Philipp von Weitershausen
     
    philikon@gmx.net
       
    Tue, 9 Apr 2002 09:57:55 -0400
    
    
  
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ApplicationControl
In directory cvs.zope.org:/tmp/cvs-serv22029
Added Files:
      Tag: Zope-3x-branch
	IRuntimeInfo.py RuntimeInfo.py 
Log Message:
- introduced the IRuntimeInfo interface and adapter to be used for the 
  first ApplicationControl view
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/IRuntimeInfo.py ===
##############################################################################
#
# 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.0 (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.
# 
##############################################################################
__doc__ = """ Runtime Information
$Id: IRuntimeInfo.py,v 1.1.2.1 2002/04/09 13:57:55 philikon Exp $"""
from Interface import Interface
class IRuntimeInfo(Interface):
    """ Runtime Information Adapter for Application Control """
    def getZopeVersion():
        """Return a string containing the descriptive version of the
		   current zope installation"""
    def getPythonVersion():
        """Return a string containing verbose description of the python
		   interpreter"""
    def getSystemPlatform():
        """Return the system platform name in a 5 tuple of
		   (sysname, nodename, release, version, machine)"""
    def getCommandLine():
        """Return the command line string Zope was invoked with"""
    def getProcessId():
        """Return the process id number currently serving the request"""
    def getUptime():
        """Return a string containing the Zope server uptime in unix uptime
           format with seconds ([NN days, ]HH:MM:SS)"""
    def getEnvironment():
        """Return a dictionary with the environment variables
           of the python interpreter"""
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/RuntimeInfo.py ===
from Zope.App.OFS.ApplicationControl.IRuntimeInfo import IRuntimeInfo
from Zope.App.OFS.ApplicationControl.IApplicationControl import IApplicationControl
from Zope.ComponentArchitecture import getUtility
from IZopeVersion import IZopeVersion
import sys, os, time
class RuntimeInfo:
    __implements__ =  IRuntimeInfo
    __used_for__ = IApplicationControl
    
    def __init__(self, context):
        self._context = context
    def getContext(self):
        return self._context
    
    ############################################################
    # Implementation methods for interface
    # Zope.App.OFS.ApplicationControl.IRuntimeInfo.
    def getZopeVersion(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        version_utility = getUtility(self.getContext(), IZopeVersion, None)
        if version_utility is None:
            return ""
        return version_utility.getZopeVersion()
    def getPythonVersion(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        return sys.version
    def getSystemPlatform(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        return os.uname()
    def getCommandLine(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        return sys.argv
    def getProcessId(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        return os.getpid()
    
    def getUptime(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        return time.time() - self.getContext().getStartTime()
    def getEnvironment(self):
        'See Zope.App.OFS.ApplicationControl.IRuntimeInfo.IRuntimeInfo'
        return os.environ
    #
    ############################################################