Index: /trunk/src/VBox/ValidationKit/testboxscript/testboxcommand.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testboxscript/testboxcommand.py	(revision 70547)
+++ /trunk/src/VBox/ValidationKit/testboxscript/testboxcommand.py	(revision 70548)
@@ -181,9 +181,9 @@
         try:
             utils.sudoProcessOutputChecked(asCmd);
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             if asCmd2 is not None:
                 try:
                     utils.sudoProcessOutputChecked(asCmd2);
-                except Exception, oXcpt:
+                except Exception as oXcpt:
                     testboxcommons.log('Error executing reboot command "%s" as well as "%s": %s' % (asCmd, asCmd2, oXcpt));
                     return False;
@@ -278,5 +278,5 @@
         try:
             sCmdName = oResponse.getStringChecked(constants.tbresp.ALL_PARAM_RESULT);
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             oConnection.close();
             return False;
@@ -289,5 +289,5 @@
                 # Execute the handler.
                 fRc = self._dfnCommands[sCmdName](oResponse, oConnection)
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 # NACK the command if an exception is raised during parameter validation.
                 testboxcommons.log1Xcpt('Exception executing "%s": %s' % (sCmdName, oXcpt));
@@ -295,5 +295,5 @@
                     try:
                         oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NACK, sCmdName);
-                    except Exception, oXcpt2:
+                    except Exception as oXcpt2:
                         testboxcommons.log('Failed to NACK "%s": %s' % (sCmdName, oXcpt2));
         elif sCmdName in [constants.tbresp.STATUS_DEAD, constants.tbresp.STATUS_NACK]:
@@ -304,5 +304,5 @@
             try:
                 oConnection.sendReplyAndClose(constants.tbreq.COMMAND_NOTSUP, sCmdName);
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 testboxcommons.log('Failed to NOTSUP "%s": %s' % (sCmdName, oXcpt));
         return fRc;
Index: /trunk/src/VBox/ValidationKit/testboxscript/testboxconnection.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testboxscript/testboxconnection.py	(revision 70547)
+++ /trunk/src/VBox/ValidationKit/testboxscript/testboxconnection.py	(revision 70548)
@@ -31,8 +31,12 @@
 
 # Standard python imports.
-import httplib
+import sys;
 import urllib
-import urlparse
-import sys
+if sys.version_info[0] >= 3:
+    import http.client as httplib;
+    import urllib.parse as urlparse;
+else:
+    import httplib;
+    import urlparse;
 
 # Validation Kit imports.
@@ -66,5 +70,5 @@
             # TestBoxConnection.postRequestRaw).
             ##testboxcommons.log2('SERVER RESPONSE: "%s"' % (sBody,))
-            self._dResponse = urlparse.parse_qs(sBody, strict_parsing=True);
+            self._dResponse = urllib_parse_qs(sBody, strict_parsing=True);
 
             # Convert the dictionary from 'field:values' to 'field:value'. Fail
