diff --git a/contrib/inventory/consul_io.py b/contrib/inventory/consul_io.py index 392c9561db3..2f226e7b50e 100755 --- a/contrib/inventory/consul_io.py +++ b/contrib/inventory/consul_io.py @@ -133,10 +133,7 @@ import os import re import argparse import sys -from time import time -import sys import ConfigParser -import urllib, urllib2, base64 def get_log_filename(): diff --git a/contrib/inventory/spacewalk.py b/contrib/inventory/spacewalk.py index 260241d807d..bee92dfb89e 100755 --- a/contrib/inventory/spacewalk.py +++ b/contrib/inventory/spacewalk.py @@ -62,7 +62,7 @@ CACHE_DIR = os.path.join(base_dir, ".spacewalk_reports") CACHE_AGE = 300 # 5min INI_FILE = os.path.join(base_dir, "spacewalk.ini") - # Sanity check +# Sanity check if not os.path.exists(SW_REPORT): print('Error: %s is required for operation.' % (SW_REPORT), file=sys.stderr) sys.exit(1) diff --git a/contrib/inventory/zabbix.py b/contrib/inventory/zabbix.py index 28b643bca63..6d41df4d3eb 100755 --- a/contrib/inventory/zabbix.py +++ b/contrib/inventory/zabbix.py @@ -32,7 +32,8 @@ Tested with Zabbix Server 2.0.6. from __future__ import print_function -import os, sys +import os +import sys import argparse import ConfigParser diff --git a/hacking/dump_playbook_attributes.py b/hacking/dump_playbook_attributes.py index c1efb9c1623..8ccd6f752b2 100755 --- a/hacking/dump_playbook_attributes.py +++ b/hacking/dump_playbook_attributes.py @@ -29,7 +29,7 @@ for aclass in class_list: # build ordered list to loop over and dict with attributes clist.append(name) - oblist[name] = dict((x, aobj.__dict__['_attributes'][x]) for x in aobj.__dict__['_attributes'] if 'private' not in x or not x.private) + oblist[name] = dict((x, aobj.__dict__['_attributes'][x]) for x in aobj.__dict__['_attributes'] if 'private' not in x or not x.private) # loop is really with_ for users if name == 'Task': diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index 6574f9fb422..932093e2c83 100644 --- a/lib/ansible/cli/__init__.py +++ b/lib/ansible/cli/__init__.py @@ -103,8 +103,10 @@ class CLI(with_metaclass(ABCMeta, object)): _CONST = re.compile(r"C\(([^)]+)\)") PAGER = 'less' - LESS_OPTS = 'FRSX' # -F (quit-if-one-screen) -R (allow raw ansi control chars) - # -S (chop long lines) -X (disable termcap init and de-init) + + # -F (quit-if-one-screen) -R (allow raw ansi control chars) + # -S (chop long lines) -X (disable termcap init and de-init) + LESS_OPTS = 'FRSX' def __init__(self, args, callback=None): """ diff --git a/lib/ansible/galaxy/token.py b/lib/ansible/galaxy/token.py index 02ca8330697..4346dc8760a 100644 --- a/lib/ansible/galaxy/token.py +++ b/lib/ansible/galaxy/token.py @@ -64,4 +64,4 @@ class GalaxyToken(object): def save(self): with open(self.file,'w') as f: yaml.safe_dump(self.config,f,default_flow_style=False) - \ No newline at end of file + diff --git a/lib/ansible/module_utils/ec2.py b/lib/ansible/module_utils/ec2.py index 9302b445fea..f829373bd30 100755 --- a/lib/ansible/module_utils/ec2.py +++ b/lib/ansible/module_utils/ec2.py @@ -619,4 +619,4 @@ def map_complex_type(complex_type, type_map): type_map)) elif type_map: return vars(globals()['__builtins__'])[type_map](complex_type) - return new_type \ No newline at end of file + return new_type diff --git a/lib/ansible/modules/cloud/amazon/cloudtrail.py b/lib/ansible/modules/cloud/amazon/cloudtrail.py index ab4652fccd4..7cb55c83b49 100644 --- a/lib/ansible/modules/cloud/amazon/cloudtrail.py +++ b/lib/ansible/modules/cloud/amazon/cloudtrail.py @@ -208,7 +208,7 @@ def main(): results['view'] = cf_man.view(ct_name) # only update if the values have changed. if results['view']['S3BucketName'] != s3_bucket_name or \ - results['view'].get('S3KeyPrefix', '') != s3_key_prefix or \ + results['view'].get('S3KeyPrefix', '') != s3_key_prefix or \ results['view']['IncludeGlobalServiceEvents'] != include_global_events: if not module.check_mode: results['update'] = cf_man.update(name=ct_name, s3_bucket_name=s3_bucket_name, s3_key_prefix=s3_key_prefix, include_global_service_events=include_global_events) diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py index 123e6e98ec8..28d988debd4 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py @@ -148,7 +148,7 @@ def main(): module = AnsibleModule(argument_spec=argument_spec) - # Validate Requirements + # Validate Requirements if not HAS_BOTO3: module.fail_json(msg='json and botocore/boto3 is required.') diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py index 0775c75bb2a..6e378dc2711 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py @@ -148,7 +148,7 @@ def main(): module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) - # Validate Requirements + # Validate Requirements if not HAS_BOTO3: module.fail_json(msg='json and boto3 is required.') @@ -160,7 +160,7 @@ def main(): # call your function here results = list_virtual_gateways(connection, module) - + module.exit_json(result=results) diff --git a/lib/ansible/modules/cloud/openstack/_quantum_network.py b/lib/ansible/modules/cloud/openstack/_quantum_network.py index 9897d50aa49..3a2c754b2ea 100644 --- a/lib/ansible/modules/cloud/openstack/_quantum_network.py +++ b/lib/ansible/modules/cloud/openstack/_quantum_network.py @@ -270,7 +270,7 @@ def main(): if not module.params['provider_physical_network']: module.fail_json(msg = " for vlan and flat networks, variable provider_physical_network should be set.") - if module.params['provider_network_type'] in ['vlan', 'gre']: + if module.params['provider_network_type'] in ['vlan', 'gre']: if not module.params['provider_segmentation_id']: module.fail_json(msg = " for vlan & gre networks, variable provider_segmentation_id should be set.") diff --git a/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py b/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py index 594a9e17830..966e8f65834 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py +++ b/lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py @@ -159,4 +159,4 @@ from ansible.module_utils.vmware import * from ansible.module_utils.basic import * if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/files/unarchive.py b/lib/ansible/modules/files/unarchive.py index ac11346ae68..f9d6baede64 100644 --- a/lib/ansible/modules/files/unarchive.py +++ b/lib/ansible/modules/files/unarchive.py @@ -559,10 +559,10 @@ class ZipArchive(object): if self.opts: cmd.extend(self.opts) cmd.append(self.src) - # NOTE: Including (changed) files as arguments is problematic (limits on command line/arguments) -# if self.includes: - # NOTE: Command unzip has this strange behaviour where it expects quoted filenames to also be escaped -# cmd.extend(map(shell_escape, self.includes)) + # NOTE: Including (changed) files as arguments is problematic (limits on command line/arguments) + # if self.includes: + # NOTE: Command unzip has this strange behaviour where it expects quoted filenames to also be escaped + # cmd.extend(map(shell_escape, self.includes)) if self.excludes: cmd.extend([ '-x' ] + self.excludes) cmd.extend([ '-d', self.dest ]) diff --git a/lib/ansible/modules/network/illumos/dladm_vlan.py b/lib/ansible/modules/network/illumos/dladm_vlan.py index 8ecf0b2d3d1..a1981bcb653 100644 --- a/lib/ansible/modules/network/illumos/dladm_vlan.py +++ b/lib/ansible/modules/network/illumos/dladm_vlan.py @@ -220,4 +220,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/network/ios/ios_config.py b/lib/ansible/modules/network/ios/ios_config.py index b582794f308..ad0c5ac19df 100644 --- a/lib/ansible/modules/network/ios/ios_config.py +++ b/lib/ansible/modules/network/ios/ios_config.py @@ -226,7 +226,7 @@ import time from ansible.module_utils.local import LocalAnsibleModule from ansible.module_utils.ios import load_config, get_config, run_commands from ansible.module_utils.netcfg import NetworkConfig, dumps -from ansible.module_utils.six import iteritems +from ansible.module_utils.six import iteritems from ansible.module_utils.network import NET_TRANSPORT_ARGS, _transitional_argument_spec diff --git a/lib/ansible/modules/network/nxos/nxos_gir.py b/lib/ansible/modules/network/nxos/nxos_gir.py index f72f7d79a07..19e0983c773 100644 --- a/lib/ansible/modules/network/nxos/nxos_gir.py +++ b/lib/ansible/modules/network/nxos/nxos_gir.py @@ -508,4 +508,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/network/nxos/nxos_igmp_interface.py b/lib/ansible/modules/network/nxos/nxos_igmp_interface.py index e6e6107ead6..b72a22940af 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp_interface.py @@ -907,4 +907,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index 05dc3c155a7..275a0dcf6e7 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -554,7 +554,7 @@ def get_interfaces_dict(module): } interface_list = body.get('TABLE_interface')['ROW_interface'] - for index in interface_list: + for index in interface_list: intf = index ['interface'] intf_type = get_interface_type(intf) @@ -967,4 +967,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/network/nxos/nxos_portchannel.py b/lib/ansible/modules/network/nxos/nxos_portchannel.py index 6e0ebbef1bf..6614691b050 100644 --- a/lib/ansible/modules/network/nxos/nxos_portchannel.py +++ b/lib/ansible/modules/network/nxos/nxos_portchannel.py @@ -743,4 +743,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py index a3420307a6f..66353ee04fd 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py @@ -505,4 +505,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/lib/ansible/modules/packaging/os/pkgng.py b/lib/ansible/modules/packaging/os/pkgng.py index e281f51a02f..df5a9713a44 100644 --- a/lib/ansible/modules/packaging/os/pkgng.py +++ b/lib/ansible/modules/packaging/os/pkgng.py @@ -175,8 +175,9 @@ def install_packages(module, pkgng_path, packages, cached, pkgsite, dir_arg): else: pkgsite = "-r %s" % (pkgsite) - batch_var = 'env BATCH=yes' # This environment variable skips mid-install prompts, - # setting them to their default values. + # This environment variable skips mid-install prompts, + # setting them to their default values. + batch_var = 'env BATCH=yes' if not module.check_mode and not cached: if old_pkgng: diff --git a/lib/ansible/modules/system/lvol.py b/lib/ansible/modules/system/lvol.py index 3ab60cb40ac..105e62c6503 100644 --- a/lib/ansible/modules/system/lvol.py +++ b/lib/ansible/modules/system/lvol.py @@ -414,7 +414,7 @@ def main(): if '+' in size: size_requested += this_lv['size'] if this_lv['size'] < size_requested: - if (size_free > 0) and (('+' not in size) or (size_free >= (size_requested - this_lv['size']))): + if (size_free > 0) and (('+' not in size) or (size_free >= (size_requested - this_lv['size']))): tool = module.get_bin_path("lvextend", required=True) else: module.fail_json(msg="Logical Volume %s could not be extended. Not enough free space left (%s%s required / %s%s available)" % (this_lv['name'], (size_requested - this_lv['size']), unit, size_free, unit)) diff --git a/lib/ansible/modules/system/open_iscsi.py b/lib/ansible/modules/system/open_iscsi.py index 16f45ee6e11..b036d3d852a 100644 --- a/lib/ansible/modules/system/open_iscsi.py +++ b/lib/ansible/modules/system/open_iscsi.py @@ -151,7 +151,7 @@ def iscsi_get_cached_nodes(module, portal=None): # older versions of scsiadm don't have nice return codes # for newer versions see iscsiadm(8); also usr/iscsiadm.c for details - # err can contain [N|n]o records... + # err can contain [N|n]o records... elif rc == 21 or (rc == 255 and "o records found" in err): nodes = [] else: diff --git a/lib/ansible/modules/web_infrastructure/letsencrypt.py b/lib/ansible/modules/web_infrastructure/letsencrypt.py index 731f02c04c6..7e8f76329da 100644 --- a/lib/ansible/modules/web_infrastructure/letsencrypt.py +++ b/lib/ansible/modules/web_infrastructure/letsencrypt.py @@ -279,7 +279,8 @@ class ACMEDirectory(object): self.directory = simple_get(self.module,self.directory_root) - def __getitem__(self, key): return self.directory[key] + def __getitem__(self, key): + return self.directory[key] def get_nonce(self,resource=None): url = self.directory_root diff --git a/lib/ansible/modules/windows/win_share.py b/lib/ansible/modules/windows/win_share.py index 5585c1eb76b..fb9f72fef5b 100644 --- a/lib/ansible/modules/windows/win_share.py +++ b/lib/ansible/modules/windows/win_share.py @@ -118,4 +118,4 @@ EXAMPLES = r''' RETURN = r''' -''' \ No newline at end of file +''' diff --git a/lib/ansible/modules/windows/win_shortcut.py b/lib/ansible/modules/windows/win_shortcut.py index b54669553fa..f22c3a46820 100644 --- a/lib/ansible/modules/windows/win_shortcut.py +++ b/lib/ansible/modules/windows/win_shortcut.py @@ -103,4 +103,4 @@ EXAMPLES = r''' ''' RETURN = ''' -''' \ No newline at end of file +''' diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index 9157bde5409..5e9c0fb81bf 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -293,7 +293,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h needs_templating = True break is_static = C.DEFAULT_TASK_INCLUDES_STATIC or \ - (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) or \ + (use_handlers and C.DEFAULT_HANDLER_INCLUDES_STATIC) or \ (not needs_templating and ir.all_parents_static() and not ir.loop) display.debug('Determined that if include_role static is %s' % str(is_static)) if is_static: diff --git a/lib/ansible/plugins/lookup/mongodb.py b/lib/ansible/plugins/lookup/mongodb.py index 9f73a0373ae..ded9495a67c 100644 --- a/lib/ansible/plugins/lookup/mongodb.py +++ b/lib/ansible/plugins/lookup/mongodb.py @@ -23,7 +23,7 @@ import datetime __metaclass__ = type try: - from pymongo import ASCENDING, DESCENDING + from pymongo import ASCENDING, DESCENDING from pymongo.errors import ConnectionFailure from pymongo import MongoClient except ImportError: @@ -40,6 +40,7 @@ else: from ansible.errors import AnsibleError from ansible.plugins.lookup import LookupBase + class LookupModule(LookupBase): def _fix_sort_parameter(self, sort_parameter): diff --git a/test/integration/targets/async/library/async_test.py b/test/integration/targets/async/library/async_test.py index 5c77a27c8d9..e378a768b1e 100644 --- a/test/integration/targets/async/library/async_test.py +++ b/test/integration/targets/async/library/async_test.py @@ -36,4 +36,4 @@ def main(): if 'trailing_junk' in fail_mode: print("trailing junk after module output") -main() \ No newline at end of file +main() diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index e3cc1bc4c30..f7170762ee9 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -220,7 +220,6 @@ lib/ansible/modules/cloud/softlayer/sl_vm.py lib/ansible/modules/cloud/vmware/vca_fw.py lib/ansible/modules/cloud/vmware/vmware_guest.py lib/ansible/modules/cloud/vmware/vmware_local_user_manager.py -lib/ansible/modules/cloud/vmware/vmware_vm_vss_dvs_migrate.py lib/ansible/modules/cloud/vmware/vmware_vswitch.py lib/ansible/modules/cloud/vmware/vsphere_copy.py lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -317,8 +316,6 @@ lib/ansible/modules/network/f5/bigip_pool.py lib/ansible/modules/network/f5/bigip_pool_member.py lib/ansible/modules/network/f5/bigip_virtual_server.py lib/ansible/modules/network/haproxy.py -lib/ansible/modules/network/illumos/dladm_vlan.py -lib/ansible/modules/network/ios/ios_config.py lib/ansible/modules/network/junos/junos_facts.py lib/ansible/modules/network/lldp.py lib/ansible/modules/network/nmcli.py @@ -456,7 +453,6 @@ lib/ansible/modules/system/lvg.py lib/ansible/modules/system/lvol.py lib/ansible/modules/system/modprobe.py lib/ansible/modules/system/ohai.py -lib/ansible/modules/system/open_iscsi.py lib/ansible/modules/system/openwrt_init.py lib/ansible/modules/system/pam_limits.py lib/ansible/modules/system/sefcontext.py @@ -498,9 +494,7 @@ lib/ansible/modules/windows/win_regedit.py lib/ansible/modules/windows/win_regmerge.py lib/ansible/modules/windows/win_robocopy.py lib/ansible/modules/windows/win_say.py -lib/ansible/modules/windows/win_share.py lib/ansible/modules/windows/win_shell.py -lib/ansible/modules/windows/win_shortcut.py lib/ansible/modules/windows/win_unzip.py lib/ansible/modules/windows/win_updates.py lib/ansible/modules/windows/win_uri.py @@ -575,7 +569,6 @@ setup.py test/integration/cleanup_ec2.py test/integration/cleanup_gce.py test/integration/setup_gce.py -test/integration/targets/async/library/async_test.py test/units/cli/test_galaxy.py test/units/contrib/inventory/test_vmware_inventory.py test/units/errors/test_errors.py diff --git a/test/sanity/pep8/legacy-ignore.txt b/test/sanity/pep8/legacy-ignore.txt index 7f0227203f5..3d2daffbb76 100644 --- a/test/sanity/pep8/legacy-ignore.txt +++ b/test/sanity/pep8/legacy-ignore.txt @@ -2,7 +2,6 @@ E101 E111 E114 E115 -E116 E121 E122 E125 @@ -10,16 +9,12 @@ E126 E129 E131 E271 -E272 -E401 E501 E701 E703 -E704 E711 E712 E721 W191 W291 -W292 W293