Enable hacking H233 rule

H233: Python 3.x incompatible use of print operator

Change-Id: I7acd664b888c0ba049524e5f519c72038d79495b
This commit is contained in:
ZhiQiang Fan
2014-01-23 10:12:19 +08:00
parent d5558265cc
commit bbcbc5a69c
12 changed files with 79 additions and 52 deletions

View File

@@ -14,6 +14,8 @@
# under the License.
#
from __future__ import print_function
import argparse
import logging
import re
@@ -421,7 +423,8 @@ class CreateCommand(NeutronCommand, show.ShowOne):
# {u'network': {u'id': u'e9424a76-6db4-4c93-97b6-ec311cd51f19'}}
info = self.resource in data and data[self.resource] or None
if info:
print >>self.app.stdout, _('Created a new %s:') % self.resource
print(_('Created a new %s:') % self.resource,
file=self.app.stdout)
else:
info = {'': ''}
return zip(*sorted(info.iteritems()))
@@ -468,9 +471,9 @@ class UpdateCommand(NeutronCommand):
obj_updator = getattr(neutron_client,
"update_%s" % self.resource)
obj_updator(_id, body)
print >>self.app.stdout, (
_('Updated %(resource)s: %(id)s') %
{'id': parsed_args.id, 'resource': self.resource})
print((_('Updated %(resource)s: %(id)s') %
{'id': parsed_args.id, 'resource': self.resource}),
file=self.app.stdout)
return
@@ -507,9 +510,10 @@ class DeleteCommand(NeutronCommand):
else:
_id = parsed_args.id
obj_deleter(_id)
print >>self.app.stdout, (_('Deleted %(resource)s: %(id)s')
% {'id': parsed_args.id,
'resource': self.resource})
print((_('Deleted %(resource)s: %(id)s')
% {'id': parsed_args.id,
'resource': self.resource}),
file=self.app.stdout)
return

View File

@@ -14,12 +14,16 @@
# under the License.
#
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import network
from neutronclient.neutron.v2_0 import router
from neutronclient.openstack.common.gettextutils import _
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
@@ -46,8 +50,8 @@ class AddNetworkToDhcpAgent(neutronV20.NeutronCommand):
neutron_client, 'network', parsed_args.network)
neutron_client.add_network_to_dhcp_agent(parsed_args.dhcp_agent,
{'network_id': _net_id})
print >>self.app.stdout, (
_('Added network %s to DHCP agent') % parsed_args.network)
print(_('Added network %s to DHCP agent') % parsed_args.network,
file=self.app.stdout)
class RemoveNetworkFromDhcpAgent(neutronV20.NeutronCommand):
@@ -72,8 +76,8 @@ class RemoveNetworkFromDhcpAgent(neutronV20.NeutronCommand):
neutron_client, 'network', parsed_args.network)
neutron_client.remove_network_from_dhcp_agent(
parsed_args.dhcp_agent, _net_id)
print >>self.app.stdout, (
_('Removed network %s to DHCP agent') % parsed_args.network)
print(_('Removed network %s to DHCP agent') % parsed_args.network,
file=self.app.stdout)
class ListNetworksOnDhcpAgent(network.ListNetwork):
@@ -149,8 +153,8 @@ class AddRouterToL3Agent(neutronV20.NeutronCommand):
neutron_client, 'router', parsed_args.router)
neutron_client.add_router_to_l3_agent(parsed_args.l3_agent,
{'router_id': _id})
print >>self.app.stdout, (
_('Added router %s to L3 agent') % parsed_args.router)
print(_('Added router %s to L3 agent') % parsed_args.router,
file=self.app.stdout)
class RemoveRouterFromL3Agent(neutronV20.NeutronCommand):
@@ -176,8 +180,8 @@ class RemoveRouterFromL3Agent(neutronV20.NeutronCommand):
neutron_client, 'router', parsed_args.router)
neutron_client.remove_router_from_l3_agent(
parsed_args.l3_agent, _id)
print >>self.app.stdout, (
_('Removed Router %s to L3 agent') % parsed_args.router)
print(_('Removed Router %s to L3 agent') % parsed_args.router,
file=self.app.stdout)
class ListRoutersOnL3Agent(neutronV20.ListCommand):

View File

