summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Adams <chadams@redhat.com>2020-04-16 16:13:09 +0200
committerChristian Adams <chadams@redhat.com>2020-04-20 15:50:50 +0200
commita899a147e19d1ebbc142cb0c789c74b0a2559db7 (patch)
tree461f236a9a76db5422655064ba2d1b0c3f55c31e
parentMerge pull request #6747 from chrismeyersfsu/fix-redis_logs (diff)
downloadawx-a899a147e19d1ebbc142cb0c789c74b0a2559db7.tar.xz
awx-a899a147e19d1ebbc142cb0c789c74b0a2559db7.zip
Fix new flake8 from pyflakes 2.2.0 release
-rw-r--r--awx/api/serializers.py2
-rw-r--r--awx/conf/fields.py4
-rw-r--r--awx/conf/settings.py4
-rw-r--r--awx/main/analytics/collectors.py2
-rw-r--r--awx/main/dispatch/periodic.py2
-rw-r--r--awx/main/dispatch/worker/base.py4
-rw-r--r--awx/main/dispatch/worker/callback.py2
-rw-r--r--awx/main/scheduler/dag_simple.py2
-rw-r--r--awx/main/scheduler/task_manager.py2
-rw-r--r--awx/main/tests/factories/tower.py4
-rw-r--r--awxkit/awxkit/api/pages/workflow_job_templates.py5
-rw-r--r--awxkit/awxkit/api/registry.py2
-rwxr-xr-xsetup.cfg2
13 files changed, 19 insertions, 18 deletions
diff --git a/awx/api/serializers.py b/awx/api/serializers.py
index 99d6b2f80d..3960790ce7 100644
--- a/awx/api/serializers.py
+++ b/awx/api/serializers.py
@@ -3668,7 +3668,7 @@ class LaunchConfigurationBaseSerializer(BaseSerializer):
attrs.get('survey_passwords', {}).pop(key, None)
else:
errors.setdefault('extra_vars', []).append(
- _('"$encrypted$ is a reserved keyword, may not be used for {var_name}."'.format(key))
+ _('"$encrypted$ is a reserved keyword, may not be used for {}."'.format(key))
)
# Launch configs call extra_vars extra_data for historical reasons
diff --git a/awx/conf/fields.py b/awx/conf/fields.py
index 4bc8128ef6..7c9a94969d 100644
--- a/awx/conf/fields.py
+++ b/awx/conf/fields.py
@@ -172,9 +172,9 @@ class URLField(CharField):
netloc = '{}:{}'.format(netloc, url_parts.port)
if url_parts.username:
if url_parts.password:
- netloc = '{}:{}@{}' % (url_parts.username, url_parts.password, netloc)
+ netloc = '{}:{}@{}'.format(url_parts.username, url_parts.password, netloc)
else:
- netloc = '{}@{}' % (url_parts.username, netloc)
+ netloc = '{}@{}'.format(url_parts.username, netloc)
value = urlparse.urlunsplit([url_parts.scheme, netloc, url_parts.path, url_parts.query, url_parts.fragment])
except Exception:
raise # If something fails here, just fall through and let the validators check it.
diff --git a/awx/conf/settings.py b/awx/conf/settings.py
index 4f227164cf..d650fdeba9 100644
--- a/awx/conf/settings.py
+++ b/awx/conf/settings.py
@@ -410,7 +410,7 @@ class SettingsWrapper(UserSettingsHolder):
field = self.registry.get_setting_field(name)
if field.read_only:
logger.warning('Attempt to set read only setting "%s".', name)
- raise ImproperlyConfigured('Setting "%s" is read only.'.format(name))
+ raise ImproperlyConfigured('Setting "{}" is read only.'.format(name))
try:
data = field.to_representation(value)
@@ -441,7 +441,7 @@ class SettingsWrapper(UserSettingsHolder):
field = self.registry.get_setting_field(name)
if field.read_only:
logger.warning('Attempt to delete read only setting "%s".', name)
- raise ImproperlyConfigured('Setting "%s" is read only.'.format(name))
+ raise ImproperlyConfigured('Setting "{}" is read only.'.format(name))
for setting in Setting.objects.filter(key=name, user__isnull=True):
setting.delete()
# pre_delete handler will delete from cache.
diff --git a/awx/main/analytics/collectors.py b/awx/main/analytics/collectors.py
index ff94965e7e..852d6a71ec 100644
--- a/awx/main/analytics/collectors.py
+++ b/awx/main/analytics/collectors.py
@@ -309,6 +309,6 @@ def copy_tables(since, full_path):
main_unifiedjobtemplate.status
FROM main_unifiedjobtemplate, django_content_type
WHERE main_unifiedjobtemplate.polymorphic_ctype_id = django_content_type.id
- ORDER BY main_unifiedjobtemplate.id ASC) TO STDOUT WITH CSV HEADER'''.format(since.strftime("'%Y-%m-%d %H:%M:%S'"))
+ ORDER BY main_unifiedjobtemplate.id ASC) TO STDOUT WITH CSV HEADER'''
_copy_table(table='unified_job_template', query=unified_job_template_query, path=full_path)
return
diff --git a/awx/main/dispatch/periodic.py b/awx/main/dispatch/periodic.py
index 2ad6f7119c..c76366a8d4 100644
--- a/awx/main/dispatch/periodic.py
+++ b/awx/main/dispatch/periodic.py
@@ -22,7 +22,7 @@ class Scheduler(Scheduler):
def run():
ppid = os.getppid()
- logger.warn(f'periodic beat started')
+ logger.warn('periodic beat started')
while True:
if os.getppid() != ppid:
# if the parent PID changes, this process has been orphaned
diff --git a/awx/main/dispatch/worker/base.py b/awx/main/dispatch/worker/base.py
index f3d46e9e12..74d2a6a6c3 100644
--- a/awx/main/dispatch/worker/base.py
+++ b/awx/main/dispatch/worker/base.py
@@ -123,9 +123,9 @@ class AWXConsumerRedis(AWXConsumerBase):
res = json.loads(res[1])
self.process_task(res)
except redis.exceptions.RedisError:
- logger.exception(f"encountered an error communicating with redis")
+ logger.exception("encountered an error communicating with redis")
except (json.JSONDecodeError, KeyError):
- logger.exception(f"failed to decode JSON message from redis")
+ logger.exception("failed to decode JSON message from redis")
if self.should_stop:
return
diff --git a/awx/main/dispatch/worker/callback.py b/awx/main/dispatch/worker/callback.py
index a38e145de2..1314f33f7c 100644
--- a/awx/main/dispatch/worker/callback.py
+++ b/awx/main/dispatch/worker/callback.py
@@ -91,7 +91,7 @@ class CallbackBrokerWorker(BaseWorker):
for e in events:
try:
if (
- isinstance(exc, IntegrityError),
+ isinstance(exc, IntegrityError) and
getattr(e, 'host_id', '')
):
# this is one potential IntegrityError we can
diff --git a/awx/main/scheduler/dag_simple.py b/awx/main/scheduler/dag_simple.py
index af6a819914..065983577a 100644
--- a/awx/main/scheduler/dag_simple.py
+++ b/awx/main/scheduler/dag_simple.py
@@ -123,7 +123,7 @@ class SimpleDAG(object):
self.root_nodes.discard(to_obj_ord)
if from_obj_ord is None and to_obj_ord is None:
- raise LookupError("From object {} and to object not found".format(from_obj, to_obj))
+ raise LookupError("From object {} and to object {} not found".format(from_obj, to_obj))
elif from_obj_ord is None:
raise LookupError("From object not found {}".format(from_obj))
elif to_obj_ord is None:
diff --git a/awx/main/scheduler/task_manager.py b/awx/main/scheduler/task_manager.py
index 9cd0aa1db9..97a429a415 100644
--- a/awx/main/scheduler/task_manager.py
+++ b/awx/main/scheduler/task_manager.py
@@ -226,7 +226,7 @@ class TaskManager():
# non-Ansible jobs on isolated instances run on controller
task.instance_group = rampart_group.controller
task.execution_node = random.choice(list(rampart_group.controller.instances.all().values_list('hostname', flat=True)))
- logger.debug('Submitting isolated {} to queue {}.'.format(
+ logger.debug('Submitting isolated {} to queue {} on node {}.'.format(
task.log_format, task.instance_group.name, task.execution_node))
elif controller_node:
task.instance_group = rampart_group
diff --git a/awx/main/tests/factories/tower.py b/awx/main/tests/factories/tower.py
index bfa7f9fc1b..1da5f126f9 100644
--- a/awx/main/tests/factories/tower.py
+++ b/awx/main/tests/factories/tower.py
@@ -220,7 +220,7 @@ def create_job_template(name, roles=None, persisted=True, webhook_service='', **
if 'organization' in kwargs:
org = kwargs['organization']
if type(org) is not Organization:
- org = mk_organization(org, '%s-desc'.format(org), persisted=persisted)
+ org = mk_organization(org, org, persisted=persisted)
if 'credential' in kwargs:
cred = kwargs['credential']
@@ -298,7 +298,7 @@ def create_organization(name, roles=None, persisted=True, **kwargs):
labels = {}
notification_templates = {}
- org = mk_organization(name, '%s-desc'.format(name), persisted=persisted)
+ org = mk_organization(name, name, persisted=persisted)
if 'inventories' in kwargs:
for i in kwargs['inventories']:
diff --git a/awxkit/awxkit/api/pages/workflow_job_templates.py b/awxkit/awxkit/api/pages/workflow_job_templates.py
index 8814a13d59..6a28891e04 100644
--- a/awxkit/awxkit/api/pages/workflow_job_templates.py
+++ b/awxkit/awxkit/api/pages/workflow_job_templates.py
@@ -25,8 +25,9 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
# return job
jobs_pg = self.related.workflow_jobs.get(id=result.workflow_job)
if jobs_pg.count != 1:
- msg = "workflow_job_template launched (id:{}) but job not found in response at {}/workflow_jobs/" % \
- (result.json['workflow_job'], self.url)
+ msg = "workflow_job_template launched (id:{}) but job not found in response at {}/workflow_jobs/".format(
+ result.json['workflow_job'], self.url
+ )
raise exc.UnexpectedAWXState(msg)
return jobs_pg.results[0]
diff --git a/awxkit/awxkit/api/registry.py b/awxkit/awxkit/api/registry.py
index a3d066ca4d..67d6bb23b8 100644
--- a/awxkit/awxkit/api/registry.py
+++ b/awxkit/awxkit/api/registry.py
@@ -79,7 +79,7 @@ class URLRegistry(object):
for url_pattern, method_pattern in url_iterable:
if url_pattern in self.store and method_pattern in self.store[url_pattern]:
if method_pattern.pattern == not_provided:
- exc_msg = '"{0.pattern}" already has methodless registration.'.format(url_pattern, method_pattern)
+ exc_msg = '"{0.pattern}" already has methodless registration.'.format(url_pattern)
else:
exc_msg = ('"{0.pattern}" already has registered method "{1.pattern}"'
.format(url_pattern, method_pattern))
diff --git a/setup.cfg b/setup.cfg
index 9dc6f6636d..4b1e22709e 100755
--- a/setup.cfg
+++ b/setup.cfg
@@ -25,5 +25,5 @@ deps =
flake8
yamllint
commands =
- flake8
+ make flake8
yamllint -s .