Changeset 70548 in vbox
- Timestamp:
- Jan 11, 2018 8:46:02 PM (7 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testboxscript
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testboxscript/testboxcommand.py
r69111 r70548 181 181 try: 182 182 utils.sudoProcessOutputChecked(asCmd); 183 except Exception ,oXcpt:183 except Exception as oXcpt: 184 184 if asCmd2 is not None: 185 185 try: 186 186 utils.sudoProcessOutputChecked(asCmd2); 187 except Exception ,oXcpt:187 except Exception as oXcpt: 188 188 testboxcommons.log('Error executing reboot command "%s" as well as "%s": %s' % (asCmd, asCmd2, oXcpt)); 189 189 return False; … … 278 278 try: 279 279 sCmdName = oResponse.getStringChecked(constants.tbresp.ALL_PARAM_RESULT); 280 except Exception ,oXcpt:280 except Exception as oXcpt: 281 281 oConnection.close(); 282 282 return False; … … 289 289 # Execute the handler. 290 290 fRc = self._dfnCommands[sCmdName](oResponse, oConnection) 291 except Exception ,oXcpt:291 except Exception as oXcpt: 292 292 # NACK the command if an exception is raised during parameter validation. 293 293 testboxcommons.log1Xcpt('Exception executing "%s": %s' % (sCmdName, oXcpt)); … … 295 295 try: 296 296 oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NACK, sCmdName); 297 except Exception ,oXcpt2:297 except Exception as oXcpt2: 298 298 testboxcommons.log('Failed to NACK "%s": %s' % (sCmdName, oXcpt2)); 299 299 elif sCmdName in [constants.tbresp.STATUS_DEAD, constants.tbresp.STATUS_NACK]: … … 304 304 try: 305 305 oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NOTSUP, sCmdName); 306 except Exception ,oXcpt:306 except Exception as oXcpt: 307 307 testboxcommons.log('Failed to NOTSUP "%s": %s' % (sCmdName, oXcpt)); 308 308 return fRc; -
trunk/src/VBox/ValidationKit/testboxscript/testboxconnection.py
r69111 r70548 31 31 32 32 # Standard python imports. 33 import httplib33 import sys; 34 34 import urllib 35 import urlparse 36 import sys 35 if sys.version_info[0] >= 3: 36 import http.client as httplib; 37 import urllib.parse as urlparse; 38 else: 39 import httplib; 40 import urlparse; 37 41 38 42 # Validation Kit imports. … … 66 70 # TestBoxConnection.postRequestRaw). 67 71 ##testboxcommons.log2('SERVER RESPONSE: "%s"' % (sBody,)) 68 self._dResponse = url parse.parse_qs(sBody, strict_parsing=True);72 self._dResponse = urllib_parse_qs(sBody, strict_parsing=True); 69 73 70 74 # Convert the dictionary from 'field:values' to 'field:value'. Fail -
trunk/src/VBox/ValidationKit/testboxscript/testboxscript.py
r69111 r70548 67 67 """ 68 68 if self.oTask is not None: 69 print 'Wait for child task...'69 print('Wait for child task...') 70 70 self.oTask.terminate() 71 71 self.oTask.wait() 72 print 'done. Exiting'72 print('done. Exiting') 73 73 self.oTask = None; 74 74 … … 108 108 rcExit = TBS_EXITCODE_FAILURE; 109 109 while True: 110 self.oTask = subprocess.Popen(asArgs,111 shell = False,112 creationflags = (0 if platform.system() != 'Windows'113 else subprocess.CREATE_NEW_PROCESS_GROUP)); # for Ctrl-C isolation110 fCreationFlags = 0; 111 if platform.system() == 'Windows': 112 fCreationFlags = getattr(subprocess, 'CREATE_NEW_PROCESS_GROUP', 0x00000200); # for Ctrl-C isolation (python 2.7) 113 self.oTask = subprocess.Popen(asArgs, shell = False, creationflags = fCreationFlags); 114 114 rcExit = self.oTask.wait(); 115 115 self.oTask = None; -
trunk/src/VBox/ValidationKit/testboxscript/testboxscript_real.py
r69111 r70548 59 59 from testboxconnection import TestBoxConnection; 60 60 from testboxscript import TBS_EXITCODE_SYNTAX, TBS_EXITCODE_FAILURE; 61 62 # Python 3 hacks: 63 if sys.version_info[0] >= 3: 64 long = int; # pylint: disable=redefined-builtin,invalid-name 61 65 62 66 … … 143 147 for sDir in [self._oOptions.sScratchRoot, self._sScratchSpill, self._sScratchScripts, self._sScratchState]: 144 148 if not os.path.isdir(sDir): 145 os.makedirs(sDir, 0 700);149 os.makedirs(sDir, 0o700); 146 150 147 151 # We count consecutive reinitScratch failures and will reboot the … … 695 699 if os.path.exists(sFullName): 696 700 raise Exception('Still exists after deletion, weird.'); 697 except Exception ,oXcpt:701 except Exception as oXcpt: 698 702 if fUseTheForce is True \ 699 703 and utils.getHostOs() not in ['win', 'os2'] \ … … 731 735 if not os.path.isdir(sDir): 732 736 try: 733 os.makedirs(sDir, 0 700);734 except Exception ,oXcpt:737 os.makedirs(sDir, 0o700); 738 except Exception as oXcpt: 735 739 fnLog('Error creating "%s": %s' % (sDir, oXcpt)); 736 740 oRc.fRc = False; … … 792 796 idTestBox = oResponse.getIntChecked(constants.tbresp.SIGNON_PARAM_ID, 1, 0x7ffffffe); 793 797 sTestBoxName = oResponse.getStringChecked(constants.tbresp.SIGNON_PARAM_NAME); 794 except TestBoxException ,err:798 except TestBoxException as err: 795 799 testboxcommons.log('Failed to sign-on: %s' % (str(err),)) 796 800 testboxcommons.log('Server response: %s' % (oResponse.toString(),)); … … 1023 1027 try: 1024 1028 oTestBoxScript = TestBoxScript(oOptions); 1025 except TestBoxScriptException ,oXcpt:1029 except TestBoxScriptException as oXcpt: 1026 1030 print('Error: %s' % (oXcpt,)); 1027 1031 return TBS_EXITCODE_SYNTAX; -
trunk/src/VBox/ValidationKit/testboxscript/testboxtasks.py
r69111 r70548 208 208 else: 209 209 oGivenConnection.postRequest(constants.tbreq.LOG_MAIN, {constants.tbreq.LOG_PARAM_BODY: sBody}); 210 except Exception ,oXcpt:210 except Exception as oXcpt: 211 211 testboxcommons.log('_logFlush error: %s' % (oXcpt,)); 212 212 if len(sBody) < self.kcchMaxBackLog * 4: … … 242 242 oNow = datetime.utcnow(); 243 243 sTs = '%02u:%02u:%02u.%06u ' % (oNow.hour, oNow.minute, oNow.second, oNow.microsecond); 244 except Exception ,oXcpt:244 except Exception as oXcpt: 245 245 sTs = 'oXcpt=%s ' % (oXcpt); 246 246 sFullMsg = sTs + sMessage; … … 294 294 oConnection.postRequest(constants.tbreq.EXEC_COMPLETED, {constants.tbreq.EXEC_COMPLETED_PARAM_RESULT: sResult}); 295 295 oConnection.close(); 296 except Exception ,oXcpt:296 except Exception as oXcpt: 297 297 if utils.timestampSecond() - secStart < self.ksecTestManagerTimeout: 298 298 self._log('_reportDone exception (%s) - retrying...' % (oXcpt,)); … … 375 375 try: 376 376 sLine = oStdOut.readline(); 377 except Exception ,oXcpt:377 except Exception as oXcpt: 378 378 self._log('child (%s) pipe I/O error: %s' % (sAction, oXcpt,)); 379 379 break; … … 396 396 try: 397 397 oStdOut.close(); 398 except Exception ,oXcpt:398 except Exception as oXcpt: 399 399 self._log('warning: Exception closing stdout pipe of "%s" child: %s' % (sAction, oXcpt,)); 400 400 … … 433 433 preexec_fn = (None if utils.getHostOs() in ['win', 'os2'] 434 434 else os.setsid)); # pylint: disable=E1101 435 except Exception ,oXcpt:435 except Exception as oXcpt: 436 436 self._log('Error creating child process %s: %s' % (asArgs, oXcpt)); 437 437 return (False, None); … … 519 519 try: 520 520 os.killpg(iProcGroup, signal.SIGTERM); # pylint: disable=E1101 521 except Exception ,oXcpt:521 except Exception as oXcpt: 522 522 self._log('killpg() failed: %s' % (oXcpt,)); 523 523 … … 525 525 self._oChild.terminate(); 526 526 oChild.oOutputThread.join(self.kcSecTerminateOutputTimeout); 527 except Exception ,oXcpt:527 except Exception as oXcpt: 528 528 self._log('terminate() failed: %s' % (oXcpt,)); 529 529 … … 535 535 try: 536 536 os.killpg(iProcGroup, signal.SIGKILL); # pylint: disable=E1101 537 except Exception ,oXcpt:537 except Exception as oXcpt: 538 538 self._log('killpg() failed: %s' % (oXcpt,)); 539 539 … … 543 543 self._oChild.kill(); 544 544 oChild.oOutputThread.join(self.kcSecKillOutputTimeout); 545 except Exception ,oXcpt:545 except Exception as oXcpt: 546 546 self._log('kill() failed: %s' % (oXcpt,)); 547 547 … … 644 644 oFile.close(); 645 645 return sStr.strip(); 646 except Exception ,oXcpt:646 except Exception as oXcpt: 647 647 raise Exception('Failed to read "%s": %s' % (sPath, oXcpt)); 648 648 … … 661 661 oFile = open(sScriptCmdLine, 'wb'); 662 662 oFile.close(); 663 except Exception ,oXcpt:663 except Exception as oXcpt: 664 664 self._log('Error truncating "%s": %s' % (sScriptCmdLine, oXcpt)); 665 665 … … 698 698 try: 699 699 sRawInfo = utils.processOutputChecked(['nvram', 'aapl,panic-info']); 700 except Exception ,oXcpt:700 except Exception as oXcpt: 701 701 return 'exception running nvram: %s' % (oXcpt,); 702 702 … … 784 784 except: pass; 785 785 oFile.close(); 786 except Exception ,oXcpt:786 except Exception as oXcpt: 787 787 raise Exception('Failed to write "%s": %s' % (sPath, oXcpt)); 788 788 return True; … … 801 801 self._writeStateFile(os.path.join(sScriptState, 'testbox-id.txt'), str(self._oTestBoxScript.getTestBoxId())); 802 802 self._writeStateFile(os.path.join(sScriptState, 'testbox-name.txt'), self._oTestBoxScript.getTestBoxName()); 803 except Exception ,oXcpt:803 except Exception as oXcpt: 804 804 self._log('Failed to write state: %s' % (oXcpt,)); 805 805 return False; -
trunk/src/VBox/ValidationKit/testboxscript/testboxupgrade.py
r69111 r70548 90 90 for sMember in asMembers: 91 91 if sMember.endswith('/'): 92 os.makedirs(os.path.join(sUpgradeDir, sMember.replace('/', os.path.sep)), 0 775);92 os.makedirs(os.path.join(sUpgradeDir, sMember.replace('/', os.path.sep)), 0o775); 93 93 else: 94 94 oZip.extract(sMember, sUpgradeDir); … … 110 110 return False; 111 111 try: 112 os.chmod(sFull, 0 755);113 except Exception ,oXcpt:112 os.chmod(sFull, 0o755); 113 except Exception as oXcpt: 114 114 testboxcommons.log('warning chmod error on %s: %s' % (sFull, oXcpt)); 115 115 return True; … … 170 170 sFull = os.path.join(g_ksValidationKitDir, sMember); 171 171 if not os.path.isdir(sFull): 172 os.makedirs(sFull, 0 755);172 os.makedirs(sFull, 0o755); 173 173 174 174 # … … 189 189 try: 190 190 os.rename(sDst, sDstRm); 191 except Exception ,oXcpt:191 except Exception as oXcpt: 192 192 testboxcommons.log('Error: failed to rename (old) "%s" to "%s": %s' % (sDst, sDstRm, oXcpt)); 193 193 try: 194 194 shutil.copy(sDst, sDstRm); 195 except Exception ,oXcpt:195 except Exception as oXcpt: 196 196 testboxcommons.log('Error: failed to copy (old) "%s" to "%s": %s' % (sDst, sDstRm, oXcpt)); 197 197 break; 198 198 try: 199 199 os.unlink(sDst); 200 except Exception ,oXcpt:200 except Exception as oXcpt: 201 201 testboxcommons.log('Error: failed to unlink (old) "%s": %s' % (sDst, oXcpt)); 202 202 break; … … 206 206 try: 207 207 os.rename(sSrc, sDst); 208 except Exception ,oXcpt:208 except Exception as oXcpt: 209 209 testboxcommons.log('Warning: failed to rename (new) "%s" to "%s": %s' % (sSrc, sDst, oXcpt)); 210 210 try: … … 259 259 try: 260 260 os.rmdir(sFull); 261 except Exception ,oXcpt:261 except Exception as oXcpt: 262 262 testboxcommons.log('Warning: failed to rmdir obsolete dir "%s": %s' % (sFull, oXcpt)); 263 263 … … 268 268 try: 269 269 os.unlink(sFull); 270 except Exception ,oXcpt:270 except Exception as oXcpt: 271 271 testboxcommons.log('Warning: failed to unlink obsolete file "%s": %s' % (sFull, oXcpt)); 272 272 return True;
Note:
See TracChangeset
for help on using the changeset viewer.