]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix python 3 pep8 errors for print
authorJohn Griffith <john.griffith@solidfire.com>
Mon, 12 Aug 2013 21:50:53 +0000 (21:50 +0000)
committerJohn Griffith <john.griffith@solidfire.com>
Wed, 21 Aug 2013 22:59:22 +0000 (16:59 -0600)
The new auto-pulled requirements files exposed
python 3 compat issues in a number of modules.
We added these to tox.ini ignore temporarily,
this change updates the print routines in bin/cinder
and removes the debug cruft that was in the unit tests.

Will update requirements and test-requirements
appropriately in a follow up patch.

Change-Id: I76ea24f4dc1f61c4f8a1d202b0554c90daf2c9cc

17 files changed:
bin/cinder-manage
bin/cinder-rootwrap
bin/cinder-volume-usage-audit
cinder/tests/api/contrib/test_types_extra_specs.py
cinder/tests/api/v1/test_snapshots.py
cinder/tests/api/v1/test_volumes.py
cinder/tests/api/v2/test_snapshots.py
cinder/tests/api/v2/test_volumes.py
cinder/tests/fake_driver.py
cinder/tests/image/test_glance.py
cinder/tests/test_test.py
cinder/wsgi.py
setup.py
tools/conf/extract_opts.py
tools/install_venv.py
tools/lintstack.py
tox.ini

index 6732c04d5254b3e4d6979d90a3b62e18398da680..3c05d779fadfda92555e64e051c0eed9a9bc6b44 100755 (executable)
@@ -54,6 +54,8 @@
   CLI interface for cinder management.
 """
 
+from __future__ import print_function
+
 
 import os
 import sys
@@ -179,10 +181,10 @@ class ShellCommands(object):
 
 
 def _db_error(caught_exception):
-    print caught_exception
-    print _("The above error may show that the database has not "
+    print('%s' % caught_exception)
+    print(_("The above error may show that the database has not "
             "been created.\nPlease create a database using "
-            "'cinder-manage db sync' before running this command.")
+            "'cinder-manage db sync' before running this command."))
     exit(1)
 
 
@@ -195,8 +197,8 @@ class HostCommands(object):
         """Show a list of all physical hosts. Filter by zone.
         args: [zone]
         """
-        print "%-25s\t%-15s" % (_('host'),
-                                _('zone'))
+        print("%-25s\t%-15s" % (_('host'),
+                                _('zone')))
         ctxt = context.get_admin_context()
         services = db.service_get_all(ctxt)
         if zone:
@@ -207,7 +209,7 @@ class HostCommands(object):
                 hosts.append(srv)
 
         for h in hosts:
-            print "%-25s\t%-15s" % (h['host'], h['availability_zone'])
+            print("%-25s\t%-15s" % (h['host'], h['availability_zone']))
 
 
 class DbCommands(object):
@@ -224,7 +226,7 @@ class DbCommands(object):
 
     def version(self):
         """Print the current database version."""
-        print migration.db_version()
+        print(migration.db_version())
 
 
 class VersionCommands(object):
@@ -254,14 +256,14 @@ class VolumeCommands(object):
         host = volume['host']
 
         if not host:
-            print "Volume not yet assigned to host."
-            print "Deleting volume from database and skipping rpc."
+            print("Volume not yet assigned to host.")
+            print("Deleting volume from database and skipping rpc.")
             db.volume_destroy(ctxt, param2id(volume_id))
             return
 
         if volume['status'] == 'in-use':
-            print "Volume is in-use."
-            print "Detach volume from instance and then try again."
+            print("Volume is in-use.")
+            print("Detach volume from instance and then try again.")
             return
 
         rpc.cast(ctxt,
@@ -279,7 +281,7 @@ class VolumeCommands(object):
         ctxt = context.get_admin_context()
         volume = db.volume_get(ctxt, param2id(volume_id))
         if not volume['instance_id']:
-            print "volume is not attached to an instance"
+            print("volume is not attached to an instance")
             return
         instance = db.instance_get(ctxt, volume['instance_id'])
         host = instance['host']
@@ -309,10 +311,10 @@ class ConfigCommands(object):
         """
         param = param and param.strip()
         if param:
