Feature #298 - Changed some defaults in gmg_commands.import_export
This commit is contained in:
parent
224813d28c
commit
9188f3afe2
@ -19,6 +19,7 @@ from mediagoblin import mg_globals
|
||||
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 import util as mg_util
|
||||
|
||||
import shlex
|
||||
import tarfile
|
||||
@ -33,7 +34,7 @@ def import_export_parse_setup(subparser):
|
||||
'-cf', '--conf_file', default='mediagoblin.ini',
|
||||
help='Config file used to set up environment')
|
||||
subparser.add_argument(
|
||||
'--mongodump_cache', default='mongodump',
|
||||
'--mongodump_cache', default='/tmp/mediagoblin/mongodump',
|
||||
help='mongodump cache directory')
|
||||
subparser.add_argument(
|
||||
'--mongodump_path', default='mongodump',
|
||||
@ -42,8 +43,11 @@ def import_export_parse_setup(subparser):
|
||||
'--mongorestore_path', default='mongorestore',
|
||||
help='mongorestore binary')
|
||||
subparser.add_argument(
|
||||
'--extract_path', default='/tmp/mediagoblin-import',
|
||||
'--extract_path', default='/tmp/mediagoblin/import',
|
||||
help='the directory to which the tarball should be extracted temporarily')
|
||||
subparser.add_argument(
|
||||
'--media_cache_path', default='/tmp/mediagoblin/mediaentries',
|
||||
help='')
|
||||
|
||||
def _export_database(db, args):
|
||||
print "\n== Exporting database ==\n"
|
||||
@ -60,6 +64,13 @@ def _export_database(db, args):
|
||||
|
||||
print "\n== Database exported ==\n"
|
||||
|
||||
def _export_media(db, args):
|
||||
for entry in db.media_entries.find():
|
||||
storage = mg_util.import_component(
|
||||
'mediagoblin.storage:BasicFileStorage')()
|
||||
print(storage.get_file(entry['media_files']['medium']))
|
||||
print(entry)
|
||||
|
||||
def _import_database(db, args):
|
||||
command = '{mongorestore_path} -d {database} -o {mongodump_cache}'.format(
|
||||
mongorestore_path=args.mongorestore_path,
|
||||
@ -91,6 +102,8 @@ def env_export(args):
|
||||
print "Aborting."
|
||||
return
|
||||
|
||||
_export_media(db, args)
|
||||
|
||||
tf = tarfile.open(
|
||||
args.tar_file,
|
||||
mode='w|gz')
|
||||
|
Loading…
x
Reference in New Issue
Block a user