Revert "use parser.parse_known_args() instead of parser.parse_args()"
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 12 Aug 2013 16:13:00 +0000 (11:13 -0500)
committerRodney Ewing <ewing.rj@gmail.com>
Fri, 16 Aug 2013 22:30:17 +0000 (15:30 -0700)
This reverts commit 029e779c468ba1a6bfd893679cfaae7f418f45dd.
(and a bit more!)

This wasn't needed anymore because we did a "rest" capture and passed
that over to the reprocess run command.

Conflicts:
mediagoblin/gmg_commands/assetlink.py
mediagoblin/gmg_commands/dbupdate.py
mediagoblin/gmg_commands/import_export.py
mediagoblin/gmg_commands/users.py

mediagoblin/gmg_commands/assetlink.py
mediagoblin/gmg_commands/dbupdate.py
mediagoblin/gmg_commands/import_export.py
mediagoblin/gmg_commands/shell.py
mediagoblin/gmg_commands/users.py
mediagoblin/gmg_commands/util.py

index dff737ffefc5c4331e03ee31e5386b50a6096341..148ebe9e9ca6310a5babc1413c6c14c1ebee1221 100644 (file)
@@ -138,8 +138,7 @@ def assetlink(args):
     """
     Link the asset directory of the currently installed theme and plugins
     """
-    commands_util.check_unrecognized_args(args)
-    mgoblin_app = commands_util.setup_app(args[0])
+    mgoblin_app = commands_util.setup_app(args)
     app_config = mg_globals.app_config
 
     # link theme
index b2efa5de4d43bacfaecb84b36a269dd828383672..961752f61f4e1af0366bc27e9574579351c2f232 100644 (file)
@@ -20,7 +20,6 @@ from sqlalchemy.orm import sessionmaker
 
 from mediagoblin.db.open import setup_connection_and_db_from_config
 from mediagoblin.db.migration_tools import MigrationManager
-from mediagoblin.gmg_commands import util as commands_util
 from mediagoblin.init import setup_global_and_app_config
 from mediagoblin.tools.common import import_component
 
@@ -148,6 +147,5 @@ def run_all_migrations(db, app_config, global_config):
 
 
 def dbupdate(args):
-    commands_util.check_unrecognized_args(args)
-    global_config, app_config = setup_global_and_app_config(args[0].conf_file)
+    global_config, app_config = setup_global_and_app_config(args.conf_file)
     run_dbupdate(app_config, global_config)
index 1d4ae1f7cd45b75664cc391459bcbcf18d5a41a3..fbac09f6562fd4776a8b8c5493665f6b48e80bee 100644 (file)
@@ -97,28 +97,27 @@ def env_import(args):
     '''
     Restore mongo database and media files from a tar archive
     '''
-    commands_util.check_unrecognized_args(args)
-    if not args[0].cache_path:
-        args[0].cache_path = tempfile.mkdtemp()
+    if not args.cache_path:
+        args.cache_path = tempfile.mkdtemp()
 
-    setup_global_and_app_config(args[0].conf_file)
+    setup_global_and_app_config(args.conf_file)
 
     # Creates mg_globals.public_store and mg_globals.queue_store
     setup_storage()
 
-    global_config, app_config = setup_global_and_app_config(args[0].conf_file)
+    global_config, app_config = setup_global_and_app_config(args.conf_file)
     db = setup_connection_and_db_from_config(
         app_config)
 
     tf = tarfile.open(
-        args[0].tar_file,
+        args.tar_file,
         mode='r|gz')
 
-    tf.extractall(args[0].cache_path)
+    tf.extractall(args.cache_path)
 
-    args[0].cache_path = os.path.join(
-        args[0].cache_path, 'mediagoblin-data')
-    args = _setup_paths(args[0])
+    args.cache_path = os.path.join(
+        args.cache_path, 'mediagoblin-data')
+    args = _setup_paths(args)
 
     # Import database from extracted data
     _import_database(db, args)
@@ -227,16 +226,16 @@ def env_export(args):
     '''
     commands_util.check_unrecognized_args(args)
     if args.cache_path:
-        if os.path.exists(args[0].cache_path):
+        if os.path.exists(args.cache_path):
             _log.error('The cache directory must not exist '
                        'before you run this script')
-            _log.error('Cache directory: {0}'.format(args[0].cache_path))
+            _log.error('Cache directory: {0}'.format(args.cache_path))
 
             return False
     else:
-        args[0].cache_path = tempfile.mkdtemp()
+        args.cache_path = tempfile.mkdtemp()
 
-    args = _setup_paths(args[0])
+    args = _setup_paths(args)
 
     if not _export_check(args):
         _log.error('Checks did not pass, exiting')
index 03e08b231b68b33ea4fe2d4d63f3144e3fbdefb5..4998acd7b46e73766e7517b706f98298c75d92d3 100644 (file)
@@ -63,13 +63,12 @@ def shell(args):
     """
     Setup a shell for the user either a normal Python shell or an IPython one
     """
-    commands_util.check_unrecognized_args(args)
     user_namespace = {
         'mg_globals': mg_globals,
-        'mgoblin_app': commands_util.setup_app(args[0]),
+        'mgoblin_app': commands_util.setup_app(args),
         'db': mg_globals.database}
 
-    if args[0].ipython:
+    if args.ipython:
         ipython_shell(**user_namespace)
     else:
         # Try ipython_shell first and fall back if not available
index b164e67221aabc43a987fd943cf70e4ac07c1fd2..e44b0aa9b481bbee3f9d653c48602de6f7605843 100644 (file)
@@ -32,17 +32,16 @@ def adduser_parser_setup(subparser):
 
 def adduser(args):
     #TODO: Lets trust admins this do not validate Emails :)
-    commands_util.check_unrecognized_args(args)
-    commands_util.setup_app(args[0])
+    commands_util.setup_app(args)
 
-    args[0].username = commands_util.prompt_if_not_set(args[0].username, "Username:")
-    args[0].password = commands_util.prompt_if_not_set(args[0].password, "Password:",True)
-    args[0].email = commands_util.prompt_if_not_set(args[0].email, "Email:")
+    args.username = commands_util.prompt_if_not_set(args.username, "Username:")
+    args.password = commands_util.prompt_if_not_set(args.password, "Password:",True)
+    args.email = commands_util.prompt_if_not_set(args.email, "Email:")
 
     db = mg_globals.database
     users_with_username = \
         db.User.query.filter_by(
-            username=args[0].username.lower()
+            username=args.username.lower()
         ).count()
 
     if users_with_username:
@@ -51,9 +50,9 @@ def adduser(args):
     else:
         # Create the user
         entry = db.User()
-        entry.username = unicode(args[0].username.lower())
-        entry.email = unicode(args[0].email)
-        entry.pw_hash = auth.gen_password_hash(args[0].password)
+        entry.username = unicode(args.username.lower())
+        entry.email = unicode(args.email)
+        entry.pw_hash = auth.gen_password_hash(args.password)
         entry.status = u'active'
         entry.email_verified = True
         entry.save()
@@ -68,13 +67,12 @@ def makeadmin_parser_setup(subparser):
 
 
 def makeadmin(args):
-    commands_util.check_unrecognized_args(args)
-    commands_util.setup_app(args[0])
+    commands_util.setup_app(args)
 
     db = mg_globals.database
 
     user = db.User.query.filter_by(
-        username=unicode(args[0].username.lower())).one()
+        username=unicode(args.username.lower())).one()
     if user:
         user.is_admin = True
         user.save()
@@ -93,15 +91,14 @@ def changepw_parser_setup(subparser):
 
 
 def changepw(args):
-    commands_util.check_unrecognized_args(args)
-    commands_util.setup_app(args[0])
+    commands_util.setup_app(args)
 
     db = mg_globals.database
 
     user = db.User.query.filter_by(
-        username=unicode(args[0].username.lower())).one()
+        username=unicode(args.username.lower())).one()
     if user:
-        user.pw_hash = auth.gen_password_hash(args[0].password)
+        user.pw_hash = auth.gen_password_hash(args.password)
         user.save()
         print 'Password successfully changed'
     else:
index 8b05799697f054b43cb295b6a38efd213601860b..63e39ca9523ef48b63aad0048c2d93be48ecc2f8 100644 (file)
@@ -17,7 +17,6 @@
 
 from mediagoblin import app
 import getpass
-import argparse
 
 
 def setup_app(args):
@@ -39,9 +38,3 @@ def prompt_if_not_set(variable, text, password=False):
             variable=getpass.getpass(text + u' ')
 
     return variable
-
-
-def check_unrecognized_args(args):
-    if args[1]:
-        parser = argparse.ArgumentParser()
-        parser.error('unrecognized arguments: {}'.format(args[1]))