From bcb3e33adbe588dcf86dc24bef5cf37e9f6d2a78 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 4 Aug 2017 08:39:13 +0200 Subject: [PATCH] command: PEP8 compliancy (#27740) --- lib/ansible/modules/commands/command.py | 48 ++++++++++++------------- test/sanity/pep8/legacy-files.txt | 1 - 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/ansible/modules/commands/command.py b/lib/ansible/modules/commands/command.py index 139b68b206..e9544ff813 100644 --- a/lib/ansible/modules/commands/command.py +++ b/lib/ansible/modules/commands/command.py @@ -90,15 +90,15 @@ from ansible.module_utils.basic import AnsibleModule def check_command(module, commandline): - arguments = { 'chown': 'owner', 'chmod': 'mode', 'chgrp': 'group', - 'ln': 'state=link', 'mkdir': 'state=directory', - 'rmdir': 'state=absent', 'rm': 'state=absent', 'touch': 'state=touch' } - commands = { 'hg': 'hg', 'curl': 'get_url or uri', 'wget': 'get_url or uri', - 'svn': 'subversion', 'service': 'service', - 'mount': 'mount', 'rpm': 'yum, dnf or zypper', 'yum': 'yum', 'apt-get': 'apt', - 'tar': 'unarchive', 'unzip': 'unarchive', 'sed': 'template or lineinfile', - 'dnf': 'dnf', 'zypper': 'zypper' } - become = [ 'sudo', 'su', 'pbrun', 'pfexec', 'runas', 'pmrun' ] + arguments = {'chown': 'owner', 'chmod': 'mode', 'chgrp': 'group', + 'ln': 'state=link', 'mkdir': 'state=directory', + 'rmdir': 'state=absent', 'rm': 'state=absent', 'touch': 'state=touch'} + commands = {'hg': 'hg', 'curl': 'get_url or uri', 'wget': 'get_url or uri', + 'svn': 'subversion', 'service': 'service', + 'mount': 'mount', 'rpm': 'yum, dnf or zypper', 'yum': 'yum', 'apt-get': 'apt', + 'tar': 'unarchive', 'unzip': 'unarchive', 'sed': 'template or lineinfile', + 'dnf': 'dnf', 'zypper': 'zypper'} + become = ['sudo', 'su', 'pbrun', 'pfexec', 'runas', 'pmrun'] command = os.path.basename(commandline.split()[0]) if command in arguments: module.warn("Consider using file module with %s rather than running %s" % (arguments[command], command)) @@ -114,13 +114,13 @@ def main(): # hence don't copy this one if you are looking to build others! module = AnsibleModule( argument_spec=dict( - _raw_params = dict(), - _uses_shell = dict(type='bool', default=False), - chdir = dict(type='path'), - executable = dict(), - creates = dict(type='path'), - removes = dict(type='path'), - warn = dict(type='bool', default=True), + _raw_params=dict(), + _uses_shell=dict(type='bool', default=False), + chdir=dict(type='path'), + executable=dict(), + creates=dict(type='path'), + removes=dict(type='path'), + warn=dict(type='bool', default=True), ) ) @@ -185,14 +185,14 @@ def main(): err = b'' result = dict( - cmd = args, - stdout = out.rstrip(b"\r\n"), - stderr = err.rstrip(b"\r\n"), - rc = rc, - start = str(startd), - end = str(endd), - delta = str(delta), - changed = True, + cmd=args, + stdout=out.rstrip(b"\r\n"), + stderr=err.rstrip(b"\r\n"), + rc=rc, + start=str(startd), + end=str(endd), + delta=str(delta), + changed=True, ) if rc != 0: diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 73d34379a4..3e329e00e2 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -195,7 +195,6 @@ lib/ansible/modules/clustering/consul_kv.py lib/ansible/modules/clustering/consul_session.py lib/ansible/modules/clustering/kubernetes.py lib/ansible/modules/clustering/pacemaker_cluster.py -lib/ansible/modules/commands/command.py lib/ansible/modules/database/misc/elasticsearch_plugin.py lib/ansible/modules/database/misc/kibana_plugin.py lib/ansible/modules/database/misc/redis.py