aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/gmg_commands')
-rw-r--r--mediagoblin/gmg_commands/import_export.py10
-rw-r--r--mediagoblin/gmg_commands/migrate.py6
-rw-r--r--mediagoblin/gmg_commands/users.py15
-rw-r--r--mediagoblin/gmg_commands/util.py13
4 files changed, 31 insertions, 13 deletions
diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py
index 30112969..4ec17d47 100644
--- a/mediagoblin/gmg_commands/import_export.py
+++ b/mediagoblin/gmg_commands/import_export.py
@@ -211,10 +211,12 @@ def _export_media(db, args):
_log.info(u'Exporting {0} - {1}'.format(
entry['title'],
name))
-
- mc_file = media_cache.get_file(path, mode='wb')
- mc_file.write(
- mg_globals.public_store.get_file(path, mode='rb').read())
+ try:
+ mc_file = media_cache.get_file(path, mode='wb')
+ mc_file.write(
+ mg_globals.public_store.get_file(path, mode='rb').read())
+ except e:
+ _log.error('Failed: {0}'.format(e))
_log.info('...Media exported')
diff --git a/mediagoblin/gmg_commands/migrate.py b/mediagoblin/gmg_commands/migrate.py
index beea109d..bd3bcb20 100644
--- a/mediagoblin/gmg_commands/migrate.py
+++ b/mediagoblin/gmg_commands/migrate.py
@@ -18,7 +18,7 @@ import sys
from mediagoblin.db import util as db_util
from mediagoblin.db.open import setup_connection_and_db_from_config
-from mediagoblin.init.config import read_mediagoblin_config
+from mediagoblin.init import setup_global_and_app_config
# This MUST be imported so as to set up the appropriate migrations!
from mediagoblin.db import migrations
@@ -41,9 +41,9 @@ def _print_finished_migration(migration_number, migration_func):
def migrate(args):
- config, validation_result = read_mediagoblin_config(args.conf_file)
+ global_config, app_config = setup_global_and_app_config(args.conf_file)
connection, db = setup_connection_and_db_from_config(
- config['mediagoblin'], use_pymongo=True)
+ app_config, use_pymongo=True)
migration_manager = db_util.MigrationManager(db)
# Clear old indexes
diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py
index 4c4b0c1b..b437e839 100644
--- a/mediagoblin/gmg_commands/users.py
+++ b/mediagoblin/gmg_commands/users.py
@@ -18,23 +18,26 @@ from mediagoblin.gmg_commands import util as commands_util
from mediagoblin.auth import lib as auth_lib
from mediagoblin import mg_globals
-
def adduser_parser_setup(subparser):
subparser.add_argument(
- 'username',
+ '--username','-u',
help="Username used to login")
subparser.add_argument(
- 'password',
- help="Your supersecret word to login")
+ '--password','-p',
+ help="Your supersecret word to login, beware of storing it in bash history")
subparser.add_argument(
- 'email',
- help="Email to recieve notifications")
+ '--email','-e',
+ help="Email to receive notifications")
def adduser(args):
#TODO: Lets trust admins this do not validate Emails :)
commands_util.setup_app(args)
+ 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.find({
diff --git a/mediagoblin/gmg_commands/util.py b/mediagoblin/gmg_commands/util.py
index 168a0760..3e26c53f 100644
--- a/mediagoblin/gmg_commands/util.py
+++ b/mediagoblin/gmg_commands/util.py
@@ -16,6 +16,7 @@
from mediagoblin import app
+import getpass
def setup_app(args):
@@ -25,3 +26,15 @@ def setup_app(args):
mgoblin_app = app.MediaGoblinApp(args.conf_file)
return mgoblin_app
+
+def prompt_if_not_set(variable, text, password=False):
+ """
+ Checks if the variable is None and prompt for a value if it is
+ """
+ if variable is None:
+ if not password:
+ variable=raw_input(text + u' ')
+ else:
+ variable=getpass.getpass(text + u' ')
+
+ return variable