From 441ed10de0cbc50ef2f40bae8dc25ea8493e8f8f Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Mon, 12 Aug 2013 14:57:45 -0700 Subject: [PATCH] wrap get_entry_and_processing_manager in try, except block --- mediagoblin/gmg_commands/reprocess.py | 52 +++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/mediagoblin/gmg_commands/reprocess.py b/mediagoblin/gmg_commands/reprocess.py index a3c732b9..579ba478 100644 --- a/mediagoblin/gmg_commands/reprocess.py +++ b/mediagoblin/gmg_commands/reprocess.py @@ -254,6 +254,9 @@ def available(args): media_type = args.id_or_type media_entry = None manager = get_processing_manager_for_type(media_type) + except ProcessingManagerDoesNotExist: + entry = MediaEntry.query.filter_by(id=args.id_or_type).first() + print 'No such processing manager for {0}'.format(entry.media_type) if args.state: processors = manager.list_all_processors_by_state(args.state) @@ -284,29 +287,34 @@ def available(args): def run(args): - media_entry, manager = get_entry_and_processing_manager(args.media_id) - - # TODO: (maybe?) This could probably be handled entirely by the - # processor class... try: - processor_class = manager.get_processor( - args.reprocess_command, media_entry) - except ProcessorDoesNotExist: - print 'No such processor "%s" for media with id "%s"' % ( - args.reprocess_command, media_entry.id) - return - except ProcessorNotEligible: - print 'Processor "%s" exists but media "%s" is not eligible' % ( - args.reprocess_command, media_entry.id) - return - - reprocess_parser = processor_class.generate_parser() - reprocess_args = reprocess_parser.parse_args(args.reprocess_args) - reprocess_request = processor_class.args_to_request(reprocess_args) - run_process_media( - media_entry, - reprocess_action=args.reprocess_command, - reprocess_info=reprocess_request) + media_entry, manager = get_entry_and_processing_manager(args.media_id) + + # TODO: (maybe?) This could probably be handled entirely by the + # processor class... + try: + processor_class = manager.get_processor( + args.reprocess_command, media_entry) + except ProcessorDoesNotExist: + print 'No such processor "%s" for media with id "%s"' % ( + args.reprocess_command, media_entry.id) + return + except ProcessorNotEligible: + print 'Processor "%s" exists but media "%s" is not eligible' % ( + args.reprocess_command, media_entry.id) + return + + reprocess_parser = processor_class.generate_parser() + reprocess_args = reprocess_parser.parse_args(args.reprocess_args) + reprocess_request = processor_class.args_to_request(reprocess_args) + run_process_media( + media_entry, + reprocess_action=args.reprocess_command, + reprocess_info=reprocess_request) + + except ProcessingManagerDoesNotExist: + entry = MediaEntry.query.filter_by(id=args.media_id).first() + print 'No such processing manager for {0}'.format(entry.media_type) def bulk_run(args): -- 2.25.1