-            print '%s = %s' % (param, CONF.get(param))
+            print('%s = %s' % (param, CONF.get(param)))
         else:
             for key, value in CONF.iteritems():
-                print '%s = %s' % (key, value)
+                print('%s = %s' % (key, value))
 
 
 class GetLogCommands(object):
@@ -332,11 +334,11 @@ class GetLogCommands(object):
                     if line.find(" ERROR ") > 0:
                         error_found += 1
                         if print_name == 0:
-                            print log_file + ":-"
+                            print(log_file + ":-")
                             print_name = 1
-                        print "Line %d : %s" % (len(lines) - index, line)
+                        print("Line %d : %s" % (len(lines) - index, line))
         if error_found == 0:
-            print "No errors in logfiles!"
+            print("No errors in logfiles!")
 
     @args('num_entries', nargs='?', type=int, default=10,
           help='Number of entries to list (default: %(default)d)')
@@ -350,20 +352,20 @@ class GetLogCommands(object):
         elif os.path.exists('/var/log/messages'):
             log_file = '/var/log/messages'
         else:
-            print "Unable to find system log file!"
+            print("Unable to find system log file!")
             sys.exit(1)
         lines = [line.strip() for line in open(log_file, "r")]
         lines.reverse()
-        print "Last %s cinder syslog entries:-" % (entries)
+        print("Last %s cinder syslog entries:-" % (entries))
         for line in lines:
             if line.find("cinder") > 0:
                 count += 1
-                print "%s" % (line)
+                print("%s" % (line))
             if count == entries:
                 break
 
         if count == 0:
-            print "No cinder entries in syslog!"
+            print("No cinder entries in syslog!")
 
 
 class BackupCommands(object):
@@ -377,7 +379,7 @@ class BackupCommands(object):
         backups = db.backup_get_all(ctxt)
 
         hdr = "%-32s\t%-32s\t%-32s\t%-24s\t%-24s\t%-12s\t%-12s\t%-12s\t%-12s"
-        print hdr % (_('ID'),
+        print(hdr % (_('ID'),
                      _('User ID'),
                      _('Project ID'),
                      _('Host'),
@@ -385,14 +387,14 @@ class BackupCommands(object):
                      _('Container'),
                      _('Status'),
                      _('Size'),
-                     _('Object Count'))
+                     _('Object Count')))
 
         res = "%-32s\t%-32s\t%-32s\t%-24s\t%-24s\t%-12s\t%-12s\t%-12d\t%-12d"
         for backup in backups:
             object_count = 0
             if backup['object_count'] is not None:
                 object_count = backup['object_count']
-            print res % (backup['id'],
+            print(res % (backup['id'],
                          backup['user_id'],
                          backup['project_id'],
                          backup['host'],
@@ -400,7 +402,7 @@ class BackupCommands(object):
                          backup['container'],
                          backup['status'],
                          backup['size'],
-                         object_count)
+                         object_count))
 
 
 class ServiceCommands(object):
@@ -410,21 +412,21 @@ class ServiceCommands(object):
         ctxt = context.get_admin_context()
         services = db.service_get_all(ctxt)
         print_format = "%-16s %-36s %-16s %-10s %-5s %-10s"
-        print print_format % (_('Binary'),
+        print(print_format % (_('Binary'),
                               _('Host'),
                               _('Zone'),
                               _('Status'),
                               _('State'),
-                              _('Updated At'))
+                              _('Updated At')))
         for svc in services:
             alive = utils.service_is_up(svc)
             art = ":-)" if alive else "XXX"
             status = 'enabled'
             if svc['disabled']:
                 status = 'disabled'
