Browse Source

HUE-3287 [core] Django 1.11 upgrade
- Removing monkey patching for User
Adding handle_noargs changes

Prakash Ranade 7 years ago
parent
commit
5f9801f66e

+ 1 - 1
apps/oozie/src/oozie/management/commands/oozie_setup.py

@@ -328,7 +328,7 @@ class Command(BaseCommand):
     self._import_workflows(unmanaged_dir, managed=False)
 
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     self.user = install_sample_user()
     self.fs = cluster.get_hdfs()
 

+ 1 - 1
apps/oozie/src/oozie/views/editor.py

@@ -934,7 +934,7 @@ def install_examples(request):
     result['message'] = _('A POST request is required.')
   else:
     try:
-      oozie_setup.Command().handle_noargs()
+      oozie_setup.Command().handle()
       activate_translation(request.LANGUAGE_CODE)
       result['status'] = 0
     except Exception, e:

+ 1 - 1
apps/pig/src/pig/management/commands/pig_setup.py

@@ -96,7 +96,7 @@ STORE upper_case INTO '$output';
     return doc2
 
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     fs = cluster.get_hdfs()
     create_directories(fs, [REMOTE_SAMPLE_DIR.get()])
     remote_dir = REMOTE_SAMPLE_DIR.get()

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

@@ -246,7 +246,7 @@ def install_examples(request):
     result['message'] = _('A POST request is required.')
   else:
     try:
-      pig_setup.Command().handle_noargs()
+      pig_setup.Command().handle()
       result['status'] = 0
     except Exception, e:
       LOG.exception(e)

+ 1 - 1
apps/search/src/search/management/commands/search_setup.py

@@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
 
 
 class Command(BaseCommand):
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
 
     sample_user = install_sample_user()
 

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

@@ -41,7 +41,7 @@ def install_examples(request):
       data = request.POST.get('data')
       indexer_setup.Command().handle(data=data)
       if 'log_analytics_demo' == data: # Hue documents installed only one time
-        search_setup.Command().handle_noargs()
+        search_setup.Command().handle()
       result['status'] = 0
     except Exception, e:
       LOG.exception(e)

+ 1 - 1
apps/useradmin/src/useradmin/old_migrations/0008_convert_documents.py

@@ -16,7 +16,7 @@ class Migration(DataMigration):
         # the same time preventing such flaws. This migration is being done at
         # the useradmin level to avoid any dependency issues.
 
-        desktop.management.commands.convert_documents.Command().handle_noargs()
+        desktop.management.commands.convert_documents.Command().handle()
 
     def backwards(self, orm):
         "Write your backwards methods here."

+ 1 - 1
desktop/core/src/desktop/management/commands/config_dump.py

@@ -35,7 +35,7 @@ class Command(BaseCommand):
     self.indent = 0
 
   """Prints documentation for configuration."""
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     print _("Dumping configuration...")
     print
     self.recurse(desktop.lib.conf.GLOBAL_CONFIG)

+ 1 - 1
desktop/core/src/desktop/management/commands/config_help.py

@@ -19,5 +19,5 @@ import desktop.appmanager
 
 class Command(BaseCommand):
   """Prints documentation for configuration."""
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     desktop.lib.conf.GLOBAL_CONFIG.print_help(skip_header=True)

+ 1 - 1
desktop/core/src/desktop/management/commands/convert_documents.py

@@ -27,7 +27,7 @@ from desktop.converters import DocumentConverter
 
 class Command(BaseCommand):
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     print 'Starting document conversions...\n'
     try:
       with transaction.atomic():

+ 1 - 1
desktop/core/src/desktop/management/commands/create_test_fs.py

@@ -23,7 +23,7 @@ from django.utils.translation import ugettext as _
 
 class Command(BaseCommand):
   """Creates file system for testing."""
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     fs_dir = os.path.join(get_build_dir(), "fs")
     if not os.path.isdir(fs_dir):
       os.makedirs(fs_dir)

+ 1 - 1
desktop/core/src/desktop/management/commands/generate_mdl.py

@@ -28,7 +28,7 @@ from desktop.lib.metrics import global_registry
 
 
 class Command(BaseCommand):
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     """Generates a Monitor Descriptor file."""
     registry = global_registry()
     definitions = []

+ 1 - 1
desktop/core/src/desktop/management/commands/is_db_alive.py

@@ -65,7 +65,7 @@ class Command(BaseCommand):
   The command directly replace the database parameters in the settings.py, to never use the defaut Hue settings.
   """
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     self.stdout.write('Going to test accessing the database')
 
     try:

+ 1 - 1
desktop/core/src/desktop/management/commands/kt_renewer.py

@@ -21,5 +21,5 @@ import desktop.kt_renewer
 class Command(BaseCommand):
   """ Starts a daemon which renews Kerberos credentials from a keytab
   periodically. """
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     desktop.kt_renewer.run()

+ 1 - 1
desktop/core/src/desktop/management/commands/ldaptest.py

@@ -438,7 +438,7 @@ class Command(BaseCommand):
       LOG.warn('LDAP Test Command failed')
     sys.exit(exit_code)
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     """
       ldap_test management command enters here. Main logic as follows:
       * check ldap parameters from hue.ini file

+ 1 - 1
desktop/core/src/desktop/management/commands/sync_documents.py

@@ -24,7 +24,7 @@ from desktop.models import Document
 
 class Command(BaseCommand):
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     logging.info('Running syncing document command.')
     self.stdout.write('Syncing document objects...\n')
     Document.objects.sync(doc2_only=False)

+ 33 - 0
desktop/core/src/desktop/management/commands/syncdb.py

@@ -0,0 +1,33 @@
+#!/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.
+
+import logging
+
+from django.core.management import call_command
+from django.core.management.base import BaseCommand
+
+class Command(BaseCommand):
+    help = 'Runs a makemigrations command'
+
+    def add_arguments(self, parser):
+        parser.add_argument(
+            '--noinput', '--no-input', action='store_false', dest='interactive',
+            help='Tells Django to NOT prompt the user for input of any kind.',
+        )
+
+    def handle(self, *args, **options):
+        call_command('makemigrations', '--noinput')

+ 1 - 1
desktop/core/src/desktop/management/commands/version.py

@@ -25,7 +25,7 @@ from desktop.lib.paths import get_desktop_root
 
 class Command(BaseCommand):
 
-  def handle_noargs(self, **options):
+  def handle(self, *args, **options):
     cdh_path = os.path.join(get_desktop_root(), '..', 'cloudera', 'cdh_version.properties')
     if os.path.exists(cdh_path):
       print open(cdh_path).read()

+ 0 - 1
desktop/libs/notebook/src/notebook/urls.py

@@ -26,7 +26,6 @@ from django.conf.urls import url
 # this file has been loaded after `desktop.settings` has been loaded.
 
 # Start DBProxy server
-import notebook.monkey_patches
 from notebook import views as notebook_views
 from notebook import api as notebook_api