- 時間撮記:
- 2017-3-7 上午10:54:16 (8 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/ValidationKit/testdriver/txsclient.py
r62484 r65967 257 257 ord(sOpcode[6]), \ 258 258 ord(sOpcode[7]) ) ) ); 259 if len(abPayload) > 0:259 if abPayload: 260 260 abMsg.extend(abPayload); 261 261 except: … … 282 282 283 283 # Read the header. 284 if len(self.abReadAheadHdr) > 0:284 if self.abReadAheadHdr: 285 285 assert(len(self.abReadAheadHdr) == 16); 286 286 abHdr = self.abReadAheadHdr; … … 756 756 rc = None; 757 757 break; 758 if len(sInput) > 0:758 if sInput: 759 759 oStdIn.uTxsClientCrc32 = zlib.crc32(sInput, oStdIn.uTxsClientCrc32); 760 760 # Convert to a byte array before handing it of to sendMsg or the string … … 1090 1090 # Update the file stream CRC and send it off. 1091 1091 uMyCrc32 = zlib.crc32(abBuf, uMyCrc32); 1092 if len(abBuf) == 0:1092 if not abBuf: 1093 1093 rc = self.sendMsg('DATA EOF', (long(uMyCrc32 & 0xffffffff), )); 1094 1094 else: … … 1108 1108 1109 1109 # EOF? 1110 if len(abBuf) == 0:1110 if not abBuf: 1111 1111 break; 1112 1112 … … 1149 1149 rc = self.taskDownloadCommon(sRemoteFile, oLocalString); 1150 1150 if rc is True: 1151 if len(oLocalString.asContent) == 0:1151 if not oLocalString.asContent: 1152 1152 rc = ''; 1153 1153 else: … … 1930 1930 self.oSocket.setblocking(0); # just in case it's not set. 1931 1931 sData = "1"; 1932 while len(sData) > 0:1932 while sData: 1933 1933 sData = self.oSocket.recv(16384); 1934 1934 except: … … 1946 1946 self.oCv.release(); 1947 1947 1948 def sendBytes(self, ab Msg, cMsTimeout):1948 def sendBytes(self, abBuf, cMsTimeout): 1949 1949 if self.oSocket is None: 1950 1950 reporter.error('TransportTcp.sendBytes: No connection.'); … … 1953 1953 # Try send it all. 1954 1954 try: 1955 cbSent = self.oSocket.send(ab Msg);1956 if cbSent == len(ab Msg):1955 cbSent = self.oSocket.send(abBuf); 1956 if cbSent == len(abBuf): 1957 1957 return True; 1958 1958 except Exception, oXcpt: 1959 1959 if not self.__isWouldBlockXcpt(oXcpt): 1960 reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(ab Msg)));1960 reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(abBuf))); 1961 1961 return False; 1962 1962 cbSent = 0; … … 1967 1967 cMsElapsed = base.timestampMilli() - msStart; 1968 1968 if cMsElapsed > cMsTimeout: 1969 reporter.error('TranportTcp.sendBytes: %s bytes timed out (1)' % (len(ab Msg)));1969 reporter.error('TranportTcp.sendBytes: %s bytes timed out (1)' % (len(abBuf))); 1970 1970 break; 1971 1971 … … 1973 1973 try: 1974 1974 ttRc = select.select([], [self.oSocket], [self.oSocket], (cMsTimeout - cMsElapsed) / 1000.0); 1975 if len(ttRc[2]) > 0 and len(ttRc[1]) == 0:1975 if ttRc[2] and not ttRc[1]: 1976 1976 reporter.error('TranportTcp.sendBytes: select returned with exception'); 1977 1977 break; 1978 if len(ttRc[1]) == 0:1979 reporter.error('TranportTcp.sendBytes: %s bytes timed out (2)' % (len(ab Msg)));1978 if not ttRc[1]: 1979 reporter.error('TranportTcp.sendBytes: %s bytes timed out (2)' % (len(abBuf))); 1980 1980 break; 1981 1981 except: … … 1985 1985 # Try send more. 1986 1986 try: 1987 cbSent += self.oSocket.send(ab Msg[cbSent:]);1988 if cbSent == len(ab Msg):1987 cbSent += self.oSocket.send(abBuf[cbSent:]); 1988 if cbSent == len(abBuf): 1989 1989 return True; 1990 1990 except Exception, oXcpt: 1991 1991 if not self.__isWouldBlockXcpt(oXcpt): 1992 reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(ab Msg)));1992 reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(abBuf))); 1993 1993 break; 1994 1994 … … 2011 2011 try: 2012 2012 abBuf = self.oSocket.recv(cb - len(self.abReadAhead)); 2013 if len(abBuf) > 0:2013 if abBuf: 2014 2014 self.abReadAhead.extend(array.array('B', abBuf)); 2015 2015 except Exception, oXcpt: … … 2026 2026 cMsElapsed = base.timestampMilli() - msStart; 2027 2027 if cMsElapsed > cMsTimeout: 2028 if not fNoDataOk or len(self.abReadAhead) > 0:2028 if not fNoDataOk or self.abReadAhead: 2029 2029 reporter.error('TranportTcp.recvBytes: %s/%s bytes timed out (1)' % (len(self.abReadAhead), cb)); 2030 2030 break; … … 2033 2033 try: 2034 2034 ttRc = select.select([self.oSocket], [], [self.oSocket], (cMsTimeout - cMsElapsed) / 1000.0); 2035 if len(ttRc[2]) > 0 and len(ttRc[0]) == 0:2035 if ttRc[2] and not ttRc[0]: 2036 2036 reporter.error('TranportTcp.recvBytes: select returned with exception'); 2037 2037 break; 2038 if len(ttRc[0]) == 0:2039 if not fNoDataOk or len(self.abReadAhead) > 0:2038 if not ttRc[0]: 2039 if not fNoDataOk or self.abReadAhead: 2040 2040 reporter.error('TranportTcp.recvBytes: %s/%s bytes timed out (2) fNoDataOk=%s' 2041 2041 % (len(self.abReadAhead), cb, fNoDataOk)); … … 2048 2048 try: 2049 2049 abBuf = self.oSocket.recv(cb - len(self.abReadAhead)); 2050 if len(abBuf) == 0:2050 if not abBuf: 2051 2051 reporter.error('TranportTcp.recvBytes: %s/%s bytes (%s) - connection has been shut down' 2052 2052 % (len(self.abReadAhead), cb, fNoDataOk)); … … 2059 2059 reporter.log('recv => exception %s' % (oXcpt,)); 2060 2060 if not self.__isWouldBlockXcpt(oXcpt): 2061 if not fNoDataOk or not self.__isConnectionReset(oXcpt) or len(self.abReadAhead) > 0:2061 if not fNoDataOk or not self.__isConnectionReset(oXcpt) or self.abReadAhead: 2062 2062 reporter.errorXcpt('TranportTcp.recvBytes: %s/%s bytes (%s)' % (len(self.abReadAhead), cb, fNoDataOk)); 2063 2063 break; … … 2075 2075 try: 2076 2076 ttRc = select.select([], [], [self.oSocket], 0.0); 2077 if len(ttRc[2]) > 0:2077 if ttRc[2]: 2078 2078 return False; 2079 2079 … … 2086 2086 try: 2087 2087 ttRc = select.select([self.oSocket], [], [], cMsTimeout / 1000.0); 2088 if len(ttRc[0]) == 0:2088 if not ttRc[0]: 2089 2089 return False; 2090 2090 except:
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器