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 e2e9989d9a
commit c82b570ffb
4 changed files with 35 additions and 37 deletions

View File

@@ -233,8 +233,8 @@ def main():
ORIG_DUMP = ORIG_DB + ".dump" ORIG_DUMP = ORIG_DB + ".dump"
NEW_DUMP = NEW_DB + ".dump" NEW_DUMP = NEW_DB + ".dump"
db_type, orig_branch, orig_version, new_branch, new_version =\ options = parse_options()
parse_options() db_type, orig_branch, orig_version, new_branch, new_version = options
# Since we're going to be switching branches, ensure user doesn't have any # Since we're going to be switching branches, ensure user doesn't have any
# uncommited changes # uncommited changes

View File

@@ -119,21 +119,20 @@ def _get_windows_network_adapters():
wbem_service = wbem_locator.ConnectServer('.', 'root\cimv2') wbem_service = wbem_locator.ConnectServer('.', 'root\cimv2')
wbem_network_adapters = wbem_service.InstancesOf('Win32_NetworkAdapter') wbem_network_adapters = wbem_service.InstancesOf('Win32_NetworkAdapter')
network_adapters = [] network_adapters = []
for wbem_network_adapter in wbem_network_adapters: for adapter in wbem_network_adapters:
if wbem_network_adapter.NetConnectionStatus == 2 or \ if (adapter.NetConnectionStatus == 2 or
wbem_network_adapter.NetConnectionStatus == 7: adapter.NetConnectionStatus == 7):
adapter_name = wbem_network_adapter.NetConnectionID adapter_name = adapter.NetConnectionID
mac_address = wbem_network_adapter.MacAddress.lower() mac_address = adapter.MacAddress.lower()
wbem_network_adapter_config = \ config = adapter.associators_(
wbem_network_adapter.associators_(
'Win32_NetworkAdapterSetting', 'Win32_NetworkAdapterSetting',
'Win32_NetworkAdapterConfiguration')[0] 'Win32_NetworkAdapterConfiguration')[0]
ip_address = '' ip_address = ''
subnet_mask = '' subnet_mask = ''
if wbem_network_adapter_config.IPEnabled: if config.IPEnabled:
ip_address = wbem_network_adapter_config.IPAddress[0] ip_address = config.IPAddress[0]
subnet_mask = wbem_network_adapter_config.IPSubnet[0] subnet_mask = config.IPSubnet[0]
#wbem_network_adapter_config.DefaultIPGateway[0] #config.DefaultIPGateway[0]
network_adapters.append({'name': adapter_name, network_adapters.append({'name': adapter_name,
'mac-address': mac_address, 'mac-address': mac_address,
'ip-address': ip_address, 'ip-address': ip_address,
@@ -160,9 +159,8 @@ def _get_linux_network_adapters():
sock.fileno(), sock.fileno(),
0x8912, 0x8912,
struct.pack('iL', max_bytes, names.buffer_info()[0])))[0] struct.pack('iL', max_bytes, names.buffer_info()[0])))[0]
adapter_names = \ adapter_names = [names.tostring()[n_cnt:n_cnt + offset1].split('\0', 1)[0]
[names.tostring()[n_counter:n_counter + offset1].split('\0', 1)[0] for n_cnt in xrange(0, outbytes, offset2)]
for n_counter in xrange(0, outbytes, offset2)]
network_adapters = [] network_adapters = []
for adapter_name in adapter_names: for adapter_name in adapter_names:
ip_address = socket.inet_ntoa(fcntl.ioctl( ip_address = socket.inet_ntoa(fcntl.ioctl(
@@ -257,10 +255,10 @@ def _windows_set_networking():
cmd = ['"' + vmware_tools_bin + '"', '--cmd', 'machine.id.get'] cmd = ['"' + vmware_tools_bin + '"', '--cmd', 'machine.id.get']
for network_detail in _parse_network_details(_execute(cmd, for network_detail in _parse_network_details(_execute(cmd,
check_exit_code=False)): check_exit_code=False)):
mac_address, ip_address, subnet_mask, gateway, broadcast,\ (mac_address, ip_address, subnet_mask, gateway, broadcast,
dns_servers = network_detail dns_servers) = network_detail
adapter_name, current_ip_address = \ name_and_ip = _get_win_adapter_name_and_ip_address(mac_address)
_get_win_adapter_name_and_ip_address(mac_address) adapter_name, current_ip_address = name_and_ip
if adapter_name and not ip_address == current_ip_address: if adapter_name and not ip_address == current_ip_address:
cmd = ['netsh', 'interface', 'ip', 'set', 'address', cmd = ['netsh', 'interface', 'ip', 'set', 'address',
'name="%s"' % adapter_name, 'source=static', ip_address, 'name="%s"' % adapter_name, 'source=static', ip_address,
@@ -289,14 +287,14 @@ def _set_rhel_networking(network_details=None):
network_details = network_details or [] network_details = network_details or []
all_dns_servers = [] all_dns_servers = []
for network_detail in network_details: for network_detail in network_details:
mac_address, ip_address, subnet_mask, gateway, broadcast,\ (mac_address, ip_address, subnet_mask, gateway, broadcast,
dns_servers = network_detail dns_servers) = network_detail
all_dns_servers.extend(dns_servers) all_dns_servers.extend(dns_servers)
adapter_name, current_ip_address = \ name_and_ip = _get_linux_adapter_name_and_ip_address(mac_address)
_get_linux_adapter_name_and_ip_address(mac_address) adapter_name, current_ip_address = name_and_ip
if adapter_name and not ip_address == current_ip_address: if adapter_name and not ip_address == current_ip_address:
interface_file_name = \ interface_file_name = ('/etc/sysconfig/network-scripts/ifcfg-%s' %
'/etc/sysconfig/network-scripts/ifcfg-%s' % adapter_name adapter_name)
# Remove file # Remove file
os.remove(interface_file_name) os.remove(interface_file_name)
# Touch file # Touch file
@@ -337,11 +335,11 @@ def _set_ubuntu_networking(network_details=None):
_execute(['touch', interface_file_name]) _execute(['touch', interface_file_name])
interface_file = open(interface_file_name, 'w') interface_file = open(interface_file_name, 'w')
for device, network_detail in enumerate(network_details): for device, network_detail in enumerate(network_details):
mac_address, ip_address, subnet_mask, gateway, broadcast,\ (mac_address, ip_address, subnet_mask, gateway, broadcast,
dns_servers = network_detail dns_servers) = network_detail
all_dns_servers.extend(dns_servers) all_dns_servers.extend(dns_servers)
adapter_name, current_ip_address = \ name_and_ip = _get_linux_adapter_name_and_ip_address(mac_address)
_get_linux_adapter_name_and_ip_address(mac_address) adapter_name, current_ip_address = name_and_ip
if adapter_name: if adapter_name:
interface_file.write('\nauto %s' % adapter_name) interface_file.write('\nauto %s' % adapter_name)

View File

@@ -48,8 +48,8 @@ VERBOSE_MISSING_IMPORT = False
def is_import_exception(mod): def is_import_exception(mod):
return mod in IMPORT_EXCEPTIONS or \ return (mod in IMPORT_EXCEPTIONS or
any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS) any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS))
def import_normalize(line): def import_normalize(line):
@@ -114,9 +114,9 @@ def nova_one_import_per_line(logical_line):
""" """
pos = logical_line.find(',') pos = logical_line.find(',')
parts = logical_line.split() parts = logical_line.split()
if pos > -1 and (parts[0] == "import" or if (pos > -1 and (parts[0] == "import" or
parts[0] == "from" and parts[2] == "import") and \ parts[0] == "from" and parts[2] == "import") and
not is_import_exception(parts[1]): not is_import_exception(parts[1])):
return pos, "NOVA N301: one import per line" return pos, "NOVA N301: one import per line"
_missingImport = set([]) _missingImport = set([])

View File

@@ -143,8 +143,8 @@ class Fedora(Distro):
def get_distro(): def get_distro():
if os.path.exists('/etc/fedora-release') or \ if (os.path.exists('/etc/fedora-release') or
os.path.exists('/etc/redhat-release'): os.path.exists('/etc/redhat-release')):
return Fedora() return Fedora()
else: else:
return Distro() return Distro()