Backslash continuation removal (Nova folsom-2)

Fixes bug #938588

Backslash continuations removal for scripts in bin/, plugin/, and etc.

Change-Id: Idd17048b6e8db6e939946968e011e68da8585b8d
This commit is contained in:
Zhongyue Luo 2012-05-16 17:08:27 +08:00
parent d02cc36034
commit bee7d99a97
6 changed files with 63 additions and 64 deletions

View File

@ -10,6 +10,8 @@ General
-------
- Put two newlines between top-level code (funcs, classes, etc)
- Put one newline between methods in classes and anywhere else
- Long lines should be wrapped in parentheses
in preference to using a backslash for line continuation.
- Do not write "except:", use "except Exception:" at the very least
- Include your name with TODOs as in "#TODO(termie)"
- Do not shadow a built-in or reserved word. Example::

View File

@ -48,10 +48,9 @@ from nova.openstack.common import cfg
from nova import rpc
delete_exchange_opt = \
cfg.BoolOpt('delete_exchange',
default=False,
help='delete nova exchange too.')
delete_exchange_opt = cfg.BoolOpt('delete_exchange',
default=False,
help='delete nova exchange too.')
FLAGS = flags.FLAGS
FLAGS.register_cli_opt(delete_exchange_opt)

View File

@ -108,10 +108,10 @@ def main():
if action in ['add', 'del', 'old']:
mac = argv[2]
ip = argv[3]
msg = _("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % \
{"action": action,
"mac": mac,
"ip": ip}
msg = (_("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") %
{"action": action,
"mac": mac,
"ip": ip})
LOG.debug(msg)
globals()[action + '_lease'](mac, ip)
else:

View File

