aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands/import_export.py
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2011-08-07 05:00:46 +0200
committerJoar Wandborg <git@wandborg.com>2011-08-07 05:00:46 +0200
commit224813d28cc60aa7ec1ead34ea028713a2d61c74 (patch)
treeba0da98cd321b2632748f4ec7cba05bb43ecb3ac /mediagoblin/gmg_commands/import_export.py
parente86d4f5d51dfdd42e2fe91e268bd0f335732908a (diff)
downloadmediagoblin-224813d28cc60aa7ec1ead34ea028713a2d61c74.tar.lz
mediagoblin-224813d28cc60aa7ec1ead34ea028713a2d61c74.tar.xz
mediagoblin-224813d28cc60aa7ec1ead34ea028713a2d61c74.zip
Feature #298
* Added some minor things to gmg_commands.import_export
Diffstat (limited to 'mediagoblin/gmg_commands/import_export.py')
-rw-r--r--mediagoblin/gmg_commands/import_export.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py
index c0ac444b..aa3fe1a1 100644
--- a/mediagoblin/gmg_commands/import_export.py
+++ b/mediagoblin/gmg_commands/import_export.py
@@ -38,6 +38,12 @@ def import_export_parse_setup(subparser):
subparser.add_argument(
'--mongodump_path', default='mongodump',
help='mongodump binary')
+ subparser.add_argument(
+ '--mongorestore_path', default='mongorestore',
+ help='mongorestore binary')
+ subparser.add_argument(
+ '--extract_path', default='/tmp/mediagoblin-import',
+ help='the directory to which the tarball should be extracted temporarily')
def _export_database(db, args):
print "\n== Exporting database ==\n"
@@ -55,13 +61,22 @@ def _export_database(db, args):
print "\n== Database exported ==\n"
def _import_database(db, args):
- pass
+ command = '{mongorestore_path} -d {database} -o {mongodump_cache}'.format(
+ mongorestore_path=args.mongorestore_path,
+ database=db.name,
+ mongodump_cache=args.mongodump_cache)
def env_import(args):
config, validation_result = read_mediagoblin_config(args.conf_file)
connection, db = setup_connection_and_db_from_config(
config['mediagoblin'], use_pymongo=True)
+ tf = tarfile.open(
+ args.tar_file,
+ mode='r|gz')
+
+ tf.extractall(args.extract_path)
+
def env_export(args):
config, validation_result = read_mediagoblin_config(args.conf_file)
connection, db = setup_connection_and_db_from_config(