-            print print_format % (svc['binary'], svc['host'].partition('.')[0],
+            print(print_format % (svc['binary'], svc['host'].partition('.')[0],
                                   svc['availability_zone'], status, art,
-                                  svc['updated_at'])
+                                  svc['updated_at']))
 
 
 CATEGORIES = {
@@ -509,10 +511,10 @@ def main():
     if len(sys.argv) < 2:
         print(_("\nOpenStack Cinder version: %(version)s\n") %
               {'version': version.version_string()})
-        print script_name + " category action [<args>]"
-        print _("Available categories:")
+        print(script_name + " category action [<args>]")
+        print (_("Available categories:"))
         for category in CATEGORIES:
-            print "\t%s" % category
+            print("\t%s" % category)
         sys.exit(2)
 
     try:
@@ -523,13 +525,13 @@ def main():
         cfgfile = CONF.config_file[-1] if CONF.config_file else None
         if cfgfile and not os.access(cfgfile, os.R_OK):
             st = os.stat(cfgfile)
-            print _("Could not read %s. Re-running with sudo") % cfgfile
+            print(_("Could not read %s. Re-running with sudo") % cfgfile)
             try:
                 os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv)
             except Exception:
-                print _('sudo failed, continuing as if nothing happened')
+                print(_('sudo failed, continuing as if nothing happened'))
 
-        print _('Please re-run cinder-manage as root.')
+        print(_('Please re-run cinder-manage as root.'))
         sys.exit(2)
 
     fn = CONF.category.action_fn
index cb2a92f5eaf2dc0b2703f38e94cf3f98b3b7a695..456044824f45df0b2656f09fd4ce7c929b0103a5 100755 (executable)
@@ -33,6 +33,8 @@
    they are needed, to avoid allowing more than is necessary.
 """
 
+from __future__ import print_function
+
 import ConfigParser
 import logging
 import os
@@ -55,7 +57,7 @@ def _subprocess_setup():
 
 
 def _exit_error(execname, message, errorcode, log=True):
-    print "%s: %s" % (execname, message)
+    print("%s: %s" % (execname, message))
     if log:
         logging.error(message)
     sys.exit(errorcode)
index 8df06c6c0dcb0a0d326b8d4ae78401c7039c09a5..2467e8365b539cc46d9bd16c183b21e68730adb2 100755 (executable)
@@ -34,6 +34,7 @@
         Jan 1 through Dec 31 of the previous year.
 """
 
+from __future__ import print_function
 
 import os
 import sys
@@ -71,9 +72,9 @@ if __name__ == '__main__':
          version=version.version_string())
     logging.setup("cinder")
     begin, end = utils.last_completed_audit_period()
-    print _("Starting volume usage audit")
+    print(_("Starting volume usage audit"))
     msg = _("Creating usages for %(begin_period)s until %(end_period)s")
-    print (msg % {"begin_period": str(begin), "end_period": str(end)})
+    print(msg % {"begin_period": str(begin), "end_period": str(end)})
 
     extra_info = {
         'audit_period_beginning': str(begin),
@@ -83,18 +84,18 @@ if __name__ == '__main__':
     volumes = db.volume_get_active_by_window(admin_context,
                                              begin,
                                              end)
-    print _("Found %d volumes") % len(volumes)
+    print(_("Found %d volumes") % len(volumes))
     for volume_ref in volumes:
         try:
             cinder.volume.utils.notify_usage_exists(admin_context,
                                                     volume_ref)
         except Exception as e:
-            print traceback.format_exc(e)
+            print(traceback.format_exc(e))
 
     snapshots = db.snapshot_get_active_by_window(admin_context,
                                                  begin,
                                                  end)
-    print _("Found %d snapshots") % len(snapshots)
+    print(_("Found %d snapshots") % len(snapshots))
     for snapshot_ref in snapshots:
         try:
             cinder.volume.utils.notify_about_snapshot_usage(admin_context,
@@ -102,6 +103,6 @@ if __name__ == '__main__':
                                                             'exists',
                                                             extra_info)
         except Exception as e:
-            print traceback.fromat_exc(e)
+            print(traceback.fromat_exc(e))
 
-    print _("Volume usage audit completed")
+    print(_("Volume usage audit completed"))
index e28a0a9535e2ca46d9786b4de9c1548209c10d07..608d837dd1780ac40bac63748ddafce25f7e3152 100644 (file)
@@ -218,7 +218,6 @@ class VolumeTypeExtraSpecsSerializerTest(test.TestCase):
         extra_specs = stub_volume_type_extra_specs()
         text = serializer.serialize(dict(extra_specs=extra_specs))
 
-        print text
         tree = etree.fromstring(text)
 
         self.assertEqual('extra_specs', tree.tag)
@@ -236,7 +235,6 @@ class VolumeTypeExtraSpecsSerializerTest(test.TestCase):
         exemplar = dict(key1='value1')
         text = serializer.serialize(exemplar)
 
-        print text
         tree = etree.fromstring(text)
 
         self.assertEqual('key1', tree.tag)
index 10aa914d03552afae2ca4c64971371262f74cf72..9f56ad8cd0bbfd492817315d70289713cb09e05f 100644 (file)
@@ -380,7 +380,6 @@ class SnapshotSerializerTest(test.TestCase):
             volume_id='vol_id', )
         text = serializer.serialize(dict(snapshot=raw_snapshot))
 
