当前位置: 首页>>代码示例>>Python>>正文


Python conf.get函数代码示例

本文整理汇总了Python中superset.conf.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: common_bootsrap_payload

 def common_bootsrap_payload(self):
     """Common data always sent to the client"""
     messages = get_flashed_messages(with_categories=True)
     locale = str(get_locale())
     return {
         'flash_messages': messages,
         'conf': {k: conf.get(k) for k in FRONTEND_CONF_KEYS},
         'locale': locale,
         'language_pack': get_language_pack(locale),
         'feature_flags': conf.get('FEATURE_FLAGS'),
     }
开发者ID:bkyryliuk,项目名称:caravel,代码行数:11,代码来源:base.py

示例2: sync_role_definitions

def sync_role_definitions():
    """Inits the Superset application with security roles and such"""
    logging.info("Syncing role definition")

    get_or_create_main_db()
    create_custom_permissions()

    pvms = db.session.query(ab_models.PermissionView).all()
    pvms = [p for p in pvms if p.permission and p.view_menu]

    # cleanup
    pvms_to_delete = [p for p in pvms if not (p.permission and p.view_menu)]

    for pvm_to_delete in pvms_to_delete:
        sm.get_session.delete(pvm_to_delete)

    # Creating default roles
    set_role('Admin', pvms, is_admin_pvm)
    set_role('Alpha', pvms, is_alpha_pvm)
    set_role('Gamma', pvms, is_gamma_pvm)
    set_role('granter', pvms, is_granter_pvm)
    set_role('sql_lab', pvms, is_sql_lab_pvm)

    if conf.get('PUBLIC_ROLE_LIKE_GAMMA', False):
        set_role('Public', pvms, is_gamma_pvm)

    view_menu_set = db.session.query(models.SqlaTable).all()
    create_missing_datasource_perms(view_menu_set)
    create_missing_database_perms(view_menu_set)
    create_missing_metrics_perm(view_menu_set)

    # commit role and view menu updates
    sm.get_session.commit()
开发者ID:kiskong,项目名称:superset,代码行数:33,代码来源:security.py

示例3: get_or_create_main_db

def get_or_create_main_db():
    logging.info("Creating database reference")
    dbobj = (
        db.session.query(models.Database)
        .filter_by(database_name='main')
        .first()
    )
    if not dbobj:
        dbobj = models.Database(database_name="main")
    logging.info(conf.get("SQLALCHEMY_DATABASE_URI"))
    dbobj.set_sqlalchemy_uri(conf.get("SQLALCHEMY_DATABASE_URI"))
    dbobj.expose_in_sqllab = True
    dbobj.allow_run_sync = True
    db.session.add(dbobj)
    db.session.commit()
    return dbobj
开发者ID:kiskong,项目名称:superset,代码行数:16,代码来源:security.py

示例4: refresh_datasources

 def refresh_datasources(self, datasource_name=None, merge_flag=False):
     """Refresh metadata of all datasources in the cluster
     If ``datasource_name`` is specified, only that datasource is updated
     """
     self.druid_version = self.get_druid_version()
     for datasource in self.get_datasources():
         if datasource not in conf.get('DRUID_DATA_SOURCE_BLACKLIST', []):
             if not datasource_name or datasource_name == datasource:
                 DruidDatasource.sync_to_db(datasource, self, merge_flag)
开发者ID:avsolatorio,项目名称:caravel,代码行数:9,代码来源:models.py

示例5: get_error_msg

def get_error_msg():
    if conf.get("SHOW_STACKTRACE"):
        error_msg = traceback.format_exc()
    else:
        error_msg = "FATAL ERROR \n"
        error_msg += (
            "Stacktrace is hidden. Change the SHOW_STACKTRACE "
            "configuration setting to enable it")
    return error_msg
开发者ID:rahulsingh303,项目名称:incubator-superset,代码行数:9,代码来源:base.py

示例6: latest_metadata

 def latest_metadata(self):
     """Returns segment metadata from the latest segment"""
     client = self.cluster.get_pydruid_client()
     results = client.time_boundary(datasource=self.datasource_name)
     if not results:
         return
     max_time = results[0]['result']['maxTime']
     max_time = dparse(max_time)
     # Query segmentMetadata for 7 days back. However, due to a bug,
     # we need to set this interval to more than 1 day ago to exclude
     # realtime segments, which triggered a bug (fixed in druid 0.8.2).
     # https://groups.google.com/forum/#!topic/druid-user/gVCqqspHqOQ
     lbound = (max_time - timedelta(days=7)).isoformat()
     rbound = max_time.isoformat()
     if not self.version_higher(self.cluster.druid_version, '0.8.2'):
         rbound = (max_time - timedelta(1)).isoformat()
     segment_metadata = None
     try:
         segment_metadata = client.segment_metadata(
             datasource=self.datasource_name,
             intervals=lbound + '/' + rbound,
             merge=self.merge_flag,
             analysisTypes=conf.get('DRUID_ANALYSIS_TYPES'))
     except Exception as e:
         logging.warning("Failed first attempt to get latest segment")
         logging.exception(e)
     if not segment_metadata:
         # if no segments in the past 7 days, look at all segments
         lbound = datetime(1901, 1, 1).isoformat()[:10]
         rbound = datetime(2050, 1, 1).isoformat()[:10]
         if not self.version_higher(self.cluster.druid_version, '0.8.2'):
             rbound = datetime.now().isoformat()[:10]
         try:
             segment_metadata = client.segment_metadata(
                 datasource=self.datasource_name,
                 intervals=lbound + '/' + rbound,
                 merge=self.merge_flag,
                 analysisTypes=conf.get('DRUID_ANALYSIS_TYPES'))
         except Exception as e:
             logging.warning("Failed 2nd attempt to get latest segment")
             logging.exception(e)
     if segment_metadata:
         return segment_metadata[-1]['columns']
开发者ID:avsolatorio,项目名称:caravel,代码行数:43,代码来源:models.py

示例7: get_or_create_main_db

def get_or_create_main_db():
    from superset import conf, db
    from superset.models import core as models

    logging.info('Creating database reference')
    dbobj = get_main_database(db.session)
    if not dbobj:
        dbobj = models.Database(database_name='main')
    dbobj.set_sqlalchemy_uri(conf.get('SQLALCHEMY_DATABASE_URI'))
    dbobj.expose_in_sqllab = True
    dbobj.allow_csv_upload = True
    db.session.add(dbobj)
    db.session.commit()
    return dbobj
开发者ID:bkyryliuk,项目名称:caravel,代码行数:14,代码来源:core.py

示例8: refresh_datasources

 def refresh_datasources(
         self,
         datasource_name=None,
         merge_flag=True,
         refreshAll=True):
     """Refresh metadata of all datasources in the cluster
     If ``datasource_name`` is specified, only that datasource is updated
     """
     self.druid_version = self.get_druid_version()
     ds_list = self.get_datasources()
     blacklist = conf.get('DRUID_DATA_SOURCE_BLACKLIST', [])
     ds_refresh = []
     if not datasource_name:
         ds_refresh = list(filter(lambda ds: ds not in blacklist, ds_list))
     elif datasource_name not in blacklist and datasource_name in ds_list:
         ds_refresh.append(datasource_name)
     else:
         return
     self.refresh_async(ds_refresh, merge_flag, refreshAll)
开发者ID:ythzx,项目名称:incubator-superset,代码行数:19,代码来源:models.py

示例9: sync_role_definitions

def sync_role_definitions():
    """Inits the Superset application with security roles and such"""
    logging.info("Syncing role definition")

    get_or_create_main_db()
    create_custom_permissions()

    # Creating default roles
    set_role('Admin', is_admin_pvm)
    set_role('Alpha', is_alpha_pvm)
    set_role('Gamma', is_gamma_pvm)
    set_role('granter', is_granter_pvm)
    set_role('sql_lab', is_sql_lab_pvm)

    if conf.get('PUBLIC_ROLE_LIKE_GAMMA', False):
        set_role('Public', is_gamma_pvm)

    create_missing_perms()

    # commit role and view menu updates
    sm.get_session.commit()