@ -593,8 +593,8 @@ class FixedIpCommands(object):
hostname = instance['hostname']
host = instance['host']
else:
print 'WARNING: fixed ip %s allocated to missing' \
' instance' % str(fixed_ip['address'])
print ('WARNING: fixed ip %s allocated to missing'
' instance' % str(fixed_ip['address']))
print "%-18s\t%-15s\t%-15s\t%s" % (
network['cidr'],
fixed_ip['address'],
@ -760,8 +760,8 @@ class NetworkCommands(object):
if FLAGS.network_manager in bridge_required:
raise exception.NetworkNotCreated(req='--bridge')
bridge_interface = bridge_interface or FLAGS.flat_interface or \
FLAGS.vlan_interface
bridge_interface = (bridge_interface or FLAGS.flat_interface or
FLAGS.vlan_interface)
if not bridge_interface:
interface_required = ['nova.network.manager.VlanManager']
if FLAGS.network_manager in interface_required:
@ -873,8 +873,8 @@ class NetworkCommands(object):
if uuid is None:
raise Exception("UUID is required to delete Quantum Networks")
if fixed_range:
raise Exception("Deleting by fixed_range is not supported " \
"with the QuantumManager")
raise Exception("Deleting by fixed_range is not supported "
"with the QuantumManager")
# delete the network
net_manager.delete_network(context.get_admin_context(),
fixed_range, uuid)
@ -920,20 +920,19 @@ class VmCommands(object):
def list(self, host=None):
"""Show a list of all instances"""
print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \
" %-10s %-10s %-10s %-5s" % (
_('instance'),
_('node'),
_('type'),
_('state'),
_('launched'),
_('image'),
_('kernel'),
_('ramdisk'),
_('project'),
_('user'),
_('zone'),
_('index'))
print ("%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s"
" %-10s %-10s %-10s %-5s" % (_('instance'),
_('node'),
_('type'),
_('state'),
_('launched'),
_('image'),
_('kernel'),
_('ramdisk'),
_('project'),
_('user'),
_('zone'),
_('index')))
if host is None:
instances = db.instance_get_all(context.get_admin_context())
@ -942,20 +941,19 @@ class VmCommands(object):
context.get_admin_context(), host)
for instance in instances:
print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \
" %-10s %-10s %-10s %-5d" % (
instance['display_name'],
instance['host'],
instance['instance_type'].name,
instance['vm_state'],
instance['launched_at'],
instance['image_ref'],
instance['kernel_id'],
instance['ramdisk_id'],
instance['project_id'],
instance['user_id'],
instance['availability_zone'],
instance['launch_index'])
print ("%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s"
" %-10s %-10s %-10s %-5d" % (instance['display_name'],
instance['host'],
instance['instance_type'].name,
instance['vm_state'],
instance['launched_at'],
instance['image_ref'],
instance['kernel_id'],
instance['ramdisk_id'],
instance['project_id'],
instance['user_id'],
instance['availability_zone'],
instance['launch_index']))
class ServiceCommands(object):
@ -1040,17 +1038,17 @@ class ServiceCommands(object):
"c": _('cpu'),
"d": _('mem(mb)'),
"e": _('hdd')}
print '%(a)-16s(total)%(b)26s%(c)8s%(d)8s' %\
{"a": host,
"b": result['resource']['vcpus'],
"c": result['resource']['memory_mb'],
"d": result['resource']['local_gb']}
print ('%(a)-16s(total)%(b)26s%(c)8s%(d)8s' %
{"a": host,
"b": result['resource']['vcpus'],
"c": result['resource']['memory_mb'],
"d": result['resource']['local_gb']})
print '%(a)-16s(used_now)%(b)23s%(c)8s%(d)8s' %\
{"a": host,
"b": result['resource']['vcpus_used'],
"c": result['resource']['memory_mb_used'],
"d": result['resource']['local_gb_used']}
print ('%(a)-16s(used_now)%(b)23s%(c)8s%(d)8s' %
{"a": host,
"b": result['resource']['vcpus_used'],
"c": result['resource']['memory_mb_used'],
"d": result['resource']['local_gb_used']})
# Printing a used_max
cpu_sum = 0
@ -1121,9 +1119,9 @@ class VersionCommands(object):
pass
def list(self):
print _("%(version)s (%(vcs)s)") % \
{'version': version.version_string(),
'vcs': version.version_string_with_vcs()}
print (_("%(version)s (%(vcs)s)") %
{'version': version.version_string(),
'vcs': version.version_string_with_vcs()})
def __call__(self):
self.list()
@ -1689,9 +1687,9 @@ def main():
script_name = argv.pop(0)
if len(argv) < 1:
print _("\nOpenStack Nova version: %(version)s (%(vcs)s)\n") % \
{'version': version.version_string(),
'vcs': version.version_string_with_vcs()}
print (_("\nOpenStack Nova version: %(version)s (%(vcs)s)\n") %
{'version': version.version_string(),
'vcs': version.version_string_with_vcs()})
print script_name + " category action [<args>]"
print _("Available categories:")
for k, _v in CATEGORIES:

View File

@ -68,8 +68,8 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state,
if old_vm_state != new_vm_state:
# yes, the vm state is changing:
fire_update = True
elif FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and \
old_task_state != new_task_state:
elif (FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and
old_task_state != new_task_state):
# yes, the task state is changing:
fire_update = True

View File

@ -128,8 +128,8 @@ class VolumeTestCase(test.TestCase):
self.volume.create_volume(self.context, volume_id)
self.mox.StubOutWithMock(self.volume.driver, 'delete_volume')
self.volume.driver.delete_volume(mox.IgnoreArg()) \
.AndRaise(exception.VolumeIsBusy)
self.volume.driver.delete_volume(mox.IgnoreArg()).AndRaise(
exception.VolumeIsBusy)
self.mox.ReplayAll()
res = self.volume.delete_volume(self.context, volume_id)
self.assertEqual(True, res)
@ -374,8 +374,8 @@ class VolumeTestCase(test.TestCase):
self.volume.create_snapshot(self.context, volume_id, snapshot_id)
self.mox.StubOutWithMock(self.volume.driver, 'delete_snapshot')
self.volume.driver.delete_snapshot(mox.IgnoreArg()) \
.AndRaise(exception.SnapshotIsBusy)
self.volume.driver.delete_snapshot(mox.IgnoreArg()).AndRaise(
exception.SnapshotIsBusy)
self.mox.ReplayAll()
self.volume.delete_snapshot(self.context, snapshot_id)
snapshot_ref = db.snapshot_get(self.context, snapshot_id)