"""
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
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
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)
'''
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)
'''
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')
"""
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
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:
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()
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()
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:
from mediagoblin import app
import getpass
-import argparse
def setup_app(args):
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]))