mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 03:01:06 -03:30
Merge pull request #6730 from rooftopcellist/pyflake
Fix new flake8 from pyflakes 2.2.0 release Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -3668,7 +3668,7 @@ class LaunchConfigurationBaseSerializer(BaseSerializer):
|
|||||||
attrs.get('survey_passwords', {}).pop(key, None)
|
attrs.get('survey_passwords', {}).pop(key, None)
|
||||||
else:
|
else:
|
||||||
errors.setdefault('extra_vars', []).append(
|
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
|
# Launch configs call extra_vars extra_data for historical reasons
|
||||||
|
|||||||
@@ -172,9 +172,9 @@ class URLField(CharField):
|
|||||||
netloc = '{}:{}'.format(netloc, url_parts.port)
|
netloc = '{}:{}'.format(netloc, url_parts.port)
|
||||||
if url_parts.username:
|
if url_parts.username:
|
||||||
if url_parts.password:
|
if url_parts.password:
|
||||||
netloc = '{}:{}@{}' % (url_parts.username, url_parts.password, netloc)
|
netloc = '{}:{}@{}'.format(url_parts.username, url_parts.password, netloc)
|
||||||
else:
|
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])
|
value = urlparse.urlunsplit([url_parts.scheme, netloc, url_parts.path, url_parts.query, url_parts.fragment])
|
||||||
except Exception:
|
except Exception:
|
||||||
raise # If something fails here, just fall through and let the validators check it.
|
raise # If something fails here, just fall through and let the validators check it.
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ class SettingsWrapper(UserSettingsHolder):
|
|||||||
field = self.registry.get_setting_field(name)
|
field = self.registry.get_setting_field(name)
|
||||||
if field.read_only:
|
if field.read_only:
|
||||||
logger.warning('Attempt to set read only setting "%s".', name)
|
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:
|
try:
|
||||||
data = field.to_representation(value)
|
data = field.to_representation(value)
|
||||||
@@ -441,7 +441,7 @@ class SettingsWrapper(UserSettingsHolder):
|
|||||||
field = self.registry.get_setting_field(name)
|
field = self.registry.get_setting_field(name)
|
||||||
if field.read_only:
|
if field.read_only:
|
||||||
logger.warning('Attempt to delete read only setting "%s".', name)
|
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):
|
for setting in Setting.objects.filter(key=name, user__isnull=True):
|
||||||
setting.delete()
|
setting.delete()
|
||||||
# pre_delete handler will delete from cache.
|
# pre_delete handler will delete from cache.
|
||||||
|
|||||||
@@ -309,6 +309,6 @@ def copy_tables(since, full_path):
|
|||||||
main_unifiedjobtemplate.status
|
main_unifiedjobtemplate.status
|
||||||
FROM main_unifiedjobtemplate, django_content_type
|
FROM main_unifiedjobtemplate, django_content_type
|
||||||
WHERE main_unifiedjobtemplate.polymorphic_ctype_id = django_content_type.id
|
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)
|
_copy_table(table='unified_job_template', query=unified_job_template_query, path=full_path)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class Scheduler(Scheduler):
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
ppid = os.getppid()
|
ppid = os.getppid()
|
||||||
logger.warn(f'periodic beat started')
|
logger.warn('periodic beat started')
|
||||||
while True:
|
while True:
|
||||||
if os.getppid() != ppid:
|
if os.getppid() != ppid:
|
||||||
# if the parent PID changes, this process has been orphaned
|
# if the parent PID changes, this process has been orphaned
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ class AWXConsumerRedis(AWXConsumerBase):
|
|||||||
res = json.loads(res[1])
|
res = json.loads(res[1])
|
||||||
self.process_task(res)
|
self.process_task(res)
|
||||||
except redis.exceptions.RedisError:
|
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):
|
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:
|
if self.should_stop:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class CallbackBrokerWorker(BaseWorker):
|
|||||||
for e in events:
|
for e in events:
|
||||||
try:
|
try:
|
||||||
if (
|
if (
|
||||||
isinstance(exc, IntegrityError),
|
isinstance(exc, IntegrityError) and
|
||||||
getattr(e, 'host_id', '')
|
getattr(e, 'host_id', '')
|
||||||
):
|
):
|
||||||
# this is one potential IntegrityError we can
|
# this is one potential IntegrityError we can
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class SimpleDAG(object):
|
|||||||
self.root_nodes.discard(to_obj_ord)
|
self.root_nodes.discard(to_obj_ord)
|
||||||
|
|
||||||
if from_obj_ord is None and to_obj_ord is None:
|
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:
|
elif from_obj_ord is None:
|
||||||
raise LookupError("From object not found {}".format(from_obj))
|
raise LookupError("From object not found {}".format(from_obj))
|
||||||
elif to_obj_ord is None:
|
elif to_obj_ord is None:
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ class TaskManager():
|
|||||||
# non-Ansible jobs on isolated instances run on controller
|
# non-Ansible jobs on isolated instances run on controller
|
||||||
task.instance_group = rampart_group.controller
|
task.instance_group = rampart_group.controller
|
||||||
task.execution_node = random.choice(list(rampart_group.controller.instances.all().values_list('hostname', flat=True)))
|
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))
|
task.log_format, task.instance_group.name, task.execution_node))
|
||||||
elif controller_node:
|
elif controller_node:
|
||||||
task.instance_group = rampart_group
|
task.instance_group = rampart_group
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ def create_job_template(name, roles=None, persisted=True, webhook_service='', **
|
|||||||
if 'organization' in kwargs:
|
if 'organization' in kwargs:
|
||||||
org = kwargs['organization']
|
org = kwargs['organization']
|
||||||
if type(org) is not 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:
|
if 'credential' in kwargs:
|
||||||
cred = kwargs['credential']
|
cred = kwargs['credential']
|
||||||
@@ -298,7 +298,7 @@ def create_organization(name, roles=None, persisted=True, **kwargs):
|
|||||||
labels = {}
|
labels = {}
|
||||||
notification_templates = {}
|
notification_templates = {}
|
||||||
|
|
||||||
org = mk_organization(name, '%s-desc'.format(name), persisted=persisted)
|
org = mk_organization(name, name, persisted=persisted)
|
||||||
|
|
||||||
if 'inventories' in kwargs:
|
if 'inventories' in kwargs:
|
||||||
for i in kwargs['inventories']:
|
for i in kwargs['inventories']:
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
|
|||||||
# return job
|
# return job
|
||||||
jobs_pg = self.related.workflow_jobs.get(id=result.workflow_job)
|
jobs_pg = self.related.workflow_jobs.get(id=result.workflow_job)
|
||||||
if jobs_pg.count != 1:
|
if jobs_pg.count != 1:
|
||||||
msg = "workflow_job_template launched (id:{}) but job not found in response at {}/workflow_jobs/" % \
|
msg = "workflow_job_template launched (id:{}) but job not found in response at {}/workflow_jobs/".format(
|
||||||
(result.json['workflow_job'], self.url)
|
result.json['workflow_job'], self.url
|
||||||
|
)
|
||||||
raise exc.UnexpectedAWXState(msg)
|
raise exc.UnexpectedAWXState(msg)
|
||||||
return jobs_pg.results[0]
|
return jobs_pg.results[0]
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class URLRegistry(object):
|
|||||||
for url_pattern, method_pattern in url_iterable:
|
for url_pattern, method_pattern in url_iterable:
|
||||||
if url_pattern in self.store and method_pattern in self.store[url_pattern]:
|
if url_pattern in self.store and method_pattern in self.store[url_pattern]:
|
||||||
if method_pattern.pattern == not_provided:
|
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:
|
else:
|
||||||
exc_msg = ('"{0.pattern}" already has registered method "{1.pattern}"'
|
exc_msg = ('"{0.pattern}" already has registered method "{1.pattern}"'
|
||||||
.format(url_pattern, method_pattern))
|
.format(url_pattern, method_pattern))
|
||||||
|
|||||||
Reference in New Issue
Block a user