Esempio n. 1
0
    def handle(self, **options):
        run_all = options['run_all']
        list_all = options['list_all']
        list_checkpoints = options['list_checkpoints']
        pillow_name = options['pillow_name']
        pillow_key = options['pillow_key']
        num_processes = options['num_processes']
        process_number = options['process_number']
        processor_chunk_size = options['processor_chunk_size']
        dedicated_migration_process = options['dedicated_migration_process']
        assert 0 <= process_number < num_processes
        assert processor_chunk_size
        if list_all:
            print("\nPillows registered in system:")
            for config in get_all_pillow_configs():
                print('{}: {}'.format(config.section, config.name))

            print("\n\tRun with --pillow-name <name> to run a pillow")
            print(
                "\n\tRun with --pillow-key <key> to run a group of pillows together\n"
            )
            sys.exit()

        if run_all:
            pillows_to_run = get_all_pillow_configs()
        elif not run_all and not pillow_name and pillow_key:
            # get pillows from key
            if pillow_key not in settings.PILLOWTOPS:
                print("\n\tError, key %s is not in settings.PILLOWTOPS, legal keys are: %s" % \
                      (pillow_key, list(settings.PILLOWTOPS)))
                sys.exit()
            else:
                pillows_to_run = [
                    get_pillow_config_from_setting(pillow_key, config)
                    for config in settings.PILLOWTOPS[pillow_key]
                ]

        elif not run_all and not pillow_key and pillow_name:
            pillow = get_pillow_by_name(
                pillow_name,
                num_processes=num_processes,
                process_num=process_number,
                processor_chunk_size=processor_chunk_size,
                dedicated_migration_process=dedicated_migration_process)
            start_pillow(pillow)
            sys.exit()
        elif list_checkpoints:
            for pillow in get_all_pillow_instances():
                print(pillow.checkpoint.checkpoint_id)
            sys.exit()
        else:
            print(
                "\nNo command set, please see --help for runtime instructions")
            sys.exit()

        start_pillows(pillows=[
            pillow_config.get_instance() for pillow_config in pillows_to_run
        ])
Esempio n. 2
0
    def handle(self, **options):
        run_all = options['run_all']
        list_all = options['list_all']
        list_checkpoints = options['list_checkpoints']
        pillow_name = options['pillow_name']
        pillow_key = options['pillow_key']
        if list_all:
            print("\nPillows registered in system:")
            for config in get_all_pillow_configs():
                print(u'{}: {}'.format(config.section, config.name))

            print("\n\tRun with --pillow-name <name> to run a pillow")
            print(
                "\n\tRun with --pillow-key <key> to run a group of pillows together\n"
            )
            sys.exit()

        if run_all:
            pillows_to_run = get_all_pillow_configs()
        elif not run_all and not pillow_name and pillow_key:
            # get pillows from key
            if pillow_key not in settings.PILLOWTOPS:
                print("\n\tError, key %s is not in settings.PILLOWTOPS, legal keys are: %s" % \
                      (pillow_key, settings.PILLOWTOPS.keys()))
                sys.exit()
            else:
                pillows_to_run = [
                    get_pillow_config_from_setting(pillow_key, config)
                    for config in settings.PILLOWTOPS[pillow_key]
                ]

        elif not run_all and not pillow_key and pillow_name:
            pillow = get_pillow_by_name(pillow_name)
            start_pillow(pillow)
            sys.exit()
        elif list_checkpoints:
            for pillow in get_all_pillow_instances():
                print(pillow.checkpoint.checkpoint_id)
            sys.exit()
        else:
            print(
                "\nNo command set, please see --help for runtime instructions")
            sys.exit()

        start_pillows(pillows=[
            pillow_config.get_instance() for pillow_config in pillows_to_run
        ])
Esempio n. 3
0
    def handle_noargs(self, **options):
        run_all = options['run_all']
        list_all = options['list_all']
        list_checkpoints = options['list_checkpoints']
        pillow_name = options['pillow_name']
        pillow_key = options['pillow_key']
        if list_all:
            print "\nPillows registered in system:"
            for config in get_all_pillow_configs():
                print u'{}: {}'.format(config.section, config.name)

            print "\n\tRun with --pillow-name <name> to run a pillow"
            print "\n\tRun with --pillow-key <key> to run a group of pillows together\n"
            sys.exit()

        if run_all:
            pillows_to_run = get_all_pillow_configs()
        elif not run_all and not pillow_name and pillow_key:
            # get pillows from key
            if pillow_key not in settings.PILLOWTOPS:
                print "\n\tError, key %s is not in settings.PILLOWTOPS, legal keys are: %s" % \
                      (pillow_key, settings.PILLOWTOPS.keys())
                sys.exit()
            else:
                pillows_to_run = [get_pillow_config_from_setting(pillow_key, config)
                                  for config in settings.PILLOWTOPS[pillow_key]]

        elif not run_all and not pillow_key and pillow_name:
            pillow = get_pillow_by_name(pillow_name)
            start_pillow(pillow)
            sys.exit()
        elif list_checkpoints:
            for pillow in get_all_pillow_instances():
                print pillow.checkpoint.checkpoint_id
            sys.exit()
        else:
            print "\nNo command set, please see --help for runtime instructions"
            sys.exit()

        start_pillows(pillows=[pillow_config.get_instance() for pillow_config in pillows_to_run])
Esempio n. 4
0
 def handle_noargs(self, **options):
     import logging
     requests_log = logging.getLogger("requests")
     requests_log.setLevel(logging.WARNING)
     start_pillows()
Esempio n. 5
0
 def handle_noargs(self, **options):
     start_pillows()