flake8 fixes

This commit is contained in:
Chris Meyers
2015-04-03 14:55:37 -04:00
parent f5600be39e
commit a769af0e83
8 changed files with 53 additions and 59 deletions

View File

@@ -3,16 +3,12 @@
import logging import logging
from datetime import datetime from datetime import datetime
import json
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from awx.main.models import * # noqa from awx.main.models import * # noqa
from awx.main.socket import Socket from awx.main.socket import Socket
import pymongo
from pymongo import MongoClient
_MODULES = ['packages', 'services', 'files'] _MODULES = ['packages', 'services', 'files']
logger = logging.getLogger('awx.main.commands.run_fact_cache_receiver') logger = logging.getLogger('awx.main.commands.run_fact_cache_receiver')
@@ -49,10 +45,10 @@ class FactCacheReceiver(object):
try: try:
host = FactHost.objects.get(hostname=hostname) host = FactHost.objects.get(hostname=hostname)
except FactHost.DoesNotExist as e: except FactHost.DoesNotExist:
host = FactHost(hostname=hostname) host = FactHost(hostname=hostname)
host.save() host.save()
except FactHost.MultipleObjectsReturned as e: except FactHost.MultipleObjectsReturned:
query = "db['fact_host'].find(hostname=%s)" % hostname query = "db['fact_host'].find(hostname=%s)" % hostname
print('Database inconsistent. Multiple FactHost "%s" exist. Try the query %s to find the records.' % (hostname, query)) print('Database inconsistent. Multiple FactHost "%s" exist. Try the query %s to find the records.' % (hostname, query))
return return

View File

@@ -49,7 +49,7 @@ class MongoDBRequired(django.test.TestCase):
try: try:
self.db = get_db() self.db = get_db()
self.db.connection.drop_database(settings.MONGO_DB) self.db.connection.drop_database(settings.MONGO_DB)
except ConnectionError as e: except ConnectionError:
self.skipTest('MongoDB connection failed') self.skipTest('MongoDB connection failed')
class QueueTestMixin(object): class QueueTestMixin(object):

View File

@@ -5,16 +5,15 @@
import time import time
from datetime import datetime from datetime import datetime
import mock import mock
import json
import unittest import unittest
from copy import deepcopy from copy import deepcopy
from mock import Mock, MagicMock from mock import MagicMock
# AWX # AWX
from awx.main.tests.base import BaseTest, MongoDBRequired from awx.main.tests.base import BaseTest, MongoDBRequired
from awx.main.tests.commands.base import BaseCommandMixin from awx.main.tests.commands.base import BaseCommandMixin
from awx.main.management.commands.run_fact_cache_receiver import FactCacheReceiver, _MODULES from awx.main.management.commands.run_fact_cache_receiver import FactCacheReceiver
from awx.main.models.fact import * from awx.main.models.fact import * # noqa
__all__ = ['RunFactCacheReceiverUnitTest', 'RunFactCacheReceiverFunctionalTest'] __all__ = ['RunFactCacheReceiverUnitTest', 'RunFactCacheReceiverFunctionalTest']

View File

@@ -3,7 +3,6 @@
# Python # Python
from datetime import datetime from datetime import datetime
from mongoengine.connection import get_db
from mongoengine import connect from mongoengine import connect
# Django # Django
@@ -11,7 +10,7 @@ from django.conf import settings
# AWX # AWX
from awx.main.tests.base import BaseTest, MongoDBRequired from awx.main.tests.base import BaseTest, MongoDBRequired
from awx.main.models.fact import * from awx.main.models.fact import * # noqa
__all__ = ['DBTransformTest'] __all__ = ['DBTransformTest']

View File

@@ -7,7 +7,7 @@ from datetime import datetime
# Django # Django
# AWX # AWX
from awx.main.models.fact import * from awx.main.models.fact import * # noqa
from awx.main.tests.base import BaseTest, MongoDBRequired from awx.main.tests.base import BaseTest, MongoDBRequired
__all__ = ['FactHostTest', 'FactTest'] __all__ = ['FactHostTest', 'FactTest']