-        print text
         tree = etree.fromstring(text)
 
         self._verify_snapshot(raw_snapshot, tree)
@@ -403,7 +402,6 @@ class SnapshotSerializerTest(test.TestCase):
                               volume_id='vol2_id', )]
         text = serializer.serialize(dict(snapshots=raw_snapshots))
 
-        print text
         tree = etree.fromstring(text)
 
         self.assertEqual('snapshots', tree.tag)
index 7870186627fb1cbdfb232b0bd7327a0dfa5953d3..87e83416234bcba659920277919248607ef58f59 100644 (file)
@@ -626,7 +626,6 @@ class VolumeSerializerTest(test.TestCase):
             self.assertEqual(str(vol[attr]), tree.get(attr))
 
         for child in tree:
-            print child.tag
             self.assertTrue(child.tag in (NS + 'attachments', NS + 'metadata'))
             if child.tag == 'attachments':
                 self.assertEqual(1, len(child))
@@ -663,7 +662,6 @@ class VolumeSerializerTest(test.TestCase):
                           baz='quux', ), )
         text = serializer.serialize(dict(volume=raw_volume))
 
-        print text
         tree = etree.fromstring(text)
 
         self._verify_volume(raw_volume, tree)
@@ -706,7 +704,6 @@ class VolumeSerializerTest(test.TestCase):
                                           bar='vol2_bar', ), )]
         text = serializer.serialize(dict(volumes=raw_volumes))
 
-        print text
         tree = etree.fromstring(text)
 
         self.assertEqual(NS + 'volumes', tree.tag)
index 2f96f0415a4ac458b07b0a94629c27673282438e..222842f353602f5211c3e238d59c852dd0e97c5e 100644 (file)
@@ -411,7 +411,6 @@ class SnapshotSerializerTest(test.TestCase):
         )
         text = serializer.serialize(dict(snapshot=raw_snapshot))
 
-        print text
         tree = etree.fromstring(text)
 
         self._verify_snapshot(raw_snapshot, tree)
@@ -440,7 +439,6 @@ class SnapshotSerializerTest(test.TestCase):
         ]
         text = serializer.serialize(dict(snapshots=raw_snapshots))
 
-        print text
         tree = etree.fromstring(text)
 
         self.assertEqual('snapshots', tree.tag)
index 842f4fb5bd632ece6799ce2c8d33af9d1be8a11a..ed89d385346bfffacd135f9e1148089b73ebc959 100644 (file)
@@ -826,7 +826,6 @@ class VolumeSerializerTest(test.TestCase):
             self.assertEqual(str(vol[attr]), tree.get(attr))
 
         for child in tree:
-            print child.tag
             self.assertTrue(child.tag in (NS + 'attachments', NS + 'metadata'))
             if child.tag == 'attachments':
                 self.assertEqual(1, len(child))
@@ -870,7 +869,6 @@ class VolumeSerializerTest(test.TestCase):
         )
         text = serializer.serialize(dict(volume=raw_volume))
 