@@ -14,6 +14,8 @@
# under the License.
#
from __future__ import print_function
import argparse
import logging
@@ -122,8 +124,8 @@ class AssociateFloatingIP(neutronV20.NeutronCommand):
update_dict['fixed_ip_address'] = parsed_args.fixed_ip_address
neutron_client.update_floatingip(parsed_args.floatingip_id,
{'floatingip': update_dict})
print >>self.app.stdout, (
_('Associated floatingip %s') % parsed_args.floatingip_id)
print(_('Associated floatingip %s') % parsed_args.floatingip_id,
file=self.app.stdout)
class DisassociateFloatingIP(neutronV20.NeutronCommand):
@@ -147,5 +149,5 @@ class DisassociateFloatingIP(neutronV20.NeutronCommand):
neutron_client.format = parsed_args.request_format
neutron_client.update_floatingip(parsed_args.floatingip_id,
{'floatingip': {'port_id': None}})
print >>self.app.stdout, (
_('Disassociated floatingip %s') % parsed_args.floatingip_id)
print(_('Disassociated floatingip %s') % parsed_args.floatingip_id,
file=self.app.stdout)

View File

@@ -16,6 +16,8 @@
# @author: KC Wang, Big Switch Networks
#
from __future__ import print_function
import argparse
import logging
import string
@@ -174,9 +176,8 @@ class FirewallPolicyInsertRule(neutronv20.UpdateCommand):
self.resource,
parsed_args.id)
self.call_api(neutron_client, _id, body)
print >>self.app.stdout, (
_('Inserted firewall rule in firewall policy %(id)s') %
{'id': parsed_args.id})
print((_('Inserted firewall rule in firewall policy %(id)s') %
{'id': parsed_args.id}), file=self.app.stdout)
class FirewallPolicyRemoveRule(neutronv20.UpdateCommand):
@@ -216,6 +217,5 @@ class FirewallPolicyRemoveRule(neutronv20.UpdateCommand):
self.resource,
parsed_args.id)
self.call_api(neutron_client, _id, body)
print >>self.app.stdout, (
_('Removed firewall rule from firewall policy %(id)s') %
{'id': parsed_args.id})
print((_('Removed firewall rule from firewall policy %(id)s') %
{'id': parsed_args.id}), file=self.app.stdout)

View File

@@ -16,6 +16,8 @@
# @author: Ilya Shakhat, Mirantis Inc.
#
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
@@ -141,8 +143,9 @@ class AssociateHealthMonitor(neutronV20.NeutronCommand):
pool_id = neutronV20.find_resourceid_by_name_or_id(
neutron_client, 'pool', parsed_args.pool_id)
neutron_client.associate_health_monitor(pool_id, body)
print >>self.app.stdout, (_('Associated health monitor '
'%s') % parsed_args.health_monitor_id)
print((_('Associated health monitor '
'%s') % parsed_args.health_monitor_id),
file=self.app.stdout)
class DisassociateHealthMonitor(neutronV20.NeutronCommand):
@@ -169,5 +172,6 @@ class DisassociateHealthMonitor(neutronV20.NeutronCommand):
neutron_client.disassociate_health_monitor(pool_id,
parsed_args
.health_monitor_id)
print >>self.app.stdout, (_('Disassociated health monitor '
'%s') % parsed_args.health_monitor_id)
print((_('Disassociated health monitor '
'%s') % parsed_args.health_monitor_id),
file=self.app.stdout)

View File

@@ -14,6 +14,8 @@
#@author Sergey Sudakovich, Cisco Systems
#@author Rudrajit Tapadar, Cisco Systems
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
@@ -128,7 +130,7 @@ class UpdateNetworkProfileV2(neutronV20.NeutronCommand):
data[self.resource]['remove_tenant'] = parsed_args.remove_tenant
neutron_client.update_network_profile(parsed_args.id,
{self.resource: data})
print >>self.app.stdout, (
_('Updated %(resource)s: %(id)s') %
{'id': parsed_args.id, 'resource': self.resource})
print((_('Updated %(resource)s: %(id)s') %
{'id': parsed_args.id, 'resource': self.resource}),
file=self.app.stdout)
return

View File

@@ -14,6 +14,8 @@
# under the License.
#
from __future__ import print_function
import logging
from neutronclient.common import utils
@@ -133,8 +135,8 @@ class ConnectNetworkGateway(NetworkGatewayInterfaceCommand):
'segmentation_id': parsed_args.segmentation_id})
# TODO(Salvatore-Orlando): Do output formatting as
# any other command
print >>self.app.stdout, (
_('Connected network to gateway %s') % gateway_id)
print(_('Connected network to gateway %s') % gateway_id,
file=self.app.stdout)
class DisconnectNetworkGateway(NetworkGatewayInterfaceCommand):
@@ -154,5 +156,5 @@ class DisconnectNetworkGateway(NetworkGatewayInterfaceCommand):
'segmentation_id': parsed_args.segmentation_id})
# TODO(Salvatore-Orlando): Do output formatting as
# any other command
print >>self.app.stdout, (
_('Disconnected network from gateway %s') % gateway_id)
print(_('Disconnected network from gateway %s') % gateway_id,
file=self.app.stdout)

