mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
[PR #9321/c3ed2144 backport][stable-10] callback plugins: use f-strings (#9357)
callback plugins: use f-strings (#9321)
* callback plugins: use f-strings
* add changelog frag
* manual change for few occurrences
* manual change for few occurrences
* adjustment from review
* adjustment from review
* adjustment from review
* Update plugins/callback/splunk.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* replace str templating with JSON templating
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit c3ed2144e2
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
a13a6d284c
commit
3c7f05c42d
22 changed files with 251 additions and 253 deletions
|
@ -118,7 +118,7 @@ class TaskData:
|
|||
if host.uuid in self.host_data:
|
||||
if host.status == 'included':
|
||||
# concatenate task include output from multiple items
|
||||
host.result = '%s\n%s' % (self.host_data[host.uuid].result, host.result)
|
||||
host.result = f'{self.host_data[host.uuid].result}\n{host.result}'
|
||||
else:
|
||||
return
|
||||
|
||||
|
@ -166,7 +166,7 @@ class ElasticSource(object):
|
|||
args = None
|
||||
|
||||
if not task.no_log and not hide_task_arguments:
|
||||
args = ', '.join(('%s=%s' % a for a in task.args.items()))
|
||||
args = ', '.join((f'{k}={v}' for k, v in task.args.items()))
|
||||
|
||||
tasks_data[uuid] = TaskData(uuid, name, path, play_name, action, args)
|
||||
|
||||
|
@ -225,7 +225,7 @@ class ElasticSource(object):
|
|||
def create_span_data(self, apm_cli, task_data, host_data):
|
||||
""" create the span with the given TaskData and HostData """
|
||||
|
||||
name = '[%s] %s: %s' % (host_data.name, task_data.play, task_data.name)
|
||||
name = f'[{host_data.name}] {task_data.play}: {task_data.name}'
|
||||
|
||||
message = "success"
|
||||
status = "success"
|
||||
|
@ -259,7 +259,7 @@ class ElasticSource(object):
|
|||
"ansible.task.host.status": host_data.status}) as span:
|
||||
span.outcome = status
|
||||
if 'failure' in status:
|
||||
exception = AnsibleRuntimeError(message="{0}: {1} failed with error message {2}".format(task_data.action, name, enriched_error_message))
|
||||
exception = AnsibleRuntimeError(message=f"{task_data.action}: {name} failed with error message {enriched_error_message}")
|
||||
apm_cli.capture_exception(exc_info=(type(exception), exception, exception.__traceback__), handled=True)
|
||||
|
||||
def init_apm_client(self, apm_server_url, apm_service_name, apm_verify_server_cert, apm_secret_token, apm_api_key):
|
||||
|
@ -288,7 +288,7 @@ class ElasticSource(object):
|
|||
message = result.get('msg', 'failed')
|
||||
exception = result.get('exception')
|
||||
stderr = result.get('stderr')
|
||||
return ('message: "{0}"\nexception: "{1}"\nstderr: "{2}"').format(message, exception, stderr)
|
||||
return f"message: \"{message}\"\nexception: \"{exception}\"\nstderr: \"{stderr}\""
|
||||
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue