def main(argv=sys.argv): if len(argv) != 5: usage(argv) config_uri = argv[1] setup_logging(config_uri) pwd_context.load_path(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) username = argv[2] password = argv[3] group = argv[4] with transaction.manager: group_criteria = Group.name == group group_params = {'name': group} group = Group.get_or_create( group_criteria, **group_params) user = User() user.group = group profile = UserProfile( user=user, username=username, password=password) ona_user_params = { 'user': user, 'username': username, 'refresh_token': 'test'} ona_user = OnaUser.get_or_create( OnaUser.username == username, **ona_user_params) DBSession.add_all([user, profile, ona_user])
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) import_health_data()
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) parse_municipalities_from_submissions()
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: user = User() DBSession.add_all([user])
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine session_factory = SignedCookieSessionFactory( settings['secret_key']) config = Configurator(settings=settings, root_factory='whoahqa.models.RootFactory', session_factory=session_factory) config.set_authentication_policy( AuthTktAuthenticationPolicy(settings['secret_key'], callback=group_finder, hashalg='sha512')) config.set_authorization_policy(ACLAuthorizationPolicy()) config.set_default_permission(perms.AUTHENTICATED) # Add custom renderers config.add_renderer('csv', 'whoahqa.renderers.CSVRenderer') # Add request object helpers add_request_helpers(config) # setup the hashid salt hashid._salt = settings['hashid_salt'] # add locale directory to project configuration config.add_translation_dirs('whoahqa:locale') # configure enketo enketo.configure( settings['enketo_url'], settings['enketo_api_token']) logging.config.fileConfig( global_config['__file__'], disable_existing_loggers=False) # configure password context pwd_context.load_path(global_config['__file__']) includeme(config) if settings.get("environment", "") == DEVELOPMENT_ENV: setup_development_data() return config.make_wsgi_app()
def main(argv=sys.argv): if len(argv) != 3: usage(argv) config_uri = argv[1] form_id = argv[2] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) client_tool_list = [ key for key, _ in itertools.chain(constants.CLIENT_TOOLS, constants.CLIENT_TOOLS_V2) ] if form_id in client_tool_list: import_submissions_for(form_id)