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 ])
def catch_signal(sender, **kwargs): if settings.UNIT_TESTING: return from fluff.pillow import FluffPillow table_pillow_map = {} pillow_configs = get_all_pillow_configs() for pillow_config in pillow_configs: pillow_class = pillow_config.get_class() if issubclass(pillow_class, FluffPillow): doc = pillow_class.indicator_class() if doc.save_direct_to_sql: table_pillow_map[doc._table.name] = { 'doc': doc, 'pillow': pillow_class } print '\tchecking fluff SQL tables for schema changes' engine = sqlalchemy.create_engine(settings.SQL_REPORTING_DATABASE_URL) with engine.begin() as connection: migration_context = get_migration_context(connection, table_pillow_map.keys()) diffs = compare_metadata(migration_context, fluff_metadata) tables_to_rebuild = get_tables_to_rebuild(diffs, table_pillow_map.keys()) for table in tables_to_rebuild: info = table_pillow_map[table] rebuild_table(engine, info['pillow'], info['doc']) engine.dispose()
def test_instantiate_all(self): all_pillow_configs = list(get_all_pillow_configs()) expected_meta = self.get_expected_meta() self.assertEqual(len(all_pillow_configs), len(expected_meta)) for pillow_config in all_pillow_configs: self.assertEqual(expected_meta[pillow_config.name], _pillow_meta_from_config(pillow_config))
def test_instantiate_all(self): all_pillow_configs = list(get_all_pillow_configs()) expected_meta = self.get_expected_meta() self.assertEqual(len(all_pillow_configs), len(expected_meta)) for pillow_config in all_pillow_configs: self.assertEqual(expected_meta[pillow_config.name], _pillow_meta_from_config(pillow_config))
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 ])
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])