コード例 #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
        ])
コード例 #2
0
ファイル: test_config.py プロジェクト: ye-man/commcare-hq
 def test_from_dict(self):
     pillow_config = {
         'class': 'my.cool.Pillow',
         'instance': 'my.instance.method',
         'name': 'MyPillow',
     }
     config = get_pillow_config_from_setting('my-section', pillow_config)
     self.assertEqual('my-section', config.section)
     self.assertEqual(pillow_config['class'], config.class_name)
     self.assertEqual(pillow_config['instance'], config.instance_generator)
     self.assertEqual(pillow_config['name'], config.name)
コード例 #3
0
ファイル: run_ptop.py プロジェクト: rodneylubwama/commcare-hq
    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
        ])
コード例 #4
0
ファイル: run_ptop.py プロジェクト: saketkanth/commcare-hq
    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])
コード例 #5
0
ファイル: test_config.py プロジェクト: ye-man/commcare-hq
 def test_from_string(self):
     class_name = 'my.cool.Pillow'
     config = get_pillow_config_from_setting('my-section', class_name)
     self.assertEqual('my-section', config.section)
     self.assertEqual(class_name, config.class_name)
     self.assertEqual(None, config.instance_generator)