More progress towards the new reprocessing infrastructure: args updating
This commit sponsored by Elizabeth Webber. Thanks, sis!
This commit is contained in:
parent
e4bdc9091c
commit
58bacb33ac
@ -96,16 +96,16 @@ def main_cli():
|
||||
|
||||
subparser.set_defaults(func=exec_func)
|
||||
|
||||
args = parser.parse_known_args()
|
||||
args[0].orig_conf_file = args[0].conf_file
|
||||
if args[0].conf_file is None:
|
||||
args = parser.parse_args()
|
||||
args.orig_conf_file = args.conf_file
|
||||
if args.conf_file is None:
|
||||
if os.path.exists('mediagoblin_local.ini') \
|
||||
and os.access('mediagoblin_local.ini', os.R_OK):
|
||||
args[0].conf_file = 'mediagoblin_local.ini'
|
||||
args.conf_file = 'mediagoblin_local.ini'
|
||||
else:
|
||||
args[0].conf_file = 'mediagoblin.ini'
|
||||
args.conf_file = 'mediagoblin.ini'
|
||||
|
||||
args[0].func(args)
|
||||
args.func(args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -13,6 +13,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from mediagoblin import mg_globals
|
||||
@ -23,30 +24,63 @@ from mediagoblin.tools.pluginapi import hook_handle
|
||||
|
||||
|
||||
def reprocess_parser_setup(subparser):
|
||||
subparser.add_argument(
|
||||
'--available', '-a',
|
||||
action="store_true",
|
||||
help="List available actions for a given media entry")
|
||||
subparser.add_argument(
|
||||
subparsers = subparser.add_subparsers(dest="reprocess_subcommand")
|
||||
|
||||
###################
|
||||
# available command
|
||||
###################
|
||||
available_parser = subparsers.add_parser(
|
||||
"available",
|
||||
help="Find out what actions are available for this media")
|
||||
|
||||
available_parser.add_argument(
|
||||
"id_or_type",
|
||||
help="Media id or media type to check")
|
||||
|
||||
|
||||
############################################
|
||||
# run command (TODO: and bulk_run command??)
|
||||
############################################
|
||||
|
||||
run_parser = subparsers.add_parser(
|
||||
"run",
|
||||
help="Run a reprocessing on one or more media")
|
||||
|
||||
run_parser.add_argument(
|
||||
'--state', '-s',
|
||||
help="Reprocess media entries in this state"
|
||||
" such as 'failed' or 'processed'")
|
||||
subparser.add_argument(
|
||||
run_parser.add_argument(
|
||||
'--type', '-t',
|
||||
help="The type of media to be reprocessed such as 'video' or 'image'")
|
||||
subparser.add_argument(
|
||||
'--media_id',
|
||||
nargs='*',
|
||||
help="The media_entry id(s) you wish to reprocess.")
|
||||
subparser.add_argument(
|
||||
run_parser.add_argument(
|
||||
'--thumbnails',
|
||||
action="store_true",
|
||||
help="Regenerate thumbnails for all processed media")
|
||||
subparser.add_argument(
|
||||
run_parser.add_argument(
|
||||
'--celery',
|
||||
action='store_true',
|
||||
help="Don't process eagerly, pass off to celery")
|
||||
|
||||
run_parser.add_argument(
|
||||
'media_id',
|
||||
help="The media_entry id(s) you wish to reprocess.")
|
||||
|
||||
run_parser.add_argument(
|
||||
'reprocess_command',
|
||||
help="The reprocess command you intend to run")
|
||||
|
||||
run_parser.add_argument(
|
||||
'reprocess_args',
|
||||
nargs=argparse.REMAINDER,
|
||||
help="rest of arguments to the reprocessing tool")
|
||||
|
||||
|
||||
###############
|
||||
# help command?
|
||||
###############
|
||||
|
||||
|
||||
|
||||
def _set_media_type(args):
|
||||
"""
|
||||
@ -165,11 +199,22 @@ def _set_media_state(args):
|
||||
args[0].state = 'processed'
|
||||
|
||||
|
||||
def reprocess(args):
|
||||
def available(args):
|
||||
# Get the media type, either by looking up media id, or by specific type
|
||||
|
||||
### TODO: look up by id
|
||||
|
||||
#
|
||||
pass
|
||||
|
||||
|
||||
def run(args):
|
||||
### OLD CODE, review
|
||||
|
||||
# Run eagerly unless explicetly set not to
|
||||
if not args[0].celery:
|
||||
if not args.celery:
|
||||
os.environ['CELERY_ALWAYS_EAGER'] = 'true'
|
||||
commands_util.setup_app(args[0])
|
||||
commands_util.setup_app(args)
|
||||
|
||||
_set_media_state(args)
|
||||
_set_media_type(args)
|
||||
@ -179,3 +224,10 @@ def reprocess(args):
|
||||
return _reprocess_all(args)
|
||||
|
||||
return _run_reprocessing(args)
|
||||
|
||||
|
||||
def reprocess(args):
|
||||
if args.reprocess_subcommand == "run":
|
||||
run(args)
|
||||
elif args.reprocess_subcommand == "available":
|
||||
available(args)
|
||||
|
@ -72,6 +72,6 @@ hooks = {
|
||||
'get_media_type_and_manager': get_media_type_and_manager,
|
||||
'sniff_handler': sniff_handler,
|
||||
('media_manager', MEDIA_TYPE): lambda: ImageMediaManager,
|
||||
('reprocess_action', 'image'): ProcessImage().reprocess_action,
|
||||
('media_reprocess', 'image'): ProcessImage().media_reprocess,
|
||||
('reprocess_action', MEDIA_TYPE): ProcessImage().reprocess_action,
|
||||
('media_reprocess', MEDIA_TYPE): ProcessImage().media_reprocess,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user