开发者ID:invenis-paris,项目名称:incubator-superset,代码行数:21,代码来源:security.py

示例10: sync_role_definitions

    def sync_role_definitions(self):
        """Inits the Superset application with security roles and such"""
        from superset import conf
        logging.info('Syncing role definition')

        self.create_custom_permissions()

        # Creating default roles
        self.set_role('Admin', self.is_admin_pvm)
        self.set_role('Alpha', self.is_alpha_pvm)
        self.set_role('Gamma', self.is_gamma_pvm)
        self.set_role('granter', self.is_granter_pvm)
        self.set_role('sql_lab', self.is_sql_lab_pvm)

        if conf.get('PUBLIC_ROLE_LIKE_GAMMA', False):
            self.set_role('Public', self.is_gamma_pvm)

        self.create_missing_perms()

        # commit role and view menu updates
        self.get_session.commit()
        self.clean_perms()
开发者ID:tan31989,项目名称:caravel,代码行数:22,代码来源:security.py

示例11: import

import sqlalchemy as sa
from sqlalchemy import (
    Boolean, Column, DateTime, ForeignKey, Integer, or_, String, Text, UniqueConstraint,
)
from sqlalchemy.orm import backref, relationship

from superset import conf, db, import_util, sm, utils
from superset.connectors.base.models import BaseColumn, BaseDatasource, BaseMetric
from superset.models.helpers import (
  AuditMixinNullable, ImportMixin, QueryResult, set_perm,
)
from superset.utils import (
    DimSelector, DTTM_ALIAS, flasher, MetricPermException,
)

DRUID_TZ = conf.get('DRUID_TZ')


# Function wrapper because bound methods cannot
# be passed to processes
def _fetch_metadata_for(datasource):
    return datasource.latest_metadata()


class JavascriptPostAggregator(Postaggregator):
    def __init__(self, name, field_names, function):
        self.post_aggregator = {
            'type': 'javascript',
            'fieldNames': field_names,
            'name': name,
            'function': function,
开发者ID:johnsonc,项目名称:caravel,代码行数:31,代码来源:models.py

示例12: import

from pydruid.utils.having import Aggregation

from flask import Markup, escape
from flask_appbuilder.models.decorators import renders
from flask_appbuilder import Model

from flask_babel import lazy_gettext as _

from superset import conf, db, import_util, utils, sm, get_session
from superset.utils import (
    flasher, MetricPermException, DimSelector, DTTM_ALIAS
)
from superset.connectors.base.models import BaseDatasource, BaseColumn, BaseMetric
from superset.models.helpers import AuditMixinNullable, QueryResult, set_perm

DRUID_TZ = conf.get("DRUID_TZ")


# Function wrapper because bound methods cannot
# be passed to processes
def _fetch_metadata_for(datasource):
    return datasource.latest_metadata()


class JavascriptPostAggregator(Postaggregator):
    def __init__(self, name, field_names, function):
        self.post_aggregator = {
            'type': 'javascript',
            'fieldNames': field_names,
            'name': name,
            'function': function,
开发者ID:ythzx,项目名称:incubator-superset,代码行数:31,代码来源:models.py

示例13: get_user_roles

def get_user_roles():
    if g.user.is_anonymous():
        public_role = conf.get('AUTH_ROLE_PUBLIC')
        return [appbuilder.sm.find_role(public_role)] if public_role else []
    return g.user.roles
开发者ID:herotan24,项目名称:incubator-superset,代码行数:5,代码来源:base.py

示例14: get_user_roles

def get_user_roles():
    if g.user.is_anonymous:
        public_role = conf.get('AUTH_ROLE_PUBLIC')
        return [security_manager.find_role(public_role)] if public_role else []
    return g.user.roles
开发者ID:neuroradiology,项目名称:caravel,代码行数:5,代码来源:base.py

示例15: get_table_access_link

 def get_table_access_link(self, tables):
     from superset import conf
     return conf.get('PERMISSION_INSTRUCTIONS_LINK')
开发者ID:tan31989,项目名称:caravel,代码行数:3,代码来源:security.py


注:本文中的superset.conf.get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。