aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/gmg_commands/assetlink.py3
-rw-r--r--mediagoblin/gmg_commands/dbupdate.py4
-rw-r--r--mediagoblin/gmg_commands/import_export.py27
-rw-r--r--mediagoblin/gmg_commands/shell.py5
-rw-r--r--mediagoblin/gmg_commands/users.py29
-rw-r--r--mediagoblin/gmg_commands/util.py7
6 files changed, 30 insertions, 45 deletions
diff --git a/mediagoblin/gmg_commands/assetlink.py b/mediagoblin/gmg_commands/assetlink.py
index dff737ff..148ebe9e 100644
--- a/mediagoblin/gmg_commands/assetlink.py
+++ b/mediagoblin/gmg_commands/assetlink.py
@@ -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
diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py
index b2efa5de..961752f6 100644
--- a/mediagoblin/gmg_commands/dbupdate.py
+++ b/mediagoblin/gmg_commands/dbupdate.py
@@ -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)
diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py
index 1d4ae1f7..fbac09f6 100644
--- a/mediagoblin/gmg_commands/import_export.py
+++ b/mediagoblin/gmg_commands/import_export.py
@@ -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')
diff --git a/mediagoblin/gmg_commands/shell.py b/mediagoblin/gmg_commands/shell.py
index 03e08b23..4998acd7 100644
--- a/mediagoblin/gmg_commands/shell.py
+++ b/mediagoblin/gmg_commands/shell.py
@@ -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
diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py
index b164e672..e44b0aa9 100644
--- a/mediagoblin/gmg_commands/users.py
+++ b/mediagoblin/gmg_commands/users.py
@@ -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:
diff --git a/mediagoblin/gmg_commands/util.py b/mediagoblin/gmg_commands/util.py
index 8b057996..63e39ca9 100644
--- a/mediagoblin/gmg_commands/util.py
+++ b/mediagoblin/gmg_commands/util.py
@@ -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]))