X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=mediagoblin%2Fgmg_commands%2Fimport_export.py;h=72ebd8a8b5b44b3338734dfaf83ad20d95f4644b;hb=0d857844b12b033ee8ecdbcfa474781f835bee59;hp=4ec17d4783d2df046ee785398d635605595f83c3;hpb=6603b300418efe0f28390a5b53208c9c7068489b;p=mediagoblin.git diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py index 4ec17d47..72ebd8a8 100644 --- a/mediagoblin/gmg_commands/import_export.py +++ b/mediagoblin/gmg_commands/import_export.py @@ -1,5 +1,5 @@ # GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS. +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -61,13 +61,12 @@ def _import_media(db, args): args._cache_path['media']) # TODO: Add import of queue files - queue_cache = BasicFileStorage( - args._cache_path['queue']) + queue_cache = BasicFileStorage(args._cache_path['queue']) - for entry in db.media_entries.find(): - for name, path in entry['media_files'].items(): + for entry in db.MediaEntry.find(): + for name, path in entry.media_files.items(): _log.info('Importing: {0} - {1}'.format( - entry['title'], + entry.title.encode('ascii', 'replace'), name)) media_file = mg_globals.public_store.get_file(path, mode='wb') @@ -107,7 +106,7 @@ def env_import(args): global_config, app_config = setup_global_and_app_config(args.conf_file) connection, db = setup_connection_and_db_from_config( - app_config, use_pymongo=True) + app_config) tf = tarfile.open( args.tar_file, @@ -203,19 +202,18 @@ def _export_media(db, args): args._cache_path['media']) # TODO: Add export of queue files - queue_cache = BasicFileStorage( - args._cache_path['queue']) + queue_cache = BasicFileStorage(args._cache_path['queue']) - for entry in db.media_entries.find(): - for name, path in entry['media_files'].items(): + for entry in db.MediaEntry.find(): + for name, path in entry.media_files.items(): _log.info(u'Exporting {0} - {1}'.format( - entry['title'], + entry.title, name)) 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: + except Exception as e: _log.error('Failed: {0}'.format(e)) _log.info('...Media exported') @@ -246,7 +244,7 @@ def env_export(args): setup_storage() connection, db = setup_connection_and_db_from_config( - app_config, use_pymongo=True) + app_config) _export_database(db, args)