confirmed_dict = { "is_confirmed": True, "active": True, "is_notification_send": True, "created_by": "System", "confirmed_by": "System", } class TerminalColors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKCYAN = '\033[96m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' def do_alembic(): from sqlalchemy import text from alembic_generate import generate_alembic_with_session generate_alembic_with_session(text=text) def create_one_address(confirmed_dict): from databases import ( AddressCity, AddressStreet, AddressLocality, AddressDistrict, AddressNeighborhood, AddressState, AddressCountry, ) country = AddressCountry.find_or_create( country_name="TÜRKİYE", country_code="TR", **confirmed_dict ) state = AddressState.find_or_create( state_name="TÜRKİYE", state_code="TR", phone_code="90", country_id=country.id, country_uu_id=str(country.uu_id), **confirmed_dict, ) city = AddressCity.find_or_create( city_name="ANKARA", city_code="6", licence_plate="06", state_id=state.id, state_uu_id=str(state.uu_id), **confirmed_dict, ) district = AddressDistrict.find_or_create( district_name="ÇANKAYA", district_code="1231", city_id=city.id, city_uu_id=str(city.uu_id), **confirmed_dict, ) locality = AddressLocality.find_or_create( locality_name="MERKEZ", locality_code="2431", type_code="3", type_description=None, district_id=district.id, district_uu_id=str(district.uu_id), **confirmed_dict, ) neighborhood = AddressNeighborhood.find_or_create( neighborhood_name="AYRANCI MAHALLESİ", neighborhood_code="1522", type_code="1", type_description="MAHALLESİ", locality_id=locality.id, locality_uu_id=str(locality.uu_id), **confirmed_dict, ) street = AddressStreet.find_or_create( street_name="REŞAT NURİ CADDESİ", type_description="CADDESİ", type_code="3", street_code="52270", neighborhood_id=neighborhood.id, neighborhood_uu_id=str(neighborhood.uu_id), **confirmed_dict, ) return def create_application_defaults_func(create_address=False): from initialize_app import ( create_modules_and_services_and_actions, create_endpoints_from_api_functions, create_all_events_from_actions, create_application_defaults, init_api_enums_build_types, add_events_all_services_and_occupant_types, add_events_to_system_super_user, create_occupant_types_defaults, ) import routers try: create_endpoints_from_api_functions(routers=routers) except Exception as e: print(f"{TerminalColors.WARNING} create_endpoints_from_api_functions Defaults Error", e) try: create_application_defaults() except Exception as e: print(f"{TerminalColors.WARNING} create_application_defaults Defaults Error", e) try: create_occupant_types_defaults() except Exception as e: print(f"{TerminalColors.WARNING} create_occupant_types_defaults Defaults Error", e) try: create_modules_and_services_and_actions() except Exception as e: print(f"{TerminalColors.WARNING} create_modules_and_services_and_actions Defaults Error", e) try: init_api_enums_build_types() except Exception as e: print(f"{TerminalColors.WARNING} init_api_enums_build_types Defaults Error", e) try: create_all_events_from_actions() except Exception as e: print(f"{TerminalColors.WARNING} create_all_events_from_actions Defaults Error", e) try: add_events_all_services_and_occupant_types() except Exception as e: print(f"{TerminalColors.WARNING} add_events_all_services_and_occupant_types Defaults Error", e) try: add_events_to_system_super_user() except Exception as e: print(f"{TerminalColors.WARNING} add_events_to_system_super_user Defaults Error", e) try: if not create_address: return create_one_address(confirmed_dict=confirmed_dict) except Exception as e: print(f"{TerminalColors.WARNING} create_one_address Defaults Error", e) if __name__ == "__main__": print("Service App Initial Default Runner is running") do_alembic() init_alembic_address = True if init_alembic_address: create_application_defaults_func(create_address=False) print("Service App Initial Default Runner is completed")