Procházet zdrojové kódy

[kafka] Small style clean-up of the current lib

Romain před 5 roky
rodič
revize
7a702350fb

+ 7 - 6
desktop/libs/kafka/src/kafka/kafka_api.py

@@ -16,14 +16,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from __future__ import print_function
 import json
 import logging
 
-from django.http import Http404
-from django.utils.html import escape
 from django.utils.translation import ugettext as _
-from django.views.decorators.http import require_POST
 
 from desktop.lib.django_util import JsonResponse
 from desktop.lib.i18n import force_unicode
@@ -63,7 +59,9 @@ def error_handler(view_fn):
 def list_topics(request):
   return JsonResponse({
     'status': 0,
-    'topics': [{'name': topic} for topic in get_topics()]
+    'topics': [
+      {'name': topic} for topic in get_topics()
+    ]
   })
 
 
@@ -106,7 +104,10 @@ def get_topics():
     try:
       manager = ManagerApi()
       broker_host = manager.get_kafka_brokers().split(',')[0].split(':')[0]
-      return [name for name in list(manager.get_kafka_topics(broker_host).keys()) if not name.startswith('__')]
+      return [
+        name
+        for name in list(manager.get_kafka_topics(broker_host).keys()) if not name.startswith('__')
+      ]
     except Exception as e:
       return ['user_behavior']
 

+ 3 - 3
desktop/libs/kafka/src/kafka/kafka_client.py

@@ -22,7 +22,6 @@ import json
 
 from subprocess import call
 
-from django.core.cache import cache
 from django.utils.translation import ugettext as _
 
 from desktop.lib.rest.http_client import RestException, HttpClient
@@ -71,9 +70,10 @@ class KafkaApi(object):
   def create_topic(self, name, partitions=1, replication_factor=1):
     # Create/delete topics are not available in the REST API.
     # Here only works with hack if command is available on the Hue host.
-    try:      
+    try:
       return call(
-        'kafka-topics --zookeeper %(zookeeper)s --create --if-not-exists --topic %(name)s --partitions %(partitions)s --replication-factor %(replication_factor)s' % {
+        'kafka-topics --zookeeper %(zookeeper)s --create --if-not-exists --topic %(name)s --partitions %(partitions)s '
+        '--replication-factor %(replication_factor)s' % {
            'zookeeper': zkensemble(),
            'name': name,
            'partitions': partitions,

+ 2 - 2
desktop/libs/notebook/src/notebook/connectors/ksql.py

@@ -19,7 +19,6 @@ from __future__ import absolute_import
 
 import logging
 
-from django.core.urlresolvers import reverse
 from django.utils.translation import ugettext as _
 
 from desktop.lib.i18n import force_unicode
@@ -82,7 +81,8 @@ class KSqlApi(Api):
             'name': col['name'],
             'type': col['type'],
             'comment': ''
-          } for col in description
+          }
+          for col in description
         ] if has_result_set else [],
         'type': 'table'
       }