Explorar o código

HUE-8737 [core] Futurize apps/search for Python 3.5

Ying Chen %!s(int64=6) %!d(string=hai) anos
pai
achega
1348771c90

+ 4 - 3
apps/search/src/search/controller.py

@@ -15,6 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from builtins import object
 import logging
 
 from libsolr.api import SolrApi
@@ -43,16 +44,16 @@ class SearchController(object):
   def get_all_indexes(self, show_all=False):
     indexes = []
     try:
-      indexes = self.get_solr_collections().keys()
+      indexes = list(self.get_solr_collections().keys())
     except:
       LOG.exception('failed to get indexes')
 
     try:
-      indexes += SolrApi(SOLR_URL.get(), self.user).aliases().keys()
+      indexes += list(SolrApi(SOLR_URL.get(), self.user).aliases().keys())
     except:
       LOG.exception('failed to get index aliases')
 
     if show_all or not indexes:
-      return indexes + SolrApi(SOLR_URL.get(), self.user).cores().keys()
+      return indexes + list(SolrApi(SOLR_URL.get(), self.user).cores().keys())
     else:
       return indexes

+ 3 - 2
apps/search/src/search/models.py

@@ -15,6 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from builtins import str
 import json
 import logging
 import re
@@ -255,7 +256,7 @@ class Collection(models.Model):
       if self.cores != '{}': # Convert collections from < Hue 3.6
         try:
           self._import_hue_3_5_collections(props, user)
-        except Exception, e:
+        except Exception as e:
           LOG.error('Could not import collection: %s' % e)
 
     if 'layout' not in props:
@@ -364,7 +365,7 @@ class Collection(models.Model):
     schema_fields = SolrApi(SOLR_URL.get(), user).fields(self.name)
     schema_fields = schema_fields['schema']['fields']
 
-    return sorted([self._make_field(field, attributes) for field, attributes in schema_fields.iteritems()])
+    return sorted([self._make_field(field, attributes) for field, attributes in schema_fields.items()])
 
   @property
   def properties_dict(self):

+ 2 - 1
apps/search/src/search/tests.py

@@ -16,6 +16,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from builtins import object
 import json
 
 from django.contrib.auth.models import User
@@ -44,7 +45,7 @@ def test_ranges():
   assert_equal((8000000, 9000000), _round_number_range(9045352))
 
 
-class MockResource():
+class MockResource(object):
   RESPONSE = None
 
   def __init__(self, client):

+ 2 - 1
apps/search/src/search/views.py

@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from builtins import str
 import logging
 
 from django.utils.translation import ugettext as _
@@ -45,7 +46,7 @@ def install_examples(request):
       if 'log_analytics_demo' == data: # Hue documents installed only one time
         search_setup.Command().handle()
       result['status'] = 0
-    except Exception, e:
+    except Exception as e:
       LOG.exception(e)
       result['message'] = str(e)