Browse Source

HUE-2525 [core] Fix manual install of samples

Romain Rigaux 11 năm trước cách đây
mục cha
commit
0ff5c60

+ 0 - 1
apps/about/src/about/views.py

@@ -15,7 +15,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import json
 import logging
 

+ 21 - 11
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -17,23 +17,26 @@
 
 import logging
 import os
+import pwd
 import simplejson
 
-from django.core.management.base import NoArgsCommand
+from django.core.management.base import BaseCommand
 from django.contrib.auth.models import User
 from django.utils.translation import ugettext as _
 
-from desktop.models import Document
 from hadoop import cluster
 
+from desktop.lib.exceptions_renderable import PopupException
+from useradmin.models import install_sample_user
+from desktop.models import Document
+
 import beeswax.conf
 
 from beeswax.models import SavedQuery, IMPALA
 from beeswax.design import hql_query
 from beeswax.server import dbms
 from beeswax.server.dbms import get_query_server_config, QueryServerException
-from useradmin.models import install_sample_user
-from desktop.lib.exceptions_renderable import PopupException
+
 
 LOG = logging.getLogger(__name__)
 
@@ -42,18 +45,25 @@ class InstallException(Exception):
   pass
 
 
-class Command(NoArgsCommand):
-  """
-  Install examples but do not overwrite them.
-  """
-  def handle_noargs(self, **options):
+class Command(BaseCommand):
+  args = '<beeswax|impala>'
+  help = 'Install examples but do not overwrite them.'
+
+  def handle(self, *args, **options):
+    if args:
+      app_name = args[0]
+      user = User.objects.get(username=pwd.getpwuid(os.getuid()).pw_name)
+    else:
+      app_name = options['app_name']
+      user = options['user']
+
     exception = None
 
     # Documents will belong to this user but we run the install as the current user
     try:
       sample_user = install_sample_user()
-      self._install_queries(sample_user, options['app_name'])
-      self._install_tables(options['user'], options['app_name'])
+      self._install_queries(sample_user, app_name)
+      self._install_tables(user, app_name)
     except Exception, ex:
       exception = ex
 

+ 1 - 1
apps/beeswax/src/beeswax/views.py

@@ -568,7 +568,7 @@ def install_examples(request):
   if request.method == 'POST':
     try:
       app_name = get_app_name(request)
-      beeswax.management.commands.beeswax_install_examples.Command().handle_noargs(app_name=app_name, user=request.user)
+      beeswax.management.commands.beeswax_install_examples.Command().handle(app_name=app_name, user=request.user)
       response['status'] = 0
     except Exception, err:
       LOG.exception(err)

+ 16 - 0
apps/hbase/gen-py/__init__.py

@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 5 - 0
apps/hbase/src/hbase/__init__.py

@@ -13,3 +13,8 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
+import sys
+import os
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'gen-py'))

+ 15 - 0
apps/hbase/src/hbase/management/__init__.py

@@ -0,0 +1,15 @@
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 16 - 0
apps/hbase/src/hbase/management/commands/__init__.py

@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 1 - 3
apps/hbase/src/hbase/server/hbase_lib.py

@@ -16,15 +16,13 @@
 # limitations under the License.
 
 import logging
-import sys,os
+import os
 
 from thrift import Thrift
 from thrift.transport.TSocket import TSocket
 from thrift.transport.TTransport import TBufferedTransport
 from thrift.protocol import TBinaryProtocol
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '../../../gen-py'))
-
 from hbased import Hbase as thrift_hbase
 from hbased import ttypes