diff options
author | aleherbau | 2011-05-19 12:48:10 +0000 |
---|---|---|
committer | aleherbau | 2011-05-19 12:48:10 +0000 |
commit | a1dfa9cc409eb736911e0be32b45f57a866e34c5 (patch) | |
tree | 97b7fa6c87076479630bdbc6a098d454264798e5 /python/src/tcf/channel/__init__.py | |
parent | 506dcea466abc2e93a508ddfbe2814d1046f3635 (diff) | |
download | org.eclipse.tcf-a1dfa9cc409eb736911e0be32b45f57a866e34c5.tar.gz org.eclipse.tcf-a1dfa9cc409eb736911e0be32b45f57a866e34c5.tar.xz org.eclipse.tcf-a1dfa9cc409eb736911e0be32b45f57a866e34c5.zip |
TCF Python: Implemented Memory and MemoryMap service proxies, code cleanup
Diffstat (limited to 'python/src/tcf/channel/__init__.py')
-rw-r--r-- | python/src/tcf/channel/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/python/src/tcf/channel/__init__.py b/python/src/tcf/channel/__init__.py index dc040aa98..b66708adb 100644 --- a/python/src/tcf/channel/__init__.py +++ b/python/src/tcf/channel/__init__.py @@ -9,7 +9,7 @@ # * Wind River Systems - initial API and implementation
# *******************************************************************************
-import cStringIO, json, binascii, types, exceptions
+import cStringIO, json, binascii, types
# channel states
STATE_OPENING = 0
@@ -166,7 +166,7 @@ def fromJSONSequence(bytes): def dumpJSONObject(object, buf):
json.dump(object, buf, separators=(',', ':'), cls=TCFJSONEncoder)
-
+
def toByteArray(data):
if data is None: return None
t = type(data)
@@ -175,12 +175,14 @@ def toByteArray(data): return binascii.a2b_base64(data)
elif t is unicode:
return binascii.a2b_base64(str(data))
- raise exceptions.TypeError(str(t))
+ raise TypeError(str(t))
class TCFJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, bytearray):
return binascii.b2a_base64(o)[:-1]
+ elif hasattr(o, '__json__'):
+ return o.__json__()
elif hasattr(o, '__iter__'):
return tuple(o)
else:
|