View File

@@ -13,7 +13,10 @@
#@author Abhishek Raut, Cisco Systems
#@author Sergey Sudakovich, Cisco Systems
from __future__ import print_function
import logging
from neutronclient.neutron import v2_0 as neutronV20
from neutronclient.neutron.v2_0 import parse_args_to_dict
from neutronclient.openstack.common.gettextutils import _
@@ -71,7 +74,7 @@ class UpdatePolicyProfileV2(neutronV20.UpdateCommand):
data[self.resource]['remove_tenant'] = parsed_args.remove_tenant
neutron_client.update_policy_profile(parsed_args.id,
{self.resource: data})
print >>self.app.stdout, (
_('Updated %(resource)s: %(id)s') %
{'id': parsed_args.id, 'resource': self.resource})
print((_('Updated %(resource)s: %(id)s') %
{'id': parsed_args.id, 'resource': self.resource}),
file=self.app.stdout)
return

View File

@@ -14,6 +14,8 @@
# under the License.
#
from __future__ import print_function
import argparse
import logging
@@ -57,9 +59,10 @@ class DeleteQuota(neutronV20.NeutronCommand):
obj_deleter = getattr(neutron_client,
"delete_%s" % self.resource)
obj_deleter(tenant_id)
print >>self.app.stdout, (_('Deleted %(resource)s: %(tenant_id)s')
% {'tenant_id': tenant_id,
'resource': self.resource})
print((_('Deleted %(resource)s: %(tenant_id)s')
% {'tenant_id': tenant_id,
'resource': self.resource}),
file=self.app.stdout)
return

View File

@@ -14,6 +14,8 @@
# under the License.
#
from __future__ import print_function
import argparse
import logging
@@ -141,8 +143,8 @@ class RouterInterfaceCommand(neutronV20.NeutronCommand):
body = {'%s_id' % resource: _interface_id}
portinfo = self.call_api(neutron_client, _router_id, body)
print >>self.app.stdout, self.success_message(parsed_args.router_id,
portinfo)
print(self.success_message(parsed_args.router_id, portinfo),
file=self.app.stdout)
class AddInterfaceRouter(RouterInterfaceCommand):
@@ -203,8 +205,8 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
if parsed_args.disable_snat:
router_dict['enable_snat'] = False
neutron_client.add_gateway_router(_router_id, router_dict)
print >>self.app.stdout, (
_('Set gateway for router %s') % parsed_args.router_id)
print(_('Set gateway for router %s') % parsed_args.router_id,
file=self.app.stdout)
class RemoveGatewayRouter(neutronV20.NeutronCommand):
@@ -228,5 +230,5 @@ class RemoveGatewayRouter(neutronV20.NeutronCommand):
_router_id = neutronV20.find_resourceid_by_name_or_id(
neutron_client, self.resource, parsed_args.router_id)
neutron_client.remove_gateway_router(_router_id)
print >>self.app.stdout, (
_('Removed gateway from router %s') % parsed_args.router_id)
print(_('Removed gateway from router %s') % parsed_args.router_id,
file=self.app.stdout)

View File

@@ -18,6 +18,8 @@
Command-line interface to the Neutron APIs
"""
from __future__ import print_function
import argparse
import logging
import os
@@ -459,7 +461,7 @@ class NeutronShell(app.App):
cmd_parser = cmd.get_parser('')
for option, _action in cmd_parser._option_string_actions.items():
options.add(option)
print ' '.join(commands | options)
print(' '.join(commands | options))
def run(self, argv):
"""Equivalent to the main program for the application.
@@ -666,7 +668,7 @@ def main(argv=sys.argv[1:]):
except exc.NeutronClientException:
return 1
except Exception as e:
print unicode(e)
print(unicode(e))
return 1

View File

@@ -29,8 +29,7 @@ downloadcache = ~/cache/pip
[flake8]
# E125 continuation line does not distinguish itself from next logical line
# H233 Python 3.x incompatible use of print operator
# H302 import only modules
ignore = E125,H233,H302
ignore = E125,H302
show-source = true
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools