[Erp5-report] r25798 - in /erp5/trunk/products/TIDStorage: ./ repozo/ tests/ utils/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Mar 3 10:06:58 CET 2009
Author: luke
Date: Tue Mar 3 10:06:56 2009
New Revision: 25798
URL: http://svn.erp5.org?rev=25798&view=rev
Log:
- move TIDClient class to own file, change imports on related scripts
Added:
erp5/trunk/products/TIDStorage/TIDClient.py
Modified:
erp5/trunk/products/TIDStorage/repozo/repozo_tidstorage.py
erp5/trunk/products/TIDStorage/tests/testTIDServer.py
erp5/trunk/products/TIDStorage/utils/dump_tid_dict.py
Added: erp5/trunk/products/TIDStorage/TIDClient.py
URL: http://svn.erp5.org/erp5/trunk/products/TIDStorage/TIDClient.py?rev=25798&view=auto
==============================================================================
--- erp5/trunk/products/TIDStorage/TIDClient.py (added)
+++ erp5/trunk/products/TIDStorage/TIDClient.py [utf8] Tue Mar 3 10:06:56 2009
@@ -1,0 +1,57 @@
+import socket
+import time
+
+from ExchangeProtocol import ExchangeProtocol
+
+class TIDClient:
+ def __init__(self, address):
+ self._to_server = socket.socket()
+ self._to_server.connect(address)
+ self._exchange_protocol = ExchangeProtocol(self._to_server)
+
+ def _dump(self, test_id=None):
+ self._exchange_protocol.send_field('dump')
+ received_dict = self._exchange_protocol.recv_dict()
+ if test_id is None:
+ result = received_dict
+ else:
+ id_len = len(test_id) + 1 # Add 1 to strip underscore.
+ result = dict([(key[id_len:], value) \
+ for key, value in received_dict.iteritems() \
+ if key.startswith(test_id)])
+ return dict([(key, int(value)) for key, value in result.iteritems()])
+
+ def dump(self, test_id):
+ return self._dump(test_id=test_id)
+
+ def dump_all(self):
+ return self._dump()
+
+ def begin(self, test_id, transaction_id, storage_id_list):
+ self._exchange_protocol.send_field('begin')
+ self._exchange_protocol.send_field(transaction_id)
+ internal_storage_id_list = ['%s_%s' % (test_id, x) \
+ for x in storage_id_list]
+ self._exchange_protocol.send_list(internal_storage_id_list)
+
+ def abort(self, test_id, transaction_id):
+ self._exchange_protocol.send_field('abort')
+ self._exchange_protocol.send_field(transaction_id)
+
+ def commit(self, test_id, transaction_id, storage_tid_dict):
+ self._exchange_protocol.send_field('commit')
+ self._exchange_protocol.send_field(transaction_id)
+ internal_storage_tid_dict = {}
+ for key, value in storage_tid_dict.iteritems():
+ internal_storage_tid_dict['%s_%s' % (test_id, key)] = value
+ self._exchange_protocol.send_dict(internal_storage_tid_dict)
+
+ def bootstraped(self):
+ self._exchange_protocol.send_field('bootstraped')
+ return self._exchange_protocol.recv_int()
+
+ def waitForBootstrap(self):
+ while not self.bootstraped():
+ time.sleep(0.1)
+
+
Modified: erp5/trunk/products/TIDStorage/repozo/repozo_tidstorage.py
URL: http://svn.erp5.org/erp5/trunk/products/TIDStorage/repozo/repozo_tidstorage.py?rev=25798&r1=25797&r2=25798&view=diff
==============================================================================
--- erp5/trunk/products/TIDStorage/repozo/repozo_tidstorage.py [utf8] (original)
+++ erp5/trunk/products/TIDStorage/repozo/repozo_tidstorage.py [utf8] Tue Mar 3 10:06:56 2009
@@ -70,7 +70,7 @@
argument.
"""
-from tests.testTIDServer import TIDClient
+from TIDClient import TIDClient
from ExchangeProtocol import ExchangeProtocol
import socket
Modified: erp5/trunk/products/TIDStorage/tests/testTIDServer.py
URL: http://svn.erp5.org/erp5/trunk/products/TIDStorage/tests/testTIDServer.py?rev=25798&r1=25797&r2=25798&view=diff
==============================================================================
--- erp5/trunk/products/TIDStorage/tests/testTIDServer.py [utf8] (original)
+++ erp5/trunk/products/TIDStorage/tests/testTIDServer.py [utf8] Tue Mar 3 10:06:56 2009
@@ -1,61 +1,9 @@
#!/usr/bin/python
-from ExchangeProtocol import ExchangeProtocol
import traceback
-import socket
-import time
import sys
-class TIDClient:
- def __init__(self, address):
- self._to_server = socket.socket()
- self._to_server.connect(address)
- self._exchange_protocol = ExchangeProtocol(self._to_server)
-
- def _dump(self, test_id=None):
- self._exchange_protocol.send_field('dump')
- received_dict = self._exchange_protocol.recv_dict()
- if test_id is None:
- result = received_dict
- else:
- id_len = len(test_id) + 1 # Add 1 to strip underscore.
- result = dict([(key[id_len:], value) \
- for key, value in received_dict.iteritems() \
- if key.startswith(test_id)])
- return dict([(key, int(value)) for key, value in result.iteritems()])
-
- def dump(self, test_id):
- return self._dump(test_id=test_id)
-
- def dump_all(self):
- return self._dump()
-
- def begin(self, test_id, transaction_id, storage_id_list):
- self._exchange_protocol.send_field('begin')
- self._exchange_protocol.send_field(transaction_id)
- internal_storage_id_list = ['%s_%s' % (test_id, x) \
- for x in storage_id_list]
- self._exchange_protocol.send_list(internal_storage_id_list)
-
- def abort(self, test_id, transaction_id):
- self._exchange_protocol.send_field('abort')
- self._exchange_protocol.send_field(transaction_id)
-
- def commit(self, test_id, transaction_id, storage_tid_dict):
- self._exchange_protocol.send_field('commit')
- self._exchange_protocol.send_field(transaction_id)
- internal_storage_tid_dict = {}
- for key, value in storage_tid_dict.iteritems():
- internal_storage_tid_dict['%s_%s' % (test_id, key)] = value
- self._exchange_protocol.send_dict(internal_storage_tid_dict)
-
- def bootstraped(self):
- self._exchange_protocol.send_field('bootstraped')
- return self._exchange_protocol.recv_int()
-
- def waitForBootstrap(self):
- while not self.bootstraped():
- time.sleep(0.1)
+from TIDClient import TIDClient
class TestTIDServerV2:
def __init__(self, address, port):
Modified: erp5/trunk/products/TIDStorage/utils/dump_tid_dict.py
URL: http://svn.erp5.org/erp5/trunk/products/TIDStorage/utils/dump_tid_dict.py?rev=25798&r1=25797&r2=25798&view=diff
==============================================================================
--- erp5/trunk/products/TIDStorage/utils/dump_tid_dict.py [utf8] (original)
+++ erp5/trunk/products/TIDStorage/utils/dump_tid_dict.py [utf8] Tue Mar 3 10:06:56 2009
@@ -30,7 +30,7 @@
# Dumps TIDStorage dict configuration
-from tests.testTIDServer import TIDClient
+from TIDClient import TIDClient
import sys
from struct import pack
from base64 import encodestring
More information about the Erp5-report
mailing list