-        print text
         tree = etree.fromstring(text)
 
         self._verify_volume(raw_volume, tree)
@@ -920,7 +918,6 @@ class VolumeSerializerTest(test.TestCase):
                               bar='vol2_bar', ), )]
         text = serializer.serialize(dict(volumes=raw_volumes))
 
-        print text
         tree = etree.fromstring(text)
 
         self.assertEqual(NS + 'volumes', tree.tag)
index 6f352a7c7739a152efae3516a025b95b61a85759..f64ad8a2f47fc2aba73f35085dba52be46be012f 100644 (file)
@@ -82,7 +82,7 @@ class LoggingVolumeDriver(driver.VolumeDriver):
         self.log_action('clear_volume', volume)
 
     def local_path(self, volume):
-        print "local_path not implemented"
+        LOG.error(_("local_path not implemented"))
         raise NotImplementedError()
 
     def ensure_export(self, context, volume):
index 9248d0f312326dd978a2320f7117dc37f25d157f..3f955cfc9f57ce44148f9895627a0f6945d49dd4 100644 (file)
@@ -335,7 +335,6 @@ class TestGlanceImageService(test.TestCase):
     def test_update(self):
         fixture = self._make_fixture(name='test image')
         image = self.service.create(self.context, fixture)
-        print image
         image_id = image['id']
         fixture['name'] = 'new image name'
         self.service.update(self.context, image_id, fixture)
