Changeset 70611 in vbox for trunk/src/VBox/ValidationKit/testdriver/txsclient.py
- Timestamp:
- Jan 17, 2018 3:47:10 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/txsclient.py
r70541 r70611 38 38 import threading; 39 39 import time; 40 import types;41 40 import zlib; 42 41 import uuid; … … 366 365 abPayload.append(ord(sUtf8[i])) 367 366 abPayload.append(0); 368 elif isinstance(o, types.LongType):367 elif isinstance(o, long): 369 368 if o < 0 or o > 0xffffffff: 370 369 reporter.fatal('sendMsg: uint32_t payload is out of range: %s' % (hex(o))); … … 736 735 elif o is not None: 737 736 aoPayload.append('|'); 738 o.uTxsClientCrc32 = zlib.crc32( '');737 o.uTxsClientCrc32 = zlib.crc32(b''); 739 738 else: 740 739 aoPayload.append(''); … … 1081 1080 # Push data packets until eof. 1082 1081 # 1083 uMyCrc32 = zlib.crc32( "");1082 uMyCrc32 = zlib.crc32(b''); 1084 1083 while True: 1085 1084 # Read up to 64 KB of data. … … 1147 1146 return rc; 1148 1147 1149 def taskDownloadString(self, sRemoteFile ):1148 def taskDownloadString(self, sRemoteFile, sEncoding = 'utf-8', fIgnoreEncodingErrors = True): 1150 1149 # Wrap sContent in a file like class. 1151 1150 class OutStringFile(object): # pylint: disable=R0903 … … 1160 1159 rc = self.taskDownloadCommon(sRemoteFile, oLocalString); 1161 1160 if rc is True: 1162 if not oLocalString.asContent: 1163 rc = ''; 1164 else: 1165 rc = ''.join(oLocalString.asContent); 1161 rc = ''; 1162 for sBuf in oLocalString.asContent: 1163 if hasattr(sBuf, 'decode'): 1164 rc += sBuf.decode(sEncoding, 'ignore' if fIgnoreEncodingErrors else 'strict'); 1165 else: 1166 rc += sBuf; 1166 1167 return rc; 1167 1168 … … 1173 1174 # Process data packets until eof. 1174 1175 # 1175 uMyCrc32 = zlib.crc32( "");1176 uMyCrc32 = zlib.crc32(b''); 1176 1177 while rc is True: 1177 1178 cbMsg, sOpcode, abPayload = self.recvReply(); … … 1610 1611 return self.asyncToSync(self.asyncDownloadFile, sRemoteFile, sLocalFile, cMsTimeout, fIgnoreErrors); 1611 1612 1612 def asyncDownloadString(self, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False): 1613 def asyncDownloadString(self, sRemoteFile, sEncoding = 'utf-8', fIgnoreEncodingErrors = True, 1614 cMsTimeout = 30000, fIgnoreErrors = False): 1613 1615 """ 1614 1616 Initiates a download string task. … … 1618 1620 The task returns a byte string on success, False on failure (logged). 1619 1621 """ 1620 return self.startTask(cMsTimeout, fIgnoreErrors, "downloadString", self.taskDownloadString, (sRemoteFile,)); 1621 1622 def syncDownloadString(self, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False): 1622 return self.startTask(cMsTimeout, fIgnoreErrors, "downloadString", 1623 self.taskDownloadString, (sRemoteFile, sEncoding, fIgnoreEncodingErrors)); 1624 1625 def syncDownloadString(self, sRemoteFile, sEncoding = 'utf-8', fIgnoreEncodingErrors = True, 1626 cMsTimeout = 30000, fIgnoreErrors = False): 1623 1627 """Synchronous version.""" 1624 return self.asyncToSync(self.asyncDownloadString, sRemoteFile, cMsTimeout, fIgnoreErrors); 1628 return self.asyncToSync(self.asyncDownloadString, sRemoteFile, sEncoding, fIgnoreEncodingErrors, 1629 cMsTimeout, fIgnoreErrors); 1625 1630 1626 1631 def asyncUnpackFile(self, sRemoteFile, sRemoteDir, cMsTimeout = 30000, fIgnoreErrors = False):
Note:
See TracChangeset
for help on using the changeset viewer.