Index: /trunk/src/VBox/ValidationKit/testboxscript/testboxscript.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testboxscript/testboxscript.py	(revision 70547)
+++ /trunk/src/VBox/ValidationKit/testboxscript/testboxscript.py	(revision 70548)
@@ -67,8 +67,8 @@
         """
         if self.oTask is not None:
-            print 'Wait for child task...'
+            print('Wait for child task...')
             self.oTask.terminate()
             self.oTask.wait()
-            print 'done. Exiting'
+            print('done. Exiting')
             self.oTask = None;
 
@@ -108,8 +108,8 @@
         rcExit = TBS_EXITCODE_FAILURE;
         while True:
-            self.oTask = subprocess.Popen(asArgs,
-                                          shell = False,
-                                          creationflags = (0 if platform.system() != 'Windows'
-                                                           else subprocess.CREATE_NEW_PROCESS_GROUP)); # for Ctrl-C isolation
+            fCreationFlags = 0;
+            if platform.system() == 'Windows':
+                fCreationFlags = getattr(subprocess, 'CREATE_NEW_PROCESS_GROUP', 0x00000200); # for Ctrl-C isolation (python 2.7)
+            self.oTask = subprocess.Popen(asArgs, shell = False, creationflags = fCreationFlags);
             rcExit = self.oTask.wait();
             self.oTask = None;
Index: /trunk/src/VBox/ValidationKit/testboxscript/testboxscript_real.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testboxscript/testboxscript_real.py	(revision 70547)
+++ /trunk/src/VBox/ValidationKit/testboxscript/testboxscript_real.py	(revision 70548)
@@ -59,4 +59,8 @@
 from testboxconnection  import TestBoxConnection;
 from testboxscript      import TBS_EXITCODE_SYNTAX, TBS_EXITCODE_FAILURE;
+
+# Python 3 hacks:
+if sys.version_info[0] >= 3:
+    long = int;     # pylint: disable=redefined-builtin,invalid-name
 
 
@@ -143,5 +147,5 @@
         for sDir in [self._oOptions.sScratchRoot, self._sScratchSpill, self._sScratchScripts, self._sScratchState]:
             if not os.path.isdir(sDir):
-                os.makedirs(sDir, 0700);
+                os.makedirs(sDir, 0o700);
 
         # We count consecutive reinitScratch failures and will reboot the
@@ -695,5 +699,5 @@
                 if os.path.exists(sFullName):
                     raise Exception('Still exists after deletion, weird.');
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 if    fUseTheForce is True \
                   and utils.getHostOs() not in ['win', 'os2'] \
@@ -731,6 +735,6 @@
             if not os.path.isdir(sDir):
                 try:
-                    os.makedirs(sDir, 0700);
-                except Exception, oXcpt:
+                    os.makedirs(sDir, 0o700);
+                except Exception as oXcpt:
                     fnLog('Error creating "%s": %s' % (sDir, oXcpt));
                     oRc.fRc = False;
@@ -792,5 +796,5 @@
             idTestBox    = oResponse.getIntChecked(constants.tbresp.SIGNON_PARAM_ID, 1, 0x7ffffffe);
             sTestBoxName = oResponse.getStringChecked(constants.tbresp.SIGNON_PARAM_NAME);
-        except TestBoxException, err:
+        except TestBoxException as err:
             testboxcommons.log('Failed to sign-on: %s' % (str(err),))
             testboxcommons.log('Server response: %s' % (oResponse.toString(),));
@@ -1023,5 +1027,5 @@
         try:
             oTestBoxScript = TestBoxScript(oOptions);
-        except TestBoxScriptException, oXcpt:
+        except TestBoxScriptException as oXcpt:
             print('Error: %s' % (oXcpt,));
             return TBS_EXITCODE_SYNTAX;
Index: /trunk/src/VBox/ValidationKit/testboxscript/testboxtasks.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testboxscript/testboxtasks.py	(revision 70547)
+++ /trunk/src/VBox/ValidationKit/testboxscript/testboxtasks.py	(revision 70548)
@@ -208,5 +208,5 @@
                 else:
                     oGivenConnection.postRequest(constants.tbreq.LOG_MAIN, {constants.tbreq.LOG_PARAM_BODY: sBody});
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 testboxcommons.log('_logFlush error: %s' % (oXcpt,));
                 if len(sBody) < self.kcchMaxBackLog * 4:
@@ -242,5 +242,5 @@
                 oNow = datetime.utcnow();
                 sTs = '%02u:%02u:%02u.%06u ' % (oNow.hour, oNow.minute, oNow.second, oNow.microsecond);
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 sTs = 'oXcpt=%s ' % (oXcpt);
             sFullMsg = sTs + sMessage;
@@ -294,5 +294,5 @@
                 oConnection.postRequest(constants.tbreq.EXEC_COMPLETED, {constants.tbreq.EXEC_COMPLETED_PARAM_RESULT: sResult});
                 oConnection.close();
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 if utils.timestampSecond() - secStart < self.ksecTestManagerTimeout:
                     self._log('_reportDone exception (%s) - retrying...' % (oXcpt,));
@@ -375,5 +375,5 @@
             try:
                 sLine = oStdOut.readline();
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 self._log('child (%s) pipe I/O error: %s' % (sAction, oXcpt,));
                 break;
@@ -396,5 +396,5 @@
         try:
             oStdOut.close();
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             self._log('warning: Exception closing stdout pipe of "%s" child: %s' % (sAction, oXcpt,));
 
@@ -433,5 +433,5 @@
                                             preexec_fn = (None if utils.getHostOs() in ['win', 'os2']
                                                           else os.setsid)); # pylint: disable=E1101
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             self._log('Error creating child process %s: %s' % (asArgs, oXcpt));
             return (False, None);
@@ -519,5 +519,5 @@
                 try:
                     os.killpg(iProcGroup, signal.SIGTERM); # pylint: disable=E1101
-                except Exception, oXcpt:
+                except Exception as oXcpt:
                     self._log('killpg() failed: %s' % (oXcpt,));
 
@@ -525,5 +525,5 @@
                 self._oChild.terminate();
                 oChild.oOutputThread.join(self.kcSecTerminateOutputTimeout);
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 self._log('terminate() failed: %s' % (oXcpt,));
 
@@ -535,5 +535,5 @@
             try:
                 os.killpg(iProcGroup, signal.SIGKILL); # pylint: disable=E1101
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 self._log('killpg() failed: %s' % (oXcpt,));
 
@@ -543,5 +543,5 @@
                 self._oChild.kill();
                 oChild.oOutputThread.join(self.kcSecKillOutputTimeout);
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 self._log('kill() failed: %s' % (oXcpt,));
 
@@ -644,5 +644,5 @@
             oFile.close();
             return sStr.strip();
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             raise Exception('Failed to read "%s": %s' % (sPath, oXcpt));
 
@@ -661,5 +661,5 @@
             oFile = open(sScriptCmdLine, 'wb');
             oFile.close();
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             self._log('Error truncating "%s": %s' % (sScriptCmdLine, oXcpt));
 
@@ -698,5 +698,5 @@
         try:
             sRawInfo = utils.processOutputChecked(['nvram', 'aapl,panic-info']);
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             return 'exception running nvram: %s' % (oXcpt,);
 
@@ -784,5 +784,5 @@
             except:  pass;
             oFile.close();
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             raise Exception('Failed to write "%s": %s' % (sPath, oXcpt));
         return True;
@@ -801,5 +801,5 @@
             self._writeStateFile(os.path.join(sScriptState, 'testbox-id.txt'),     str(self._oTestBoxScript.getTestBoxId()));
             self._writeStateFile(os.path.join(sScriptState, 'testbox-name.txt'),   self._oTestBoxScript.getTestBoxName());
-        except Exception, oXcpt:
+        except Exception as oXcpt:
             self._log('Failed to write state: %s' % (oXcpt,));
             return False;
Index: /trunk/src/VBox/ValidationKit/testboxscript/testboxupgrade.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testboxscript/testboxupgrade.py	(revision 70547)
+++ /trunk/src/VBox/ValidationKit/testboxscript/testboxupgrade.py	(revision 70548)
@@ -90,5 +90,5 @@
     for sMember in asMembers:
         if sMember.endswith('/'):
-            os.makedirs(os.path.join(sUpgradeDir, sMember.replace('/', os.path.sep)), 0775);
+            os.makedirs(os.path.join(sUpgradeDir, sMember.replace('/', os.path.sep)), 0o775);
         else:
             oZip.extract(sMember, sUpgradeDir);
@@ -110,6 +110,6 @@
                 return False;
             try:
-                os.chmod(sFull, 0755);
-            except Exception, oXcpt:
+                os.chmod(sFull, 0o755);
+            except Exception as oXcpt:
                 testboxcommons.log('warning chmod error on %s: %s' % (sFull, oXcpt));
     return True;
@@ -170,5 +170,5 @@
                 sFull = os.path.join(g_ksValidationKitDir, sMember);
                 if not os.path.isdir(sFull):
-                    os.makedirs(sFull, 0755);
+                    os.makedirs(sFull, 0o755);
 
     #
@@ -189,14 +189,14 @@
                 try:
                     os.rename(sDst, sDstRm);
-                except Exception, oXcpt:
+                except Exception as oXcpt:
                     testboxcommons.log('Error: failed to rename (old) "%s" to "%s": %s' % (sDst, sDstRm, oXcpt));
                     try:
                         shutil.copy(sDst, sDstRm);
-                    except Exception, oXcpt:
+                    except Exception as oXcpt:
                         testboxcommons.log('Error: failed to copy (old) "%s" to "%s": %s' % (sDst, sDstRm, oXcpt));
                         break;
                     try:
                         os.unlink(sDst);
-                    except Exception, oXcpt:
+                    except Exception as oXcpt:
                         testboxcommons.log('Error: failed to unlink (old) "%s": %s' % (sDst, oXcpt));
                         break;
@@ -206,5 +206,5 @@
             try:
                 os.rename(sSrc, sDst);
-            except Exception, oXcpt:
+            except Exception as oXcpt:
                 testboxcommons.log('Warning: failed to rename (new) "%s" to "%s": %s' % (sSrc, sDst, oXcpt));
                 try:
@@ -259,5 +259,5 @@
                 try:
                     os.rmdir(sFull);
-                except Exception, oXcpt:
+                except Exception as oXcpt:
                     testboxcommons.log('Warning: failed to rmdir obsolete dir "%s": %s' % (sFull, oXcpt));
 
@@ -268,5 +268,5 @@
                 try:
                     os.unlink(sFull);
-                except Exception, oXcpt:
+                except Exception as oXcpt:
                     testboxcommons.log('Warning: failed to unlink obsolete file "%s": %s' % (sFull, oXcpt));
     return True;