index fe62d9abd1206777f28a3822606d8a0b863855f2..be17f391679e205c12df0d7c13f00acf365c1864 100644 (file)
@@ -30,8 +30,6 @@ class IsolationTestCase(test.TestCase):
 
     """
     def test_service_isolation(self):
-        import os
-        print os.path.abspath(".")
         self.start_service('volume')
 
     def test_rpc_consumer_isolation(self):
index 098c1d3a6753898a34cebc907348128ad469de38..028aa54cfc77a698511535f94d4b157890d6934b 100644 (file)
@@ -19,6 +19,7 @@
 
 """Utility methods for working with WSGI servers."""
 
+from __future__ import print_function
 
 import errno
 import os
@@ -382,16 +383,16 @@ class Debug(Middleware):
 
     @webob.dec.wsgify(RequestClass=Request)
     def __call__(self, req):
-        print ('*' * 40) + ' REQUEST ENVIRON'
+        print(('*' * 40) + ' REQUEST ENVIRON')
         for key, value in req.environ.items():
-            print key, '=', value
-        print
+            print(key, '=', value)
+        print()
         resp = req.get_response(self.application)
 
-        print ('*' * 40) + ' RESPONSE HEADERS'
+        print(('*' * 40) + ' RESPONSE HEADERS')
         for (key, value) in resp.headers.iteritems():
-            print key, '=', value
-        print
+            print(key, '=', value)
+        print()
 
         resp.app_iter = self.print_generator(resp.app_iter)
 
@@ -400,12 +401,12 @@ class Debug(Middleware):
     @staticmethod
     def print_generator(app_iter):
         """Iterator that prints the contents of a wrapper string."""
-        print ('*' * 40) + ' BODY'
+        print(('*' * 40) + ' BODY')
         for part in app_iter:
             sys.stdout.write(part)
             sys.stdout.flush()
             yield part
-        print
+        print()
 
 
 class Router(object):
index b3e85a7150c3bd1d740102d143577e76498f1ac7..2a0786a8b28e67a7be5b8c4834529bcc17a6ae33 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -14,8 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
 import setuptools
 
 setuptools.setup(
-    setup_requires=['d2to1>=0.2.10,<0.3', 'pbr>=0.5.10,<0.6'],
-    d2to1=True)
+    setup_requires=['pbr>=0.5.21,<1.0'],
+    pbr=True)
index 2f32cff5d85b7ed4ff8732b687699fc67d66e0c2..eef2ab0c94aac5f48b4623c3201a4173623d748c 100644 (file)
@@ -18,6 +18,8 @@
 
 """Extracts OpenStack config option info from module(s)."""
 
+from __future__ import print_function
+
 import __builtin__
 setattr(__builtin__, '_', lambda x: x)
 import os
@@ -49,8 +51,8 @@ WORDWRAP_WIDTH = 60
 
 
 def main(srcfiles):
-    print '\n'.join(['#' * 20, '# cinder.conf sample #', '#' * 20,
-                     '', '[DEFAULT]', ''])
+    print('\n'.join(['#' * 20, '# cinder.conf sample #', '#' * 20,
+                     '', '[DEFAULT]', '']))
     _list_opts(cfg.ConfigOpts,
                cfg.__name__ + ':' + cfg.ConfigOpts.__name__)
     mods_by_pkg = dict()
@@ -70,7 +72,7 @@ def main(srcfiles):
         mods.sort()
         for mod_str in mods:
             _print_module(mod_str)
-    print "# Total option count: %d" % OPTION_COUNT
+    print("# Total option count: %d" % OPTION_COUNT)
 
 
 def _print_module(mod_str):
@@ -99,13 +101,13 @@ def _list_opts(obj, name):
         return
     global OPTION_COUNT
     OPTION_COUNT += len(opts)
-    print '#'
-    print '# Options defined in %s' % name
-    print '#'
-    print
+    print('#')
+    print('# Options defined in %s' % name)
+    print('#')
+    print()
     for opt in opts:
         _print_opt(opt)
-    print
+    print()
 
 
 def _get_my_ip():
@@ -157,31 +159,31 @@ def _print_opt(opt):
         sys.stderr.write("%s\n" % str(err))
         sys.exit(1)
     opt_help += ' (' + OPT_TYPES[opt_type] + ')'
-    print '#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH))
+    print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH)))
     try:
         if opt_default is None:
-            print '#%s=<None>' % opt_name
+            print('#%s=<None>' % opt_name)
         elif opt_type == STROPT:
             assert(isinstance(opt_default, basestring))
-            print '#%s=%s' % (opt_name, _sanitize_default(opt_default))
+            print('#%s=%s' % (opt_name, _sanitize_default(opt_default)))
         elif opt_type == BOOLOPT:
             assert(isinstance(opt_default, bool))
-            print '#%s=%s' % (opt_name, str(opt_default).lower())
+            print('#%s=%s' % (opt_name, str(opt_default).lower()))
         elif opt_type == INTOPT:
             assert(isinstance(opt_default, int) and
                    not isinstance(opt_default, bool))
-            print '#%s=%s' % (opt_name, opt_default)
+            print('#%s=%s' % (opt_name, opt_default))
         elif opt_type == FLOATOPT:
             assert(isinstance(opt_default, float))
-            print '#%s=%s' % (opt_name, opt_default)
+            print('#%s=%s' % (opt_name, opt_default))
         elif opt_type == LISTOPT:
             assert(isinstance(opt_default, list))
-            print '#%s=%s' % (opt_name, ','.join(opt_default))
+            print('#%s=%s' % (opt_name, ','.join(opt_default)))
         elif opt_type == MULTISTROPT:
             assert(isinstance(opt_default, list))
             for default in opt_default:
-                print '#%s=%s' % (opt_name, default)
-        print
+                print('#%s=%s' % (opt_name, default))
+        print()
     except Exception:
         sys.stderr.write('Error in option "%s"\n' % opt_name)
         sys.exit(1)
@@ -189,6 +191,6 @@ def _print_opt(opt):
 
 if __name__ == '__main__':
     if len(sys.argv) < 2:
-        print "usage: python %s [srcfile]...\n" % sys.argv[0]
+        print("usage: python %s [srcfile]...\n" % sys.argv[0])
         sys.exit(0)
     main(sys.argv[1:])
index 1a4ae4a0441efeb8bd9ea65d870c113859e68796..884b2a9e953e113ef7b2636df268c57a31bcb164 100644 (file)
@@ -21,6 +21,8 @@
 
 """Installation script for Cinder's development virtualenv."""
 
+from __future__ import print_function
+
 import optparse
 import os
 import subprocess
