VirtualBox

Ignore:
Timestamp:
Jan 21, 2018 4:18:58 PM (7 years ago)
Author:
vboxsync
Message:

ValidationKit: Python 3 and pylint 1.8.1 adjustments/fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py

    r69111 r70660  
    1212
    1313"""
     14
     15from __future__ import print_function;
    1416
    1517__copyright__ = \
     
    4143import os;
    4244import hashlib;
    43 import StringIO;
    44 from optparse import OptionParser;
    45 from PIL import Image;                  # pylint: disable=import-error
     45if sys.version_info[0] >= 3:
     46    from io       import StringIO as StringIO;      # pylint: disable=import-error,no-name-in-module
     47else:
     48    from StringIO import StringIO as StringIO;      # pylint: disable=import-error,no-name-in-module
     49from optparse import OptionParser;                  # pylint: disable=deprecated-module
     50from PIL import Image;                              # pylint: disable=import-error
    4651
    4752# Add Test Manager's modules path
     
    6065from testmanager.core.testresultfailures    import TestResultFailureLogic, TestResultFailureData;
    6166from testmanager.core.useraccount           import UserAccountLogic;
     67
     68# Python 3 hacks:
     69if sys.version_info[0] >= 3:
     70    xrange = range; # pylint: disable=redefined-builtin,invalid-name
    6271
    6372
     
    224233        else:
    225234            try:
    226                 oImage = Image.open(StringIO.StringIO(abImageFile));
     235                oImage = Image.open(StringIO(abImageFile));
    227236            except Exception as oXcpt:
    228237                self.oSheriff.vprint(u'Error opening the "%s" image bytes using PIL.Image.open: %s' % (oFile.sFile, oXcpt,))
     
    302311        Returns 1 (for exit code usage.)
    303312        """
    304         print 'error: %s' % (sText,);
     313        print('error: %s' % (sText,));
    305314        if self.oLogFile is not None:
    306315            self.oLogFile.write((u'error: %s\n' % (sText,)).encode('utf-8'));
     
    313322        if self.oConfig.fDebug:
    314323            if not self.oConfig.fQuiet:
    315                 print 'debug: %s' % (sText, );
     324                print('debug: %s' % (sText, ));
    316325            if self.oLogFile is not None:
    317326                self.oLogFile.write((u'debug: %s\n' % (sText,)).encode('utf-8'));
     
    323332        """
    324333        if not self.oConfig.fQuiet:
    325             print 'info: %s' % (sText,);
     334            print('info: %s' % (sText,));
    326335        if self.oLogFile is not None:
    327336            self.oLogFile.write((u'info: %s\n' % (sText,)).encode('utf-8'));
Note: See TracChangeset for help on using the changeset viewer.

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