mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-16 03:48:37 -05:00
Fixing flake8 errors, this should be almost all of them!
This commit is contained in:
+15
-15
@@ -2,19 +2,19 @@
|
||||
# All Rights Reserved.
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
|
||||
# AWX
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.unified_jobs import *
|
||||
from awx.main.models.organization import *
|
||||
from awx.main.models.credential import *
|
||||
from awx.main.models.projects import *
|
||||
from awx.main.models.inventory import *
|
||||
from awx.main.models.jobs import *
|
||||
from awx.main.models.schedules import *
|
||||
from awx.main.models.activity_stream import *
|
||||
from awx.main.models.ha import *
|
||||
from awx.main.models.base import * # noqa
|
||||
from awx.main.models.unified_jobs import * # noqa
|
||||
from awx.main.models.organization import * # noqa
|
||||
from awx.main.models.credential import * # noqa
|
||||
from awx.main.models.projects import * # noqa
|
||||
from awx.main.models.inventory import * # noqa
|
||||
from awx.main.models.jobs import * # noqa
|
||||
from awx.main.models.schedules import * # noqa
|
||||
from awx.main.models.activity_stream import * # noqa
|
||||
from awx.main.models.ha import * # noqa
|
||||
|
||||
# Monkeypatch Django serializer to ignore django-taggit fields (which break
|
||||
# the dumpdata command; see https://github.com/alex/django-taggit/issues/155).
|
||||
@@ -29,15 +29,15 @@ def _new_handle_m2m_field(self, obj, field):
|
||||
_PythonSerializer.handle_m2m_field = _new_handle_m2m_field
|
||||
|
||||
# Add custom methods to User model for permissions checks.
|
||||
from django.contrib.auth.models import User
|
||||
from awx.main.access import *
|
||||
from django.contrib.auth.models import User # noqa
|
||||
from awx.main.access import * # noqa
|
||||
User.add_to_class('get_queryset', get_user_queryset)
|
||||
User.add_to_class('can_access', check_user_access)
|
||||
|
||||
# Import signal handlers only after models have been defined.
|
||||
import awx.main.signals
|
||||
import awx.main.signals # noqa
|
||||
|
||||
from awx.main.registrar import activity_stream_registrar
|
||||
from awx.main.registrar import activity_stream_registrar # noqa
|
||||
activity_stream_registrar.connect(Organization)
|
||||
activity_stream_registrar.connect(Inventory)
|
||||
activity_stream_registrar.connect(Host)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# All Rights Reserved.
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -9,25 +9,14 @@ import shlex
|
||||
import yaml
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db.models import signals
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
|
||||
# Django-JSONField
|
||||
from jsonfield import JSONField
|
||||
|
||||
# Django-Polymorphic
|
||||
from polymorphic import PolymorphicModel
|
||||
|
||||
# Django-Taggit
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
# Django-Celery
|
||||
from djcelery.models import TaskMeta
|
||||
|
||||
# Django-CRUM
|
||||
from crum import get_current_user
|
||||
|
||||
|
||||
@@ -6,17 +6,15 @@ import base64
|
||||
import re
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
# AWX
|
||||
from awx.main import storage
|
||||
from awx.main.constants import CLOUD_PROVIDERS
|
||||
from awx.main.utils import decrypt_field
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.base import * # noqa
|
||||
|
||||
__all__ = ['Credential']
|
||||
|
||||
|
||||
@@ -3,37 +3,27 @@
|
||||
|
||||
# Python
|
||||
import datetime
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import uuid
|
||||
import copy
|
||||
import random
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models, connection
|
||||
from django.db.models import Q
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.db import transaction
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.timezone import now, make_aware, get_default_timezone
|
||||
from django.core.cache import cache
|
||||
from django.utils.timezone import now
|
||||
|
||||
# AWX
|
||||
from awx.main.constants import CLOUD_PROVIDERS
|
||||
from awx.main.fields import AutoOneToOneField
|
||||
from awx.main.managers import HostManager
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.base import * # noqa
|
||||
from awx.main.models.jobs import Job
|
||||
from awx.main.models.unified_jobs import *
|
||||
from awx.main.utils import encrypt_field, ignore_inventory_computed_fields, _inventory_updates
|
||||
from awx.main.models.unified_jobs import * # noqa
|
||||
from awx.main.utils import ignore_inventory_computed_fields, _inventory_updates
|
||||
|
||||
__all__ = ['Inventory', 'Host', 'Group', 'InventorySource', 'InventoryUpdate', 'CustomInventoryScript']
|
||||
|
||||
@@ -220,7 +210,7 @@ class Inventory(CommonModel):
|
||||
group_hosts_map = self.get_group_hosts_map(active=True)
|
||||
active_host_pks = set(self.hosts.filter(active=True).values_list('pk', flat=True))
|
||||
failed_host_pks = set(self.hosts.filter(active=True, last_job_host_summary__job__active=True, last_job_host_summary__failed=True).values_list('pk', flat=True))
|
||||
active_group_pks = set(self.groups.filter(active=True).values_list('pk', flat=True))
|
||||
# active_group_pks = set(self.groups.filter(active=True).values_list('pk', flat=True))
|
||||
failed_group_pks = set() # Update below as we check each group.
|
||||
groups_with_cloud_pks = set(self.groups.filter(active=True, inventory_sources__active=True, inventory_sources__source__in=CLOUD_INVENTORY_SOURCES).values_list('pk', flat=True))
|
||||
groups_to_update = {}
|
||||
@@ -539,7 +529,7 @@ class Group(CommonModelNameNotUnique):
|
||||
|
||||
@transaction.atomic
|
||||
def mark_inactive_recursive(self):
|
||||
from awx.main.tasks import update_inventory_computed_fields, bulk_inventory_element_delete
|
||||
from awx.main.tasks import bulk_inventory_element_delete
|
||||
from awx.main.utils import ignore_inventory_computed_fields
|
||||
from awx.main.signals import disable_activity_stream
|
||||
|
||||
|
||||
+5
-20
@@ -2,43 +2,28 @@
|
||||
# All Rights Reserved.
|
||||
|
||||
# Python
|
||||
import datetime
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import uuid
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.timezone import now, make_aware, get_default_timezone
|
||||
|
||||
# Django-JSONField
|
||||
from jsonfield import JSONField
|
||||
|
||||
# Django-Polymorphic
|
||||
from polymorphic import PolymorphicModel
|
||||
|
||||
# AWX
|
||||
from awx.main.constants import CLOUD_PROVIDERS
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.unified_jobs import *
|
||||
from awx.main.utils import encrypt_field, decrypt_field, ignore_inventory_computed_fields
|
||||
from awx.main.models.base import * # noqa
|
||||
from awx.main.models.unified_jobs import * # noqa
|
||||
from awx.main.utils import decrypt_field, ignore_inventory_computed_fields
|
||||
from awx.main.utils import emit_websocket_notification
|
||||
|
||||
# Celery
|
||||
from celery import chain
|
||||
|
||||
logger = logging.getLogger('awx.main.models.jobs')
|
||||
|
||||
__all__ = ['JobTemplate', 'Job', 'JobHostSummary', 'JobEvent', 'SystemJobOptions', 'SystemJobTemplate', 'SystemJob']
|
||||
@@ -434,7 +419,7 @@ class Job(UnifiedJob, JobOptions):
|
||||
# running this job (via callback inventory refresh).
|
||||
try:
|
||||
start_args = json.loads(decrypt_field(self, 'start_args'))
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
start_args = None
|
||||
start_args = start_args or {}
|
||||
inventory_sources_already_updated = start_args.get('inventory_sources_already_updated', [])
|
||||
|
||||
@@ -10,14 +10,13 @@ import uuid
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.timezone import now
|
||||
|
||||
# AWX
|
||||
from awx.main.fields import AutoOneToOneField
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.base import * # noqa
|
||||
|
||||
__all__ = ['Organization', 'Team', 'Permission', 'Profile', 'AuthToken']
|
||||
|
||||
|
||||
@@ -3,34 +3,25 @@
|
||||
|
||||
# Python
|
||||
import datetime
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import urlparse
|
||||
import uuid
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db.models import CASCADE, SET_NULL, PROTECT
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import smart_str
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.timezone import now, make_aware, get_default_timezone
|
||||
|
||||
# AWX
|
||||
from awx.lib.compat import slugify
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.base import * # noqa
|
||||
from awx.main.models.jobs import Job
|
||||
from awx.main.models.unified_jobs import *
|
||||
from awx.main.models.unified_jobs import * # noqa
|
||||
from awx.main.utils import update_scm_url
|
||||
from awx.main.utils import encrypt_field
|
||||
|
||||
__all__ = ['Project', 'ProjectUpdate']
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.utils.timezone import now, make_aware, get_default_timezone
|
||||
from jsonfield import JSONField
|
||||
|
||||
# AWX
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.base import * # noqa
|
||||
from awx.main.utils import ignore_inventory_computed_fields, emit_websocket_notification
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import codecs
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import shlex
|
||||
import os
|
||||
import os.path
|
||||
from StringIO import StringIO
|
||||
@@ -14,9 +13,7 @@ from StringIO import StringIO
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db import transaction
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import NON_FIELD_ERRORS
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
@@ -31,9 +28,9 @@ from polymorphic import PolymorphicModel
|
||||
from djcelery.models import TaskMeta
|
||||
|
||||
# AWX
|
||||
from awx.main.models.base import *
|
||||
from awx.main.models.base import * # noqa
|
||||
from awx.main.models.schedules import Schedule
|
||||
from awx.main.utils import decrypt_field, get_type_for_model, emit_websocket_notification, _inventory_updates
|
||||
from awx.main.utils import decrypt_field, emit_websocket_notification, _inventory_updates
|
||||
from awx.main.redact import UriCleaner
|
||||
|
||||
__all__ = ['UnifiedJobTemplate', 'UnifiedJob']
|
||||
@@ -597,7 +594,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
if self.result_stdout_file != "":
|
||||
try:
|
||||
os.remove(self.result_stdout_file)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
pass
|
||||
super(UnifiedJob, self).delete()
|
||||
|
||||
@@ -713,7 +710,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
needed = self.get_passwords_needed_to_start()
|
||||
try:
|
||||
start_args = json.loads(decrypt_field(self, 'start_args'))
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
start_args = None
|
||||
if start_args in (None, ''):
|
||||
start_args = kwargs
|
||||
@@ -756,10 +753,10 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
|
||||
# Each type of unified job has a different Task class; get the
|
||||
# appropirate one.
|
||||
task_type = get_type_for_model(self)
|
||||
# task_type = get_type_for_model(self)
|
||||
|
||||
# Actually tell the task runner to run this task.
|
||||
# NOTE: This will deadlock the task runner
|
||||
# FIXME: This will deadlock the task runner
|
||||
#from awx.main.tasks import notify_task_runner
|
||||
#notify_task_runner.delay({'id': self.id, 'metadata': kwargs,
|
||||
# 'task_type': task_type})
|
||||
|
||||
Reference in New Issue
Block a user