VirtualBox

Ignore:
Timestamp:
Jan 10, 2018 3:49:10 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120149
Message:

ValidationKit: More python 3 adjustments.

Location:
trunk/src/VBox/ValidationKit/testdriver
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/base.py

    r70517 r70521  
    5858except: __file__ = sys.argv[0];
    5959g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)));
     60
     61# Python 3 hacks:
     62if sys.version_info[0] >= 3:
     63    long = int;     # pylint: disable=redefined-builtin,invalid-name
    6064
    6165
  • trunk/src/VBox/ValidationKit/testdriver/reporter.py

    r70517 r70521  
    393393            sLogDir = os.path.abspath(os.environ.get('TESTBOX_REPORTER_LOG_DIR', self.sDefLogDir));
    394394            if not os.path.isdir(sLogDir):
    395                 os.makedirs(sLogDir, 0x1e8); # 0750 = 0x1e8
     395                os.makedirs(sLogDir, 0o750);
    396396        except:
    397397            sLogDir = self.sDefLogDir;
    398398            if not os.path.isdir(sLogDir):
    399                 os.makedirs(sLogDir, 0x1e8); # 0750 = 0x1e8
     399                os.makedirs(sLogDir, 0o750);
    400400
    401401        #
     
    405405        self.sLogDir = sLogDir = os.path.join(sLogDir, '%s-%s' % (sTs, self.sName));
    406406        try:
    407             os.makedirs(self.sLogDir, 0x1e8); # 0750 = 0x1e8
     407            os.makedirs(self.sLogDir, 0o750);
    408408        except:
    409409            self.sLogDir = '%s-%s' % (self.sLogDir, os.getpid());
    410             os.makedirs(self.sLogDir, 0x1e8); # 0750 = 0x1e8
     410            os.makedirs(self.sLogDir, 0o750);
    411411
    412412        #
  • trunk/src/VBox/ValidationKit/testdriver/tst-txsclient.py

    r70517 r70521  
    4242import testdriver.reporter as reporter
    4343from common import utils;
     44
     45# Python 3 hacks:
     46if sys.version_info[0] >= 3:
     47    long = int;     # pylint: disable=redefined-builtin,invalid-name
    4448
    4549g_cTests = 0;
     
    6064    global g_cTests, g_cFailures;
    6165    g_cTests = g_cTests + 1;
    62     if isinstance(rc, basestring):
     66    if utils.isString(rc):
    6367        if rc == sExpect:
    6468            return 'PASSED';
  • trunk/src/VBox/ValidationKit/testdriver/txsclient.py

    r70508 r70521  
    3030
    3131# Standard Python imports.
    32 import array
    33 import errno
    34 import os
    35 import select
    36 import socket
    37 import threading
    38 import time
    39 import types
    40 import zlib
    41 import uuid
     32import array;
     33import errno;
     34import os;
     35import select;
     36import socket;
     37import sys;
     38import threading;
     39import time;
     40import types;
     41import zlib;
     42import uuid;
    4243
    4344# Validation Kit imports.
    44 from common     import utils;
    45 from testdriver import base;
    46 from testdriver import reporter;
     45from common             import utils;
     46from testdriver         import base;
     47from testdriver         import reporter;
    4748from testdriver.base    import TdTaskBase;
     49
     50# Python 3 hacks:
     51if sys.version_info[0] >= 3:
     52    long = int;     # pylint: disable=redefined-builtin,invalid-name
    4853
    4954#
     
    118123    """Encodes the u32 value as a little endian byte (B) array."""
    119124    return array.array('B', \
    120                        (  u32             % 256, \
    121                          (u32 / 256)      % 256, \
    122                          (u32 / 65536)    % 256, \
    123                          (u32 / 16777216) % 256) );
     125                       (  u32              % 256, \
     126                         (u32 // 256)      % 256, \
     127                         (u32 // 65536)    % 256, \
     128                         (u32 // 16777216) % 256) );
    124129
    125130
     
    352357        for o in aoPayload:
    353358            try:
    354                 if isinstance(o, basestring):
    355                     # the primitive approach...
    356                     sUtf8 = o.encode('utf_8');
    357                     for i in range(0, len(sUtf8)):
    358                         abPayload.append(ord(sUtf8[i]))
     359                if utils.isString(o):
     360                    if sys.version_info[0] >= 3:
     361                        abPayload.extend(o.encode('utf_8'));
     362                    else:
     363                        # the primitive approach...
     364                        sUtf8 = o.encode('utf_8');
     365                        for i in range(0, len(sUtf8)):
     366                            abPayload.append(ord(sUtf8[i]))
    359367                    abPayload.append(0);
    360368                elif isinstance(o, types.LongType):
     
    724732            aoPayload.append('%s' % (sPutEnv));
    725733        for o in (oStdIn, oStdOut, oStdErr, oTestPipe):
    726             if isinstance(o, basestring):
     734            if utils.isString(o):
    727735                aoPayload.append(o);
    728736            elif o is not None:
     
    748756                if     msPendingInputReply is None \
    749757                   and oStdIn is not None \
    750                    and not isinstance(oStdIn, basestring):
     758                   and not utils.isString(oStdIn):
    751759                    try:
    752760                        sInput = oStdIn.read(65536);
     
    910918        # Cleanup.
    911919        for o in (oStdIn, oStdOut, oStdErr, oTestPipe):
    912             if o is not None and not isinstance(o, basestring):
     920            if o is not None and not utils.isString(o):
    913921                del o.uTxsClientCrc32;      # pylint: disable=E1103
    914922                # Make sure all files are closed
     
    10841092                # Convert to array - this is silly!
    10851093                abBuf = array.array('B');
    1086                 for i, _ in enumerate(sRaw):
    1087                     abBuf.append(ord(sRaw[i]));
     1094                if utils.isString(sRaw):
     1095                    for i, _ in enumerate(sRaw):
     1096                        abBuf.append(ord(sRaw[i]));
     1097                else:
     1098                    abBuf.extend(sRaw);
    10881099                sRaw = None;
    10891100
     
    14061417    #
    14071418
    1408     def asyncMkDir(self, sRemoteDir, fMode = 0700, cMsTimeout = 30000, fIgnoreErrors = False):
     1419    def asyncMkDir(self, sRemoteDir, fMode = 0o700, cMsTimeout = 30000, fIgnoreErrors = False):
    14091420        """
    14101421        Initiates a mkdir task.
     
    14161427        return self.startTask(cMsTimeout, fIgnoreErrors, "mkDir", self.taskMkDir, (sRemoteDir, long(fMode)));
    14171428
    1418     def syncMkDir(self, sRemoteDir, fMode = 0700, cMsTimeout = 30000, fIgnoreErrors = False):
     1429    def syncMkDir(self, sRemoteDir, fMode = 0o700, cMsTimeout = 30000, fIgnoreErrors = False):
    14191430        """Synchronous version."""
    14201431        return self.asyncToSync(self.asyncMkDir, sRemoteDir, long(fMode), cMsTimeout, fIgnoreErrors);
    14211432
    1422     def asyncMkDirPath(self, sRemoteDir, fMode = 0700, cMsTimeout = 30000, fIgnoreErrors = False):
     1433    def asyncMkDirPath(self, sRemoteDir, fMode = 0o700, cMsTimeout = 30000, fIgnoreErrors = False):
    14231434        """
    14241435        Initiates a mkdir -p task.
     
    14301441        return self.startTask(cMsTimeout, fIgnoreErrors, "mkDirPath", self.taskMkDirPath, (sRemoteDir, long(fMode)));
    14311442
    1432     def syncMkDirPath(self, sRemoteDir, fMode = 0700, cMsTimeout = 30000, fIgnoreErrors = False):
     1443    def syncMkDirPath(self, sRemoteDir, fMode = 0o700, cMsTimeout = 30000, fIgnoreErrors = False):
    14331444        """Synchronous version."""
    14341445        return self.asyncToSync(self.asyncMkDirPath, sRemoteDir, long(fMode), cMsTimeout, fIgnoreErrors);
     
    16591670    def __isInProgressXcpt(self, oXcpt):
    16601671        """ In progress exception? """
     1672        reporter.log("oXcpt=%s" % (oXcpt)) ## TMP TMP
     1673        reporter.log("dir(oXcpt)=%s" % (dir(oXcpt))) ## TMP TMP
    16611674        try:
    16621675            if isinstance(oXcpt, socket.error):
    16631676                try:
    1664                     if oXcpt[0] == errno.EINPROGRESS:
     1677                    if oXcpt.errno == errno.EINPROGRESS:
    16651678                        return True;
    16661679                except: pass;
    16671680                # Windows?
    16681681                try:
    1669                     if oXcpt[0] == errno.EWOULDBLOCK:
     1682                    if oXcpt.errno == errno.EWOULDBLOCK:
    16701683                        return True;
    16711684                except: pass;
     
    16791692            if isinstance(oXcpt, socket.error):
    16801693                try:
    1681                     if oXcpt[0] == errno.EWOULDBLOCK:
     1694                    if oXcpt.errno == errno.EWOULDBLOCK:
    16821695                        return True;
    16831696                except: pass;
    16841697                try:
    1685                     if oXcpt[0] == errno.EAGAIN:
     1698                    if oXcpt.errno == errno.EAGAIN:
    16861699                        return True;
    16871700                except: pass;
     
    16951708            if isinstance(oXcpt, socket.error):
    16961709                try:
    1697                     if oXcpt[0] == errno.ECONNRESET:
     1710                    if oXcpt.errno == errno.ECONNRESET:
    16981711                        return True;
    16991712                except: pass;
    17001713                try:
    1701                     if oXcpt[0] == errno.ENETRESET:
     1714                    if oXcpt.errno == errno.ENETRESET:
    17021715                        return True;
    17031716                except: pass;
  • trunk/src/VBox/ValidationKit/testdriver/vbox.py

    r70517 r70521  
    5555from testdriver import vboxtestvms;
    5656
     57# Python 3 hacks:
     58if sys.version_info[0] >= 3:
     59    xrange = range; # pylint: disable=redefined-builtin,invalid-name
     60    long = int;     # pylint: disable=redefined-builtin,invalid-name
    5761
    5862#
     
    23962400            tsNow = datetime.datetime.now()
    23972401            tsDelta = tsNow - tsStart
    2398             if ((tsDelta.microseconds + tsDelta.seconds * 1000000) / 1000) > cMsTimeout:
     2402            if ((tsDelta.microseconds + tsDelta.seconds * 1000000) // 1000) > cMsTimeout:
    23992403                if fErrorOnTimeout:
    24002404                    reporter.errorTimeout('Timeout while waiting for progress.')
  • trunk/src/VBox/ValidationKit/testdriver/vboxinstaller.py

    r69111 r70521  
    562562        if not os.path.exists(sMountPath):
    563563            try:
    564                 os.mkdir(sMountPath, 0755);
     564                os.mkdir(sMountPath, 0o755);
    565565            except:
    566566                reporter.logXcpt();
  • trunk/src/VBox/ValidationKit/testdriver/vboxtestvms.py

    r70491 r70521  
    870870        oSet.aoTestVms.append(oTestVm);
    871871
    872         ## NT 3.x
    873         #oTestVm = TestVm(oSet, 'tst-nt310', sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
    874         #                 sKind = 'WindowsNT3x', acCpusSup = [1],
    875         #                 sHddControllerType = 'BusLogic SCSI Controller', sDvdControllerType = 'BusLogic SCSI Controller' );
    876         #oSet.aoTestVms.append(oTestVm); ## @todo COM
     872        # NT 3.x
     873        oTestVm = TestVm(oSet, 'tst-nt310', sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
     874                         sKind = 'WindowsNT3x', acCpusSup = [1],
     875                         sHddControllerType = 'BusLogic SCSI Controller', sDvdControllerType = 'BusLogic SCSI Controller' );
     876        oSet.aoTestVms.append(oTestVm); ## @todo COM
    877877
    878878        # NT 4
     
    986986        #oSet.aoTestVms.append(oTestVm);
    987987
    988         ## NT 3.x
    989         #oTestVm = TestVm(oSet, 'tst-nt310', sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
    990         #                 sKind = 'WindowsNT3x', acCpusSup = [1],
    991         #                 sHddControllerType = 'BusLogic SCSI Controller', sDvdControllerType = 'BusLogic SCSI Controller' );
    992         #oSet.aoTestVms.append(oTestVm); ## @todo COM
     988        # NT 3.x
     989        oTestVm = TestVm(oSet, 'tst-nt310', sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
     990                         sKind = 'WindowsNT3x', acCpusSup = [1],
     991                         sHddControllerType = 'BusLogic SCSI Controller', sDvdControllerType = 'BusLogic SCSI Controller' );
     992        oSet.aoTestVms.append(oTestVm); ## @todo COM
    993993
    994994        # NT 4
  • trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py

    r70508 r70521  
    3232
    3333# Standard Python imports.
    34 import os
    35 import socket
     34import os;
     35import socket;
     36import sys;
    3637
    3738# Validation Kit imports.
     
    480481                if fErrorOnTimeout:
    481482                    if fIgnoreErrors:
    482                         reporter.log('Timing out after waiting for %u s on "%s" operation %d' \
     483                        reporter.log('Timing out after waiting for %s s on "%s" operation %d' \
    483484                                     % (cMsTimeout / 1000, self.sName, iOperation))
    484485                    else:
    485                         reporter.error('Timing out after waiting for %u s on "%s" operation %d' \
     486                        reporter.error('Timing out after waiting for %s s on "%s" operation %d' \
    486487                                       % (cMsTimeout / 1000, self.sName, iOperation))
    487488                return -1;
     
    15441545                sHostIP = socket.gethostbyname(sHostName)
    15451546                abHostIP = socket.inet_aton(sHostIP)
    1546                 if   ord(abHostIP[0]) == 127 \
    1547                   or (ord(abHostIP[0]) == 169 and ord(abHostIP[1]) == 254) \
    1548                   or (ord(abHostIP[0]) == 192 and ord(abHostIP[1]) == 168 and ord(abHostIP[2]) == 56):
     1547                if sys.version_info[0] < 3:
     1548                    abHostIP = (ord(abHostIP[0]), ord(abHostIP[1]), ord(abHostIP[2]), ord(abHostIP[3]));
     1549                if   abHostIP[0] == 127 \
     1550                  or (abHostIP[0] == 169 and abHostIP[1] == 254) \
     1551                  or (abHostIP[0] == 192 and abHostIP[1] == 168 and abHostIP[2] == 56):
    15491552                    reporter.log('warning: host IP for "%s" is %s, most likely not unique.' % (sHostName, sHostIP))
    15501553            except:
     
    15521555                return False
    15531556            sDefaultMac = '%02X%02X%02X%02X%02X%02X' \
    1554                 % (0x02, ord(abHostIP[0]), ord(abHostIP[1]), ord(abHostIP[2]), ord(abHostIP[3]), iNic)
     1557                % (0x02, abHostIP[0], abHostIP[1], abHostIP[2], abHostIP[3], iNic)
    15551558            sMacAddr = sDefaultMac[0:(12 - cchMacAddr)] + sMacAddr
    15561559
     
    28332836
    28342837        oTxsSession = txsclient.tryOpenTcpSession(cMsTimeout, sHostname, fReversedSetup = fReversed,
    2835                                                   cMsIdleFudge = cMsTimeout / 2);
     2838                                                  cMsIdleFudge = cMsTimeout // 2);
    28362839        if oTxsSession is None:
    28372840            return False;
  • trunk/src/VBox/ValidationKit/testdriver/winbase.py

    r69578 r70521  
    3232
    3333# Standard Python imports.
     34import ctypes;
    3435import os;
    35 import ctypes;
     36import sys;
    3637
    3738# Windows specific imports.
     
    4748from testdriver import reporter;
    4849
     50# Python 3 hacks:
     51if sys.version_info[0] >= 3:
     52    long = int;             # pylint: disable=redefined-builtin,invalid-name
    4953
    5054
     
    215219    except:
    216220        reporter.logXcpt();
    217     reporter.log2('processCreate -> %#x, hProcess=%#x' % (uPid, hProcess,));
     221    reporter.log2('processCreate -> %#x, hProcess=%s %#x' % (uPid, hProcess, hProcess.handle,));
    218222    return (uPid, hProcess, uTid);
    219223
     
    225229        dwWait = win32event.WaitForSingleObject(hProcess, 0);                                       # pylint: disable=no-member
    226230    except:
    227         reporter.logXcpt('hProcess=%s %#x' % (hProcess, hProcess,));
     231        reporter.logXcpt('hProcess=%s %#x' % (hProcess, hProcess.handle,));
    228232        return True;
    229233    return dwWait != win32con.WAIT_TIMEOUT; #0x102; #
     
    237241        win32api.TerminateProcess(hProcess, 0x40010004); # DBG_TERMINATE_PROCESS                    # pylint: disable=no-member
    238242    except:
    239         reporter.logXcpt('hProcess=%s %#x' % (hProcess, hProcess,));
     243        reporter.logXcpt('hProcess=%s %#x' % (hProcess, hProcess.handle,));
    240244        return False;
    241245    return True;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette