- Timestamp:
- Mar 8, 2022 2:15:09 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150374
- Location:
- trunk/src/VBox/ValidationKit/testboxscript
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testboxscript/testboxcommand.py
r93115 r94125 129 129 130 130 # Kick off the task and ACK the command. 131 self._oCurTaskLock.acquire(); 132 try: 131 with self._oCurTaskLock: 133 132 self._oCurTask = TestBoxExecTask(self._oTestBoxScript, idResult = idResult, sScriptZips = sScriptZips, 134 133 sScriptCmdLine = sScriptCmdLine, cSecTimeout = cSecTimeout); 135 finally:136 self._oCurTaskLock.release();137 134 oConnection.sendAckAndClose(constants.tbresp.CMD_EXEC); 138 135 return True; … … 327 324 return (-1, '', False); 328 325 329 self._oCurTaskLock.acquire(); 330 self._oCurTask = oTask; 331 self._oCurTaskLock.release(); 326 with self._oCurTaskLock: 327 self._oCurTask = oTask; 332 328 333 329 return (oTask.idTestBox, oTask.sTestBoxName, True); … … 351 347 def _getCurTask(self): 352 348 """ Gets the current task in a paranoidly safe manny. """ 353 self._oCurTaskLock.acquire(); 354 oCurTask = self._oCurTask; 355 self._oCurTaskLock.release(); 349 with self._oCurTaskLock: 350 oCurTask = self._oCurTask; 356 351 return oCurTask; 357 352 -
trunk/src/VBox/ValidationKit/testboxscript/testboxscript_real.py
r93115 r94125 182 182 constants.tbreq.SIGNON_PARAM_SCRATCH_SIZE: { self.VALUE: None, self.FN: self._getFreeScratchSpace }, 183 183 } 184 for sItem in self._ddSignOnParams: 184 for sItem in self._ddSignOnParams: # pylint: disable=consider-using-dict-items 185 185 if self._ddSignOnParams[sItem][self.FN] is not None: 186 186 self._ddSignOnParams[sItem][self.VALUE] = self._ddSignOnParams[sItem][self.FN]() … … 189 189 testboxcommons.log('Test Manager URL: %s' % self._oOptions.sTestManagerUrl,) 190 190 testboxcommons.log('Scratch root path: %s' % self._oOptions.sScratchRoot,) 191 for sItem in self._ddSignOnParams: 191 for sItem in self._ddSignOnParams: # pylint: disable=consider-using-dict-items 192 192 testboxcommons.log('Sign-On value %18s: %s' % (sItem, self._ddSignOnParams[sItem][self.VALUE])); 193 193 … … 323 323 if sType == 'cifs': 324 324 ## @todo This stuff doesn't work on wei01-x4600b.de.oracle.com running 11.1. FIXME! 325 oPasswdFile = tempfile.TemporaryFile(); 325 oPasswdFile = tempfile.TemporaryFile(); # pylint: disable=consider-using-with 326 326 oPasswdFile.write(sPassword + '\n'); 327 327 oPasswdFile.flush(); … … 795 795 # Assemble SIGN-ON request parameters and send the request. 796 796 dParams = {}; 797 for sParam in self._ddSignOnParams: 797 for sParam in self._ddSignOnParams: # pylint: disable=consider-using-dict-items 798 798 dParams[sParam] = self._ddSignOnParams[sParam][self.VALUE]; 799 799 oResponse = TestBoxConnection.sendSignOn(self._oOptions.sTestManagerUrl, dParams); … … 848 848 # Refresh sign-on parameters, changes triggers sign-on. 849 849 fNeedSignOn = not self._fSignedOn or self._fNeedReSignOn; 850 for item in self._ddSignOnParams:851 if self._ddSignOnParams[ item][self.FN] is None:850 for sItem in self._ddSignOnParams: # pylint: disable=consider-using-dict-items 851 if self._ddSignOnParams[sItem][self.FN] is None: 852 852 continue 853 853 854 sOldValue = self._ddSignOnParams[ item][self.VALUE]855 self._ddSignOnParams[ item][self.VALUE] = self._ddSignOnParams[item][self.FN]()856 if sOldValue != self._ddSignOnParams[ item][self.VALUE]:854 sOldValue = self._ddSignOnParams[sItem][self.VALUE] 855 self._ddSignOnParams[sItem][self.VALUE] = self._ddSignOnParams[sItem][self.FN]() 856 if sOldValue != self._ddSignOnParams[sItem][self.VALUE]: 857 857 fNeedSignOn = True 858 testboxcommons.log('Detected %s parameter change: %s -> %s' %859 (item, sOldValue, self._ddSignOnParams[item][self.VALUE]))858 testboxcommons.log('Detected %s parameter change: %s -> %s' 859 % (sItem, sOldValue, self._ddSignOnParams[sItem][self.VALUE],)) 860 860 861 861 if fNeedSignOn: -
trunk/src/VBox/ValidationKit/testboxscript/testboxtasks.py
r93115 r94125 184 184 """ 185 185 fRc = True; 186 self._oBackLogFlushLock.acquire(); 187 188 # Grab the current back log. 189 self._oBackLogLock.acquire(); 190 asBackLog = self._asBackLog; 191 self._asBackLog = []; 192 self._cchBackLog = 0; 193 self._secTsBackLogFlush = utils.timestampSecond(); 194 self._oBackLogLock.release(); 195 196 # If there is anything to flush, flush it. 197 if asBackLog: 198 sBody = ''; 199 for sLine in asBackLog: 200 sBody += sLine + '\n'; 201 202 oConnection = None; 203 try: 204 if oGivenConnection is None: 205 oConnection = self._oTestBoxScript.openTestManagerConnection(); 206 oConnection.postRequest(constants.tbreq.LOG_MAIN, {constants.tbreq.LOG_PARAM_BODY: sBody}); 207 oConnection.close(); 208 else: 209 oGivenConnection.postRequest(constants.tbreq.LOG_MAIN, {constants.tbreq.LOG_PARAM_BODY: sBody}); 210 except Exception as oXcpt: 211 testboxcommons.log('_logFlush error: %s' % (oXcpt,)); 212 if len(sBody) < self.kcchMaxBackLog * 4: 213 self._oBackLogLock.acquire(); 214 asBackLog.extend(self._asBackLog); 215 self._asBackLog = asBackLog; 216 # Don't restore _cchBackLog as there is no point in retrying immediately. 217 self._oBackLogLock.release(); 218 if oConnection is not None: # Be kind to apache. 219 try: oConnection.close(); 220 except: pass; 221 fRc = False; 222 223 self._oBackLogFlushLock.release(); 186 187 with self._oBackLogFlushLock: 188 # Grab the current back log. 189 with self._oBackLogLock: 190 asBackLog = self._asBackLog; 191 self._asBackLog = []; 192 self._cchBackLog = 0; 193 self._secTsBackLogFlush = utils.timestampSecond(); 194 195 # If there is anything to flush, flush it. 196 if asBackLog: 197 sBody = ''; 198 for sLine in asBackLog: 199 sBody += sLine + '\n'; 200 201 oConnection = None; 202 try: 203 if oGivenConnection is None: 204 oConnection = self._oTestBoxScript.openTestManagerConnection(); 205 oConnection.postRequest(constants.tbreq.LOG_MAIN, {constants.tbreq.LOG_PARAM_BODY: sBody}); 206 oConnection.close(); 207 else: 208 oGivenConnection.postRequest(constants.tbreq.LOG_MAIN, {constants.tbreq.LOG_PARAM_BODY: sBody}); 209 except Exception as oXcpt: 210 testboxcommons.log('_logFlush error: %s' % (oXcpt,)); 211 if len(sBody) < self.kcchMaxBackLog * 4: 212 with self._oBackLogLock: 213 asBackLog.extend(self._asBackLog); 214 self._asBackLog = asBackLog; 215 # Don't restore _cchBackLog as there is no point in retrying immediately. 216 if oConnection is not None: # Be kind to apache. 217 try: oConnection.close(); 218 except: pass; 219 fRc = False; 220 224 221 return fRc; 225 222 … … 248 245 sFullMsg = sMessage; 249 246 250 self._oBackLogLock.acquire(); 251 self._asBackLog.append(sFullMsg); 252 cchBackLog = self._cchBackLog + len(sFullMsg) + 1; 253 self._cchBackLog = cchBackLog; 254 secTsBackLogFlush = self._secTsBackLogFlush; 255 self._oBackLogLock.release(); 247 with self._oBackLogLock: 248 self._asBackLog.append(sFullMsg); 249 cchBackLog = self._cchBackLog + len(sFullMsg) + 1; 250 self._cchBackLog = cchBackLog; 251 secTsBackLogFlush = self._secTsBackLogFlush; 256 252 257 253 testboxcommons.log(sFullMsg); … … 642 638 """ 643 639 try: 644 oFile = open(sPath, "rb");645 sStr = oFile.read();640 with open(sPath, "rb") as oFile: 641 sStr = oFile.read(); 646 642 sStr = sStr.decode('utf-8'); 647 oFile.close();648 643 return sStr.strip(); 649 644 except Exception as oXcpt: … … 662 657 try: 663 658 os.remove(sScriptCmdLine); 664 oFile = open(sScriptCmdLine, 'wb'); 665 oFile.close(); 659 open(sScriptCmdLine, 'wb').close(); # pylint: disable=consider-using-with 666 660 except Exception as oXcpt: 667 661 self._log('Error truncating "%s": %s' % (sScriptCmdLine, oXcpt)); … … 781 775 """ 782 776 try: 783 oFile = open(sPath, "wb"); 784 oFile.write(sContent.encode('utf-8')); 785 oFile.flush(); 786 try: os.fsync(oFile.fileno()); 787 except: pass; 788 oFile.close(); 777 with open(sPath, "wb") as oFile: 778 oFile.write(sContent.encode('utf-8')); 779 oFile.flush(); 780 try: os.fsync(oFile.fileno()); 781 except: pass; 789 782 except Exception as oXcpt: 790 783 raise Exception('Failed to write "%s": %s' % (sPath, oXcpt)); -
trunk/src/VBox/ValidationKit/testboxscript/testboxupgrade.py
r93115 r94125 40 40 41 41 # Validation Kit imports. 42 from common import utils; 42 43 import testboxcommons 43 44 from testboxscript import TBS_EXITCODE_SYNTAX; 44 from common import utils;45 45 46 46 # Figure where we are. … … 127 127 if sys.executable: 128 128 asArgs.insert(0, sys.executable); 129 oChild = subprocess.Popen(asArgs, shell = False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT); 129 oChild = subprocess.Popen(asArgs, shell = False, # pylint: disable=consider-using-with 130 stdout=subprocess.PIPE, stderr=subprocess.STDOUT); 130 131 131 132 asBuf = [] … … 300 301 # We'll remove them next time we upgrade. 301 302 # 302 oZip = zipfile.ZipFile(sZipFile, 'r'); 303 oZip = zipfile.ZipFile(sZipFile, 'r'); # No 'with' support in 2.6 class: pylint: disable=consider-using-with 303 304 asMembers = _doUpgradeCheckZip(oZip); 304 305 if asMembers is None:
Note:
See TracChangeset
for help on using the changeset viewer.