[Zope3-checkins] CVS: Zope3/src/zope/app/applicationcontrol - interfaces.py:1.3 runtimeinfo.py:1.6

Dmitry Vasiliev dima at hlabs.spb.ru
Tue Mar 23 08:35:39 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol
In directory cvs.zope.org:/tmp/cvs-serv5236

Modified Files:
	interfaces.py runtimeinfo.py 
Log Message:
RuntimeInfo changes:
- new method: getPreferredEncoding()
- getSystemPlatform(), getPythonVersion() now returns an unicode strings encoded
  with the preferred system encoding


=== Zope3/src/zope/app/applicationcontrol/interfaces.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/applicationcontrol/interfaces.py:1.2	Mon Mar  8 18:33:38 2004
+++ Zope3/src/zope/app/applicationcontrol/interfaces.py	Tue Mar 23 08:35:07 2004
@@ -38,21 +38,25 @@
 class IRuntimeInfo(Interface):
     """ Runtime Information Adapter for Application Control """
 
+    def getPreferredEncoding():
+        """Return the encoding used for text data, according
+           to user system preferences"""
+
     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"""
+        """Return an unicode string containing verbose description
+           of the python interpreter"""
 
     def getPythonPath():
         """Return a tuple containing the lookup paths of the python interpreter
         """
 
     def getSystemPlatform():
-        """Return the system platform name in a 5 tuple of
-           (sysname, nodename, release, version, machine)"""
+        """Return an unicode string containing the system platform name
+        """
 
     def getCommandLine():
         """Return the command line string Zope was invoked with"""
@@ -62,8 +66,7 @@
         """
 
     def getUptime():
-        """Return a string containing the Zope server uptime in unix uptime
-           format with seconds ([NN days, ]HH:MM:SS)"""
+        """Return the Zope server uptime in seconds."""
 
 
 class IZopeVersion(Interface):
@@ -96,7 +99,7 @@
 
     def registerShutdownHook(call, priority, name):
         """Register a function that will be callen on server shutdown.
-        
+
         The function needs to takes no argument at all."""
 
 


=== Zope3/src/zope/app/applicationcontrol/runtimeinfo.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/applicationcontrol/runtimeinfo.py:1.5	Mon Mar  1 08:43:24 2004
+++ Zope3/src/zope/app/applicationcontrol/runtimeinfo.py	Tue Mar 23 08:35:07 2004
@@ -17,6 +17,11 @@
 """
 import sys, os, time
 
+try:
+    import locale
+except ImportError:
+    locale = None
+
 from zope.app.applicationcontrol.interfaces import \
      IRuntimeInfo, IApplicationControl, IZopeVersion
 from zope.component import getUtility, ComponentLookupError
@@ -30,6 +35,13 @@
     def __init__(self, context):
         self.context = context
 
+    def getPreferredEncoding(self):
+        """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
+        if locale is None:
+            # XXX: sys.getdefaultencoding()?
+            return "Latin1"
+        return locale.getpreferredencoding()
+
     def getZopeVersion(self):
         """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
         try:
@@ -40,7 +52,7 @@
 
     def getPythonVersion(self):
         """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        return sys.version
+        return unicode(sys.version, self.getPreferredEncoding())
 
     def getPythonPath(self):
         """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
@@ -49,13 +61,14 @@
     def getSystemPlatform(self):
         """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
         if hasattr(os, "uname"):
-            return os.uname()
+            info = os.uname()
         else:
-            return (sys.platform,)
+            info = (sys.platform,)
+        return unicode(" ".join(info), self.getPreferredEncoding())
 
     def getCommandLine(self):
         """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
-        return sys.argv
+        return " ".join(sys.argv)
 
     def getProcessId(self):
         """See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""




More information about the Zope3-Checkins mailing list