mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
move code linting to a stricter pep8-esque auto-formatting tool, black
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
@@ -10,7 +11,6 @@ from ansible.plugins.action import ActionBase
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
def save_playbook(self, proj_path, remediation, content):
|
||||
name = remediation.get('name', None) or 'insights-remediation'
|
||||
name = re.sub(r'[^\w\s-]', '', name).strip().lower()
|
||||
@@ -50,11 +50,7 @@ class ActionModule(ActionBase):
|
||||
session.auth = requests.auth.HTTPBasicAuth(username, password)
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': '{} {} ({})'.format(
|
||||
'AWX' if license == 'open' else 'Red Hat Ansible Tower',
|
||||
awx_version,
|
||||
license
|
||||
)
|
||||
'User-Agent': '{} {} ({})'.format('AWX' if license == 'open' else 'Red Hat Ansible Tower', awx_version, license),
|
||||
}
|
||||
url = '/api/remediations/v1/remediations'
|
||||
while url:
|
||||
@@ -62,9 +58,8 @@ class ActionModule(ActionBase):
|
||||
|
||||
if res.status_code != 200:
|
||||
result['failed'] = True
|
||||
result['msg'] = (
|
||||
'Expected {} to return a status code of 200 but returned status '
|
||||
'code "{}" instead with content "{}".'.format(url, res.status_code, res.content)
|
||||
result['msg'] = 'Expected {} to return a status code of 200 but returned status ' 'code "{}" instead with content "{}".'.format(
|
||||
url, res.status_code, res.content
|
||||
)
|
||||
return result
|
||||
|
||||
@@ -86,17 +81,14 @@ class ActionModule(ActionBase):
|
||||
url = res.json()['links']['next'] # will be None if we're on the last page
|
||||
|
||||
for item in res.json()['data']:
|
||||
playbook_url = '{}/api/remediations/v1/remediations/{}/playbook'.format(
|
||||
insights_url, item['id'])
|
||||
playbook_url = '{}/api/remediations/v1/remediations/{}/playbook'.format(insights_url, item['id'])
|
||||
res = session.get(playbook_url, timeout=120)
|
||||
if res.status_code == 204:
|
||||
continue
|
||||
elif res.status_code != 200:
|
||||
result['failed'] = True
|
||||
result['msg'] = (
|
||||
'Expected {} to return a status code of 200 but returned status '
|
||||
'code "{}" instead with content "{}".'.format(
|
||||
playbook_url, res.status_code, res.content)
|
||||
result['msg'] = 'Expected {} to return a status code of 200 but returned status ' 'code "{}" instead with content "{}".'.format(
|
||||
playbook_url, res.status_code, res.content
|
||||
)
|
||||
return result
|
||||
self.save_playbook(proj_path, item, res.content)
|
||||
|
||||
@@ -45,9 +45,7 @@ class ActionModule(ActionBase):
|
||||
# Most well formed archives contain a single root directory, typically named
|
||||
# project-name-1.0.0. The project contents should be inside that directory.
|
||||
start_index = 0
|
||||
root_contents = set(
|
||||
[filename.split(os.path.sep)[0] for filename in get_filenames()]
|
||||
)
|
||||
root_contents = set([filename.split(os.path.sep)[0] for filename in get_filenames()])
|
||||
if len(root_contents) == 1:
|
||||
start_index = len(list(root_contents)[0]) + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user