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 import util as db_util
|
||||||
from mediagoblin.db.open import setup_connection_and_db_from_config
|
from mediagoblin.db.open import setup_connection_and_db_from_config
|
||||||
from mediagoblin.init.config import read_mediagoblin_config
|
from mediagoblin.init.config import read_mediagoblin_config
|
||||||
|
from mediagoblin import util as mg_util
|
||||||
|
|
||||||
import shlex
|
import shlex
|
||||||
import tarfile
|
import tarfile
|
||||||
@ -33,7 +34,7 @@ def import_export_parse_setup(subparser):
|
|||||||
'-cf', '--conf_file', default='mediagoblin.ini',
|
'-cf', '--conf_file', default='mediagoblin.ini',
|
||||||
help='Config file used to set up environment')
|
help='Config file used to set up environment')
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--mongodump_cache', default='mongodump',
|
'--mongodump_cache', default='/tmp/mediagoblin/mongodump',
|
||||||
help='mongodump cache directory')
|
help='mongodump cache directory')
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--mongodump_path', default='mongodump',
|
'--mongodump_path', default='mongodump',
|
||||||
@ -42,12 +43,15 @@ def import_export_parse_setup(subparser):
|
|||||||
'--mongorestore_path', default='mongorestore',
|
'--mongorestore_path', default='mongorestore',
|
||||||
help='mongorestore binary')
|
help='mongorestore binary')
|
||||||
subparser.add_argument(
|
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')
|
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):
|
def _export_database(db, args):
|
||||||
print "\n== Exporting database ==\n"
|
print "\n== Exporting database ==\n"
|
||||||
|
|
||||||
command = '{mongodump_path} -d {database} -o {mongodump_cache}'.format(
|
command = '{mongodump_path} -d {database} -o {mongodump_cache}'.format(
|
||||||
mongodump_path=args.mongodump_path,
|
mongodump_path=args.mongodump_path,
|
||||||
database=db.name,
|
database=db.name,
|
||||||
@ -60,6 +64,13 @@ def _export_database(db, args):
|
|||||||
|
|
||||||
print "\n== Database exported ==\n"
|
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):
|
def _import_database(db, args):
|
||||||
command = '{mongorestore_path} -d {database} -o {mongodump_cache}'.format(
|
command = '{mongorestore_path} -d {database} -o {mongodump_cache}'.format(
|
||||||
mongorestore_path=args.mongorestore_path,
|
mongorestore_path=args.mongorestore_path,
|
||||||
@ -74,7 +85,7 @@ def env_import(args):
|
|||||||
tf = tarfile.open(
|
tf = tarfile.open(
|
||||||
args.tar_file,
|
args.tar_file,
|
||||||
mode='r|gz')
|
mode='r|gz')
|
||||||
|
|
||||||
tf.extractall(args.extract_path)
|
tf.extractall(args.extract_path)
|
||||||
|
|
||||||
def env_export(args):
|
def env_export(args):
|
||||||
@ -91,6 +102,8 @@ def env_export(args):
|
|||||||
print "Aborting."
|
print "Aborting."
|
||||||
return
|
return
|
||||||
|
|
||||||
|
_export_media(db, args)
|
||||||
|
|
||||||
tf = tarfile.open(
|
tf = tarfile.open(
|
||||||
args.tar_file,
|
args.tar_file,
|
||||||
mode='w|gz')
|
mode='w|gz')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user