From aa387fc57ec1c176a739df8c5f4cedaf70ae9af1 Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Thu, 1 Aug 2013 10:23:37 -0700 Subject: use parser.parse_known_args() instead of parser.parse_args() --- mediagoblin/gmg_commands/import_export.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'mediagoblin/gmg_commands/import_export.py') diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py index 98ec617d..2a624b96 100644 --- a/mediagoblin/gmg_commands/import_export.py +++ b/mediagoblin/gmg_commands/import_export.py @@ -96,27 +96,27 @@ def env_import(args): ''' Restore mongo database and media files from a tar archive ''' - if not args.cache_path: - args.cache_path = tempfile.mkdtemp() + if not args[0].cache_path: + args[0].cache_path = tempfile.mkdtemp() - setup_global_and_app_config(args.conf_file) + setup_global_and_app_config(args[0].conf_file) # Creates mg_globals.public_store and mg_globals.queue_store setup_storage() - global_config, app_config = setup_global_and_app_config(args.conf_file) + global_config, app_config = setup_global_and_app_config(args[0].conf_file) db = setup_connection_and_db_from_config( app_config) tf = tarfile.open( - args.tar_file, + args[0].tar_file, mode='r|gz') - tf.extractall(args.cache_path) + tf.extractall(args[0].cache_path) - args.cache_path = os.path.join( - args.cache_path, 'mediagoblin-data') - args = _setup_paths(args) + args[0].cache_path = os.path.join( + args[0].cache_path, 'mediagoblin-data') + args = _setup_paths(args[0]) # Import database from extracted data _import_database(db, args) @@ -224,16 +224,16 @@ def env_export(args): Export database and media files to a tar archive ''' if args.cache_path: - if os.path.exists(args.cache_path): + if os.path.exists(args[0].cache_path): _log.error('The cache directory must not exist ' 'before you run this script') - _log.error('Cache directory: {0}'.format(args.cache_path)) + _log.error('Cache directory: {0}'.format(args[0].cache_path)) return False else: - args.cache_path = tempfile.mkdtemp() + args[0].cache_path = tempfile.mkdtemp() - args = _setup_paths(args) + args = _setup_paths(args[0]) if not _export_check(args): _log.error('Checks did not pass, exiting') -- cgit v1.2.3 From 262c789754931d95a4bb567fc59a3ffb833ed1bb Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Thu, 1 Aug 2013 11:11:04 -0700 Subject: Throw an error if there are unrecognized arguments --- mediagoblin/gmg_commands/import_export.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mediagoblin/gmg_commands/import_export.py') diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py index 2a624b96..1d4ae1f7 100644 --- a/mediagoblin/gmg_commands/import_export.py +++ b/mediagoblin/gmg_commands/import_export.py @@ -16,6 +16,7 @@ from mediagoblin import mg_globals from mediagoblin.db.open import setup_connection_and_db_from_config +from mediagoblin.gmg_commands import util as commands_util from mediagoblin.storage.filestorage import BasicFileStorage from mediagoblin.init import setup_storage, setup_global_and_app_config @@ -96,6 +97,7 @@ 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() @@ -223,6 +225,7 @@ def env_export(args): ''' Export database and media files to a tar archive ''' + commands_util.check_unrecognized_args(args) if args.cache_path: if os.path.exists(args[0].cache_path): _log.error('The cache directory must not exist ' -- cgit v1.2.3 From ff12ecef347d0fdb29534eb2bc0390cf183c10ba Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 12 Aug 2013 11:13:00 -0500 Subject: Revert "use parser.parse_known_args() instead of parser.parse_args()" 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/import_export.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'mediagoblin/gmg_commands/import_export.py') 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') -- cgit v1.2.3