@@ -48,7 +50,7 @@ def print_help():
 
     Also, make test will automatically use the virtualenv.
     """
-    print help
+    print(help)
 
 
 def main(argv):
index 4130d105f67c7b6eb6547e019c3628118fcad995..367078b4cee65767b4bf3c90e2a16e489ebe6b6f 100755 (executable)
@@ -18,6 +18,8 @@
 
 """pylint error checking."""
 
+from __future__ import print_function
+
 import cStringIO as StringIO
 import json
 import re
@@ -112,9 +114,9 @@ class ErrorKeys(object):
 
     @classmethod
     def print_json(cls, errors, output=sys.stdout):
-        print >>output, "# automatically generated by tools/lintstack.py"
+        print("# automatically generated by tools/lintstack.py", file=output)
         for i in sorted(errors.keys()):
-            print >>output, json.dumps(i)
+            print(json.dumps(i), file=output)
 
     @classmethod
     def from_file(cls, filename):
@@ -137,7 +139,7 @@ def run_pylint():
 
 
 def generate_error_keys(msg=None):
-    print "Generating", KNOWN_PYLINT_EXCEPTIONS_FILE
+    print("Generating", KNOWN_PYLINT_EXCEPTIONS_FILE)
     if msg is None:
         msg = run_pylint()
     errors = LintOutput.from_msg_to_dict(msg)
@@ -146,41 +148,41 @@ def generate_error_keys(msg=None):
 
 
 def validate(newmsg=None):
-    print "Loading", KNOWN_PYLINT_EXCEPTIONS_FILE
+    print("Loading", KNOWN_PYLINT_EXCEPTIONS_FILE)
     known = ErrorKeys.from_file(KNOWN_PYLINT_EXCEPTIONS_FILE)
     if newmsg is None:
-        print "Running pylint. Be patient..."
+        print("Running pylint. Be patient...")
         newmsg = run_pylint()
     errors = LintOutput.from_msg_to_dict(newmsg)
 
-    print "Unique errors reported by pylint: was %d, now %d." \
-          % (len(known), len(errors))
+    print("Unique errors reported by pylint: was %d, now %d."
+          % (len(known), len(errors)))
     passed = True
     for err_key, err_list in errors.items():
         for err in err_list:
             if err_key not in known:
-                print err.lintoutput
-                print
+                print(err.lintoutput)
+                print()
                 passed = False
     if passed:
-        print "Congrats! pylint check passed."
+        print("Congrats! pylint check passed.")
         redundant = known - set(errors.keys())
         if redundant:
-            print "Extra credit: some known pylint exceptions disappeared."
+            print("Extra credit: some known pylint exceptions disappeared.")
             for i in sorted(redundant):
-                print json.dumps(i)
-            print "Consider regenerating the exception file if you will."
+                print(json.dumps(i))
+            print("Consider regenerating the exception file if you will.")
     else:
-        print ("Please fix the errors above. If you believe they are false "
-               "positives, run 'tools/lintstack.py generate' to overwrite.")
+        print("Please fix the errors above. If you believe they are false "
+              "positives, run 'tools/lintstack.py generate' to overwrite.")
         sys.exit(1)
 
 
 def usage():
-    print """Usage: tools/lintstack.py [generate|validate]
+    print("""Usage: tools/lintstack.py [generate|validate]
     To generate pylint_exceptions file: tools/lintstack.py generate
     To validate the current commit: tools/lintstack.py
-    """
+    """)
 
 
 def main():
diff --git a/tox.ini b/tox.ini
index 7c614b982735bb67f17016fdbd2c1f7efe1fe621..cac92ed0cb516885c376263e70ed8dd8671ace97 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -43,6 +43,6 @@ commands =
 commands = {posargs}
 
 [flake8]
-ignore = E711,E712,F401,F403,F811,F841,H233,H302,H303,H304,H402,H404
+ignore = E711,E712,F401,F403,F811,F841,H302,H303,H304,H402,H404
 builtins = _
 exclude = .git,.venv,.tox,dist,doc,common,*egg,build