orca r3819 - in trunk: . src/orca test/harness
- From: wwalker svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r3819 - in trunk: . src/orca test/harness
- Date: Mon, 7 Apr 2008 20:20:05 +0100 (BST)
Author: wwalker
Date: Mon Apr 7 20:20:05 2008
New Revision: 3819
URL: http://svn.gnome.org/viewvc/orca?rev=3819&view=rev
Log:
Fix for bug #525348 - Orca uses wget.
Added:
trunk/src/orca/dbusserver.py
Modified:
trunk/ChangeLog
trunk/src/orca/Makefile.am
trunk/src/orca/httpserver.py
trunk/src/orca/orca.in
trunk/src/orca/orca.py
trunk/src/orca/settings.py
trunk/test/harness/harness.sh
trunk/test/harness/utils.py
Modified: trunk/src/orca/Makefile.am
==============================================================================
--- trunk/src/orca/Makefile.am (original)
+++ trunk/src/orca/Makefile.am Mon Apr 7 20:20:05 2008
@@ -16,6 +16,7 @@
braillegenerator.py \
brlmon.py \
chnames.py \
+ dbusserver.py \
debug.py \
dectalk.py \
default.py \
Added: trunk/src/orca/dbusserver.py
==============================================================================
--- (empty file)
+++ trunk/src/orca/dbusserver.py Mon Apr 7 20:20:05 2008
@@ -0,0 +1,157 @@
+# Orca
+#
+# Copyright 2008 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+"""Exposes Orca as a DBus service for testing and watchdog purposes."""
+
+__id__ = "$Id: httpserver.py 3445 2008-01-11 17:05:52Z wwalker $"
+__version__ = "$Revision: 3445 $"
+__date__ = "$Date: 2008-01-11 12:05:52 -0500 (Fri, 11 Jan 2008) $"
+__copyright__ = "Copyright (c) 2008 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+import debug
+import platform
+import settings
+
+# Handlers for logging speech and braille output.
+#
+loggingFileHandlers = {}
+loggingStreamHandlers = {}
+
+class Server(dbus.service.Object):
+
+ @dbus.service.method(dbus_interface='org.gnome.Orca.Logging',
+ in_signature='si', out_signature='')
+ def setDebug(self, debugFile, debugLevel):
+ """Sets the file to send detailed debug information."""
+ if not settings.enableRemoteLogging:
+ return
+ debug.println(debug.LEVEL_FINEST,
+ "DBus Logging.setDebug(%s, %d)" \
+ % (debugFile, debugLevel))
+ if debug.debugFile:
+ debug.debugFile.close()
+ debug.debugFile = None
+ if debugFile and len(debugFile):
+ debug.debugFile = open('%s.debug' % debugFile, 'w', 0)
+ debug.debugLevel = debugLevel
+
+ @dbus.service.method(dbus_interface='org.gnome.Orca.Logging',
+ in_signature='s', out_signature='')
+ def setLogFile(self, logFile):
+ """Sets the file to send speech and braille logging information."""
+ if not settings.enableRemoteLogging:
+ return
+ import logging
+ debug.println(debug.LEVEL_FINEST,
+ "DBus Logging.setLogFile(%s)" % logFile)
+ for logger in ['braille', 'speech']:
+ log = logging.getLogger(logger)
+ formatter = logging.Formatter('%(message)s')
+ try:
+ loggingFileHandlers[logger].flush()
+ loggingFileHandlers[logger].close()
+ log.removeHandler(loggingFileHandlers[logger])
+ except:
+ pass
+ if logFile and len(logFile):
+ loggingFileHandlers[logger] = logging.FileHandler(
+ '%s.%s' % (logFile, logger), 'w')
+ loggingFileHandlers[logger].setFormatter(formatter)
+ log.addHandler(loggingFileHandlers[logger])
+ log.setLevel(logging.INFO)
+
+ @dbus.service.method(dbus_interface='org.gnome.Orca.Logging',
+ in_signature='', out_signature='')
+ def startRecording(self):
+ """Tells Orca to start logging speech and braille output."""
+ if not settings.enableRemoteLogging:
+ return
+ debug.println(debug.LEVEL_FINEST, "DBus Logging.startRecording")
+ import logging
+ import StringIO
+ for logger in ['braille', 'speech']:
+ log = logging.getLogger(logger)
+ try:
+ [stringIO, handler] = loggingStreamHandlers[logger]
+ handler.close()
+ log.removeHandler(handler)
+ stringIO.close()
+ except:
+ pass
+ formatter = logging.Formatter('%(message)s')
+ stringIO = StringIO.StringIO()
+ handler = logging.StreamHandler(stringIO)
+ handler.setFormatter(formatter)
+ log.addHandler(handler)
+ loggingStreamHandlers[logger] = [stringIO, handler]
+ log.setLevel(logging.INFO)
+
+ @dbus.service.method(dbus_interface='org.gnome.Orca.Logging',
+ in_signature='', out_signature='s')
+ def stopRecording(self):
+ """Tells Orca to stop logging speech and braille output and
+ to return whatever was recorded since the last call to
+ startRecording."""
+ if not settings.enableRemoteLogging:
+ return ""
+ debug.println(debug.LEVEL_FINEST, "DBus Logging.stopRecording")
+ import logging
+ import StringIO
+ result = ''
+ for logger in ['braille', 'speech']:
+ log = logging.getLogger(logger)
+ try:
+ [stringIO, handler] = loggingStreamHandlers[logger]
+ handler.flush()
+ handler.close()
+ log.removeHandler(handler)
+ result += stringIO.getvalue()
+ stringIO.close()
+ except:
+ debug.printException(debug.LEVEL_OFF)
+ stringIO = StringIO.StringIO()
+ return result
+
+obj = None
+
+def init():
+ """Sets up the Orca DBus service. This will only take effect once
+ the Orca main loop starts."""
+
+ global obj
+
+ if obj:
+ return
+
+ try:
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+ bus = dbus.SessionBus()
+ name = dbus.service.BusName('org.gnome.Orca', bus=bus)
+ obj = Server(name, '/')
+ except:
+ debug.println(debug.LEVEL_WARNING,
+ "dbusserver.py: Could not initialize DBus server")
+
+def shutdown():
+ pass
Modified: trunk/src/orca/httpserver.py
==============================================================================
--- trunk/src/orca/httpserver.py (original)
+++ trunk/src/orca/httpserver.py Mon Apr 7 20:20:05 2008
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2006-2007 Sun Microsystems Inc.
+# Copyright 2006-2008 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -24,7 +24,7 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2006-2007 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2006-2008 Sun Microsystems Inc."
__license__ = "LGPL"
import threading
@@ -49,11 +49,7 @@
as a speech service.
The protocol is simple: POST content is 'stop', 'speak:<text>',
- or 'isSpeaking'. A POST content of 'log:filename' will also
- instruct Orca to log speech and braille output to
- 'filename.speech' and 'filename.braille'. A POST content of
- 'debug:level:filename' will instruct Orca to send debug output
- at 'level' (an integer value) to 'filename.debug'.
+ or 'isSpeaking'.
To test this, run:
@@ -92,74 +88,6 @@
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write("%s" % speech.isSpeaking())
- elif settings.enableRemoteLogging and inputBody.startswith("log:"):
- import logging
- logFile = inputBody[4:]
- for logger in ['braille', 'speech']:
- log = logging.getLogger(logger)
- formatter = logging.Formatter('%(message)s')
- try:
- loggingFileHandlers[logger].flush()
- loggingFileHandlers[logger].close()
- log.removeHandler(loggingFileHandlers[logger])
- except:
- pass
- if logFile and len(logFile):
- loggingFileHandlers[logger] = logging.FileHandler(
- '%s.%s' % (logFile, logger), 'w')
- loggingFileHandlers[logger].setFormatter(formatter)
- log.addHandler(loggingFileHandlers[logger])
- log.setLevel(logging.INFO)
- self.send_response(200, 'OK')
- elif settings.enableRemoteLogging and inputBody == "recordStart":
- import logging
- import StringIO
- for logger in ['braille', 'speech']:
- log = logging.getLogger(logger)
- try:
- [stringIO, handler] = loggingStreamHandlers[logger]
- handler.close()
- log.removeHandler(handler)
- stringIO.close()
- except:
- pass
- formatter = logging.Formatter('%(message)s')
- stringIO = StringIO.StringIO()
- handler = logging.StreamHandler(stringIO)
- handler.setFormatter(formatter)
- log.addHandler(handler)
- loggingStreamHandlers[logger] = [stringIO, handler]
- log.setLevel(logging.INFO)
- self.send_response(200, 'OK')
- elif settings.enableRemoteLogging and inputBody == "recordStop":
- import logging
- import StringIO
- result = ''
- for logger in ['braille', 'speech']:
- log = logging.getLogger(logger)
- try:
- [stringIO, handler] = loggingStreamHandlers[logger]
- handler.flush()
- handler.close()
- log.removeHandler(handler)
- result += stringIO.getvalue()
- stringIO.close()
- except:
- debug.printException(debug.LEVEL_OFF)
- stringIO = StringIO.StringIO()
- self.send_response(200, 'OK')
- self.send_header("Content-type", "text/html")
- self.end_headers()
- self.wfile.write(result)
- elif inputBody.startswith("debug:"):
- split = inputBody.split(':')
- debug.debugLevel = int(split[1])
- if debug.debugFile:
- debug.debugFile.close()
- debug.debugFile = None
- if (len(split) == 3) and (len(split[2])):
- debug.debugFile = open('%s.debug' % split[2], 'w', 0)
- self.send_response(200, 'OK')
else:
debug.println(debug.LEVEL_FINEST,
"httpserver._HTTPRequestHandler received no data")
Modified: trunk/src/orca/orca.in
==============================================================================
--- trunk/src/orca/orca.in (original)
+++ trunk/src/orca/orca.in Mon Apr 7 20:20:05 2008
@@ -2,7 +2,7 @@
#
# Orca
#
-# Copyright 2006-2007 Sun Microsystems Inc.
+# Copyright 2006-2008 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -25,7 +25,7 @@
# __id__ = "$Id: orca.in,v 1.22 2006/12/08 16:21:25 wwalker Exp $"
# __version__ = "$Revision: 1.22 $"
# __date__ = "$Date: 2006/12/08 16:21:25 $"
-# __copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
+# __copyright__ = "Copyright (c) 2006-2008 Sun Microsystems Inc."
# __license__ = "LGPL"
# Set the user's $PATH for this script.
@@ -50,17 +50,17 @@
# The watchdog will periodically ping Orca to see if it is responding.
# If orca isn't responding, the watchdog will kill the Orca process.
-# The watchdog logic requires 'wget', so we won't do it if we can't
-# find wget in the path. Note also that you can force WATCHDOG=0 if you
+# The watchdog logic requires 'dbus-send', so we won't do it if we can't
+# find dbus-send in the path. Note also that you can force WATCHDOG=0 if you
# do not want a background process that periodically pings Orca to see
# if it is responding.
#
IFS=:
-WGETCMD=
+DBUSSENDCMD=
WATCHDOG=0
for dir in $PATH:/usr/sfw/bin:/usr/local/bin; do
- test -x "$dir/wget" && {
- WGETCMD="$dir/wget"
+ test -x "$dir/dbus-send" && {
+ DBUSSENDCMD="$dir/dbus-send"
WATCHDOG=1
break
}
@@ -134,7 +134,7 @@
# Runs a watchdog process in the background. It merely attempts to
# get to Orca via some other means than the AT-SPI. Here we use
-# Orca's http server at port 20433. If it doesn't respond, then
+# a Ping on the Orca DBus service. If it doesn't respond, then
# we assume Orca is dead.
#
watchdog()
@@ -151,10 +151,12 @@
then
exit
else
- $WGETCMD -q -t 0 -O /dev/null -w 2 "http://localhost:20433" || {
+ $DBUSSENDCMD --reply-timeout=100 --print-reply --dest=org.gnome.Orca / org.freedesktop.DBus.Peer.Ping > /dev/null 2>&1
+ if [ "$?" -ne 0 ]
+ then
echo Orca watchdog detected something bad. Cleaning up.
cleanup
- }
+ fi
fi
done
) &
Modified: trunk/src/orca/orca.py
==============================================================================
--- trunk/src/orca/orca.py (original)
+++ trunk/src/orca/orca.py Mon Apr 7 20:20:05 2008
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2004-2007 Sun Microsystems Inc.
+# Copyright 2004-2008 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -22,7 +22,7 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2007 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2004-2008 Sun Microsystems Inc."
__license__ = "LGPL"
# We're going to force the name of the app to "orca" so pygtk
@@ -55,6 +55,7 @@
import pyatspi
import braille
import debug
+import dbusserver
import httpserver
import keynames
import keybindings
@@ -829,6 +830,7 @@
# Shutdown the output drivers and give them a chance to die.
#
+ dbusserver.shutdown()
httpserver.shutdown()
speech.shutdown()
braille.shutdown()
@@ -940,6 +942,7 @@
showMainWindowGUI()
+ dbusserver.init()
httpserver.init()
return True
Modified: trunk/src/orca/settings.py
==============================================================================
--- trunk/src/orca/settings.py (original)
+++ trunk/src/orca/settings.py Mon Apr 7 20:20:05 2008
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2004-2007 Sun Microsystems Inc.
+# Copyright 2004-2008 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -24,7 +24,7 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2007 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2004-2008 Sun Microsystems Inc."
__license__ = "LGPL"
import os
@@ -258,7 +258,7 @@
# The port to listen on if orca is to act as an HTTP server
# (mainly as a speech server for self-voicing applications).
#
-httpServerPort = 20433
+httpServerPort = 0
# The number of attempts to retry setting up an HTTP server
# connection (each time incrementing the port number by 1).
Modified: trunk/test/harness/harness.sh
==============================================================================
--- trunk/test/harness/harness.sh (original)
+++ trunk/test/harness/harness.sh Mon Apr 7 20:20:05 2008
@@ -261,11 +261,11 @@
echo === $testFile
newResultsFile=`basename $testFile .py`
- wget --output-file /dev/null --post-data="debug:0:./tmp/$application/$newResultsFile" localhost:20433
- wget --output-file /dev/null --post-data="log:./tmp/$application/$newResultsFile" localhost:20433
+ dbus-send --reply-timeout=100 --print-reply --dest=org.gnome.Orca / org.gnome.Orca.Logging.setDebug string:"./tmp/$application/$newResultsFile" int:0
+ dbus-send --reply-timeout=100 --print-reply --dest=org.gnome.Orca / org.gnome.Orca.Logging.setLogFile string:"./tmp/$application/$newResultsFile"
python $testFile
- wget --output-file /dev/null --post-data="log:" localhost:20433
- wget --output-file /dev/null --post-data="debug:10000" localhost:20433
+ dbus-send --reply-timeout=100 --print-reply --dest=org.gnome.Orca / org.gnome.Orca.Logging.setLogFile string:""
+ dbus-send --reply-timeout=100 --print-reply --dest=org.gnome.Orca / org.gnome.Orca.Logging.setDebug string:"" int:10000
# Copy the results (.orca) file to the output directory.
# This is the file that will be used for regression
Modified: trunk/test/harness/utils.py
==============================================================================
--- trunk/test/harness/utils.py (original)
+++ trunk/test/harness/utils.py Mon Apr 7 20:20:05 2008
@@ -3,6 +3,11 @@
file in order for the tests that use it to work. The test
harness does that automatically for you."""
+import dbus
+bus = dbus.SessionBus()
+dbusOrca = bus.get_object('org.gnome.Orca', '/')
+dbusOrcaLogging = dbus.Interface(dbusOrca, 'org.gnome.Orca.Logging')
+
# Where to find Dojo tests.
#
#DojoURLPrefix="http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/"
@@ -56,10 +61,7 @@
AtomicAction.__init__(self, 0, lambda: None)
def _startRecording(self):
- import sys, urllib
- f = urllib.urlopen("http://localhost:20433", "recordStart")
- result = f.read()
- f.close()
+ dbusOrcaLogging.startRecording()
def __str__(self):
return 'Start Recording Action'
@@ -177,17 +179,7 @@
return expectedToFail
def _stopRecording(self):
- import sys, urllib
-
- f = urllib.urlopen("http://localhost:20433", "recordStop")
- result = ''
- while True:
- someRead = f.read()
- result += someRead
- if not len(someRead):
- break
- f.close()
-
+ result = dbusOrcaLogging.stopRecording()
results = self._assertionPredicate(result, self._expectedResults)
if not results:
AssertPresentationAction.totalSucceed += 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]