[Python-checkins] r47083 - in sandbox/trunk/pdb: mconnection.py mpdb.py test/test_mconnection.py
matt.fleming
python-checkins at python.org
Fri Jun 23 13:18:42 CEST 2006
Author: matt.fleming
Date: Fri Jun 23 13:18:41 2006
New Revision: 47083
Modified:
sandbox/trunk/pdb/mconnection.py
sandbox/trunk/pdb/mpdb.py
sandbox/trunk/pdb/test/test_mconnection.py
Log:
There should be no distinction between serial servers and clients.
Modified: sandbox/trunk/pdb/mconnection.py
==============================================================================
--- sandbox/trunk/pdb/mconnection.py (original)
+++ sandbox/trunk/pdb/mconnection.py Fri Jun 23 13:18:41 2006
@@ -59,9 +59,11 @@
### This might go in a different file
-class MConnectionServerSerial(MConnectionServerInterface):
+# Not, serial protocol does not require the distinction between server and
+# client.
+class MConnectionSerial(MConnectionServerInterface):
- """ This server connection class that allows a connection to a
+ """ This connection class that allows a connection to a
target via a serial line.
"""
@@ -79,8 +81,9 @@
try:
self.output = open(self._dev, 'w')
self.input = open(self._dev, 'r')
- except IOError:
- raise ConnectionRefused
+ except IOError,e:
+ # Use e[1] for more detail about why the connection failed
+ raise ConnectionFailed, e[1]
def disconnect(self):
""" Close the serial device. """
@@ -100,7 +103,6 @@
self.output.write(msg)
self.output.flush()
-MConnectionClientSerial = MConnectionServerSerial
### This might go in a different file
import socket
Modified: sandbox/trunk/pdb/mpdb.py
==============================================================================
--- sandbox/trunk/pdb/mpdb.py (original)
+++ sandbox/trunk/pdb/mpdb.py Fri Jun 23 13:18:41 2006
@@ -190,11 +190,11 @@
# Matt - Where are the connection parameters?
if self.connection: self.connection.disconnect()
try:
- from mconnection import (MConnectionClientSerial,
+ from mconnection import (MConnectionSerial,
ConnectionFailed)
- self.connection = MConnectionClientSerial()
+ self.connection = MConnectionSerial()
except ImportError:
- self.msg('Could not import MConnectionClientSerial')
+ self.msg('Could not import MConnectionSerial')
return
else:
if '.' in target:
@@ -263,6 +263,14 @@
except ImportError:
self.msg('Could not load MConnectionServerTCP class')
return
+ elif target == 'serial':
+ try:
+ from mconnection import (MConnectionSerial,
+ ConnectionFailed)
+ self.connection = MConnectionSerial()
+ except ImportError:
+ self.msg('Could not load MConnectionSerial class')
+ return
else:
if '.' in target:
base = target[:target.rfind('.')]
@@ -275,7 +283,7 @@
try:
self.connection.connect(comm)
except ConnectionFailed, err:
- self.msg("Failed to connect to %s: (%s)" % (addr, err))
+ self.msg("Failed to connect to %s: (%s)" % (comm, err))
return
self.target = 'remote'
self._rebind_input(self.connection)
Modified: sandbox/trunk/pdb/test/test_mconnection.py
==============================================================================
--- sandbox/trunk/pdb/test/test_mconnection.py (original)
+++ sandbox/trunk/pdb/test/test_mconnection.py Fri Jun 23 13:18:41 2006
@@ -19,8 +19,7 @@
sys.path.append("..")
from mconnection import (MConnectionServerTCP, MConnectionClientTCP,
- MConnectionServerSerial, MConnectionClientSerial,
- ConnectionFailed)
+ MConnectionSerial, ConnectionFailed)
# Try to connect the client to addr either until we've tried MAXTRIES
# times or until it succeeds.
@@ -88,8 +87,8 @@
on *nix systems is just files anyway.
"""
def setUp(self):
- self.server = MConnectionServerSerial()
- self.client = MConnectionClientSerial()
+ self.server = MConnectionSerial()
+ self.client = MConnectionSerial()
fd = open(TESTFN, "wr+")
fd.close()
self.server.connect(TESTFN)
More information about the Python-checkins
mailing list