[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: HTTPSpeaker.py and speaker.py



The attached patch modifies HTTPSpeaker.py and speaker.py:

1. It uses whichever version of Python is the default on the system rather
than Python 2.4, which, here at least, isn't installed anymore.

2. It eliminates the warning about the deprecated os.popen3() function by
using the newer subprocess module instead.

3. HTTPSpeaker.py honours the DTK_PROGRAM environment variable, but still
defaults to outloud if it isn't set.

I also had to change the location of the Emacspeak directory to reflect my
installation, but I've deleted this from the patch as it wouldn't be useful to
others and it's obvious which line has to be modified anyway.

Further improvements and suggestions are welcome.

Index: speaker.py
===================================================================
--- speaker.py	(revision 7064)
+++ speaker.py	(working copy)
@@ -27,7 +27,7 @@
 __license__ = "LGPL"
 __all__=['Speaker']
 
-import os, sys
+import os, sys, subprocess
 
 class Speaker:
     
@@ -86,7 +86,8 @@
                                          "ssh-%s" %
                                          self._engine)
         cmd = '{ ' + self._server + '; } 2>&1'
-        (self._w, self._r, self._e) = os.popen3(cmd, "w", 1)
+        server_process = subprocess.Popen(cmd, 1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
+        (self._w, self._r, self._e) = server_process.stdin, server_process.stdout, server_process.stderr
         self._settings ={}
         if initial is not None:
             self._settings.update(initial)

Index: HTTPSpeaker.py
===================================================================
--- HTTPSpeaker.py	(revision 7064)
+++ HTTPSpeaker.py	(working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.4
+#!/usr/bin/python
 
 """HTTP wrapper around Emacspeak speech server.
 
@@ -23,6 +23,7 @@
 from speaker import Speaker
 from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
 import sys
+import os
 import urllib
 
 class HTTPSpeaker (HTTPServer):
@@ -97,7 +98,7 @@
     if sys.argv[1:]:
         engine = sys.argv[1]
     else:
-        engine='outloud'
+        engine=os.getenv('DTK_PROGRAM','outloud')
     if sys.argv[2:]:
         port = int(sys.argv[2])
     else:


If you have questions about this archive or had problems using it, please send mail to:

priestdo@cs.vassar.edu No Soliciting!

Emacspeak List Archive | 2010 | 2009 | 2008 | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999 | 1998 | Pre 1998

Emacspeak Files | Emacspeak Blog | Search the archive