• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python config.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load_project_config

    def load_project_config(self):
        """Choose the config file.

        Try to guess whether this is a development or installed project.

        """

        # check whether user specified custom settings
        if self.load_config:
            load_project_config(self.config)

        if config.get("i18n.locale_dir"):
            self.locale_dir = config.get("i18n.locale_dir")
            print 'Use %s as a locale directory' % self.locale_dir
        if config.get('i18n.domain'):
            self.domain = config.get("i18n.domain")
            print 'Use %s as a message domain' % self.domain

        if os.path.exists(self.locale_dir) and \
                not os.path.isdir(self.locale_dir):
            raise ProgramError, (
                '%s is not a directory' % self.locale_dir)

        if not os.path.exists(self.locale_dir):
            os.makedirs(self.locale_dir)
开发者ID:OnShift,项目名称:turbogears,代码行数:25,代码来源:i18n.py


示例2: __init__

 def __init__(self, *args, **kw):
   super(ErrorCatcher, self).__init__(*args, **kw)
   self.sender_email = config.get('error_catcher.sender_email')
   self.admin_email = config.get('error_catcher.admin_email')
   self.smtp_host = config.get('error_catcher.smtp_host', 'localhost')
   self.smtp_user = config.get('error_catcher.smtp_user')
   self.smtp_passwd = config.get('error_catcher.smtp_passwd')
开发者ID:aidanappleCO,项目名称:gheimdall,代码行数:7,代码来源:controllers.py


示例3: wait_for_sync

 def wait_for_sync(self):
     """
     Block until our repomd.xml hits the master mirror
     """
     if not len(self.updates):
         log.debug("No updates in masher; skipping wait_for_sync")
         return
     log.info("Waiting for updates to hit mirror...")
     update = self.updates.pop()
     release = update.release
     self.updates.add(update)
     mashdir = config.get("mashed_dir")
     repo = release.stable_repo
     master_repomd = config.get("%s_master_repomd" % release.id_prefix.lower().replace("-", "_"))
     repomd = join(mashdir, repo, "i386", "repodata", "repomd.xml")
     if not exists(repomd):
         log.error("Cannot find local repomd: %s" % repomd)
         return
     checksum = sha.new(file(repomd).read()).hexdigest()
     while True:
         sleep(600)
         try:
             masterrepomd = urllib2.urlopen(master_repomd % release.get_version())
         except urllib2.URLError, e:
             log.error("Error fetching repomd.xml: %s" % str(e))
             continue
         except urllib2.HTTPError, e:
             log.error("Error fetching repomd.xml: %s" % str(e))
             continue
开发者ID:kmcdowell85,项目名称:bodhi,代码行数:29,代码来源:masher.py


示例4: _create_runtime_env

def _create_runtime_env():
    directory = config.get('basepath.assets',
            # default location is at the base of our source tree
            os.path.join(os.path.dirname(__file__), '..', '..', 'assets'))
    debug = config.get('assets.debug')
    auto_build = config.get('assets.auto_build')
    return _create_env(directory=directory, debug=debug, auto_build=auto_build)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:7,代码来源:assets.py


示例5: insert_pkgtags

    def insert_pkgtags(self):
        """ Download and inject the pkgtags sqlite from the pkgdb """
        if config.get('pkgtags_url') not in [None, ""]:
            try:
                for arch in os.listdir(self.repo):
                    if arch == 'SRPMS':
                        continue
                    filename = ''
                    reponame = os.path.basename(self.repo)
                    if reponame.startswith('f'):
                        release = reponame[1:].split('-')[0]
                        filename = 'F-%s-%s-' % (release, arch)
                        if 'testing' in reponame:
                            filename += 'tu'
                        else:
                            filename += 'u'
                    elif reponame.startswith('el'):
                        release = reponame[2:].split('-')[0]
                        filename = 'E-%s-%s' % (release, arch)
                        if 'testing' in reponame:
                            filename += '-t'
                    else:
                        log.error('Unknown repo %s' % reponame)
                        return

                    tags_url = config.get('pkgtags_url') + filename
                    log.info('Downloading %s' % tags_url)
                    f = urllib.urlretrieve(tags_url, filename='/tmp/pkgtags.sqlite')

                    repomd = RepoMetadata(join(self.repo, arch, 'repodata'))
                    repomd.add('/tmp/pkgtags.sqlite')

            except Exception, e:
                log.exception(e)
                log.error("There was a problem injecting pkgtags")
开发者ID:ralphbean,项目名称:bodhi,代码行数:35,代码来源:metadata.py


示例6: render

def render(info, template=None, format=None ,content_type=None, mapping=None, fragment=False):
    """Renders data in the desired format.

    @param info: the data itself
    @type info: dict
    @param format: "html", "xml" or "json"
    @type format: string
    @param fragment: passed through to tell the template if only a
                     fragment of a page is desired
    @type fragment: bool
    @param template: name of the template to use
    @type template: string
    """
    template = info.pop("tg_template", template)
    if not info.has_key("tg_flash"):
        if config.get("tg.empty_flash", True):
            info["tg_flash"] = None
    engine, template, enginename = _choose_engine(template)
    if  not content_type and getattr(engine, 'get_content_type', None):
        ua = getattr(cherrypy.request.headers, "User-Agent", None)
        ua = UserAgent(ua)
        content_type = engine.get_content_type(ua)
    elif not content_type:
        content_type = "text/html"
    if content_type == 'text/html' and enginename in ('genshi', 'kid'):
        charset = get_template_encoding_default(enginename)
        content_type = content_type + '; charset=' + charset
    cherrypy.response.headers["Content-Type"] = content_type
    if not format:
        format = config.get("%s.outputformat" % enginename, "html") 
    args, kw = adapt_call(engine.render, args= [],
                kw = dict(info=info, format=format, fragment=fragment, template=template, mapping=mapping), start=1)
    return engine.render(**kw)
开发者ID:thraxil,项目名称:gtreed,代码行数:33,代码来源:base.py


示例7: sync_user_to_ipa

 def sync_user_to_ipa(self, user, user_name, password):
     if user.ipa_sync_status is None:
         os.system('kinit -k -t %s %s' % (config.get('ipa_sync_keytab'),
                                          config.get('ipa_sync_principal')))
         r = requests.post('https://%s/ipa/json'
                           % config.get('ipa_sync_server'),
             json={'method': 'user_add',
                   'params':[
                       [user_name],
                       {'givenname': 'FAS',
                        'sn': 'Synced',
                        'cn': user_name,
                        'userpassword': password
                       }], 
                   'id': 0},
             verify=config.get('ipa_sync_certfile'),
             auth=HTTPKerberosAuth(),
             headers={'referer':
                      'https://%s/ipa'
                      % config.get('ipa_sync_server')}).json()
         if r['error'] is None:
             log.info('User %s synced to IPA' % user_name)
             user.ipa_sync_status = 'success'
         else:
             user.ipa_sync_status = 'error:%s' % r['error']['message']
             log.error('Error syncing %s: %s' % (user_name, 
                                                 r['error']['message']))
开发者ID:fedora-infra,项目名称:fas,代码行数:27,代码来源:safasprovider.py


示例8: _execute_func

def _execute_func(func, template, format, content_type, mapping, fragment, args, kw):
    """Call controller method and process it's output."""
    if config.get("tg.strict_parameters", False):
        tg_util.remove_keys(kw, ["tg_random", "tg_format"]
            + config.get("tg.ignore_parameters", []))
    else:
        # get special parameters used by upstream decorators like paginate
        try:
            tg_kw = dict([(k, v) for k, v in kw.items() if k in func._tg_args])
        except AttributeError:
            tg_kw = {}
        # remove excessive parameters
        args, kw = tg_util.adapt_call(func, args, kw)
        # add special parameters again
        kw.update(tg_kw)
    if config.get('server.environment', 'development') == 'development':
        # Only output this in development mode: If it's a field storage object,
        # this means big memory usage, and we don't want that in production
        log.debug("Calling %s with *(%s), **(%s)", func, args, kw)
    output = errorhandling.try_call(func, *args, **kw)
    assert isinstance(output, (basestring, dict, list, types.GeneratorType)), \
           "Method %s.%s() returned unexpected output. Output should " \
           "be of type basestring, dict, list or generator." % (
            args[0].__class__.__name__, func.__name__)
    if isinstance(output, dict):
        template = output.pop("tg_template", template)
        format = output.pop("tg_format", format)
    if template and template.startswith("."):
        template = func.__module__[:func.__module__.rfind('.')]+template
    return _process_output(output, template, format, content_type, mapping, fragment)
开发者ID:mjonescase,项目名称:turbogears,代码行数:30,代码来源:controllers.py


示例9: start_extension

def start_extension():
    global _manager

    # Bail out if the application hasn't enabled this extension
    if not config.get("visit.on", False):
        return

    # Bail out if this extension is already running
    if _manager:
        log.warning("Visit manager already running.")
        return

    # How long may the visit be idle before a new visit ID is assigned?
    # The default is 20 minutes.
    timeout = timedelta(minutes=config.get("visit.timeout", 20))
    log.info("Visit Tracking starting (timeout = %i sec).", timeout.seconds)
    # Create the thread that manages updating the visits
    _manager = _create_visit_manager(timeout)

    visit_filter = VisitFilter()
    # Install Filter into the root filter chain
    if not hasattr(cherrypy.root, "_cp_filters"):
        cherrypy.root._cp_filters = list()
    if not visit_filter in cherrypy.root._cp_filters:
        cherrypy.root._cp_filters.append(visit_filter)
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:25,代码来源:api.py


示例10: _create_runtime_env

def _create_runtime_env():
    source_dir = config.get('basepath.assets')
    output_dir = config.get('basepath.assets_cache')
    debug = config.get('assets.debug')
    auto_build = config.get('assets.auto_build')
    return _create_env(source_dir=source_dir, output_dir=output_dir,
            debug=debug, auto_build=auto_build)
开发者ID:beaker-project,项目名称:beaker,代码行数:7,代码来源:assets.py


示例11: mail_changed_email_validation

 def mail_changed_email_validation(self, new_email):
     '''
         Sends an email out that has validation information for changed email addresses.
         The logic is that we keep the old (verified) email in the User table, and add the
         new information into the RegistrationUserEmailChange table.  When the user eventually
         validates the new address, we delete the information out of RegistrationUserEmailChange
         and put the new email address into User table.  That way, we always have a "good" email
         address in the User table.
     
         @param new_email: The new email
     '''
     
     unique_str = new_email + identity.current.user.email_address
     validation_key = self.validation_hash(unique_str)
     email_change = register_model.RegistrationUserEmailChange.new(
                                         user=identity.current.user,
                                         new_email_address=new_email,
                                         validation_key=validation_key)
     reg_base_url = self.registration_base_url()
     queryargs = urllib.urlencode(dict(email=new_email, 
                                       key=validation_key))
     url = '%s/validate_email_change?%s' % (reg_base_url, queryargs)
                                         
     body = pkg_resources.resource_string(__name__, 
                                         'templates/register_changed_email.txt')
     self.send_email(new_email,
                 config.get('registration.mail.admin_email'), 
                 config.get('registration.mail.changed_email.subject', 
                             'Please verify your new email address'),
                 body % {'validation_url': url})
开发者ID:macagua,项目名称:SPREE,代码行数:30,代码来源:register_controllers.py


示例12: get_pkg_pushers

def get_pkg_pushers(pkg, branch):
    watchers = []
    committers = []
    watchergroups = []
    committergroups = []

    if config.get('acl_system') == 'dummy':
        return ((['guest', 'admin'], ['guest', 'admin']),
                (['guest', 'admin'], ['guest', 'admin']))

    from pkgdb2client import PkgDB
    pkgdb = PkgDB(config.get('pkgdb_url'))
    acls = pkgdb.get_package(pkg, branches=branch)

    for package in acls['packages']:
        for acl in package.get('acls', []):
            if acl['status'] == 'Approved':
                if acl['acl'] == 'watchcommits':
                    name = acl['fas_name']
                    if name.startswith('group::'):
                        watchergroups.append(name.split('::')[1])
                    else:
                        watchers.append(name)
                elif acl['acl'] == 'commit':
                    name = acl['fas_name']
                    if name.startswith('group::'):
                        committergroups.append(name.split('::')[1])
                    else:
                        committers.append(name)

    return (committers, watchers), (committergroups, watchergroups)
开发者ID:bitlord,项目名称:bodhi,代码行数:31,代码来源:util.py


示例13: validate_password

    def validate_password(self, user, user_name, password):
        '''
        Check the supplied user_name and password against existing credentials.
        Note: user_name is not used here, but is required by external
        password validation schemes that might override this method.
        If you use SaFasIdentityProvider, but want to check the passwords
        against an external source (i.e. PAM, LDAP, Windows domain, etc),
        subclass SaFasIdentityProvider, and override this method.

        :user: User information.  Not used.
        :user_name: Given username.
        :password: Given, plaintext password.
        :returns: True if the password matches the username.  Otherwise False.
            Can return False for problems within the Account System as well.
        '''
        # crypt.crypt(stuff, '') == ''
        # Just kill any possibility of blanks.
        if not user.password:
            return False
        if not password:
            return False

        # Check if yubi-authentication is being used
        if len(password) == 44 and password.startswith('ccccc') and config.get('yubi_server_prefix', False):
            if config.get('yubi_enabled', False):
                return otp_validate(user_name, password)
            flash(_("Yubikey single-factor authentication has been disabled."))
            return False

        # TG identity providers take user_name in case an external provider
        # needs it so we can't get rid of it. (W0613)
        # pylint: disable-msg=W0613
        return user.password == crypt.crypt(password.encode('utf-8'), user.password)
开发者ID:chepioq,项目名称:fas,代码行数:33,代码来源:safasprovider.py


示例14: start_bonjour

def start_bonjour(package=None):
    """Register the TurboGears server with the Bonjour framework.

    Currently only Unix-like systems are supported where either the 'avahi'
    daemon (Linux etc.) is available or the 'dns-sd' program (Mac OS X).

    """
    global DNS_SD_PID
    if DNS_SD_PID:
        return
    if not getattr(cherrypy, 'root', None):
        return
    if not package:
        package = cherrypy.root.__module__
        package = package[:package.find(".")]

    host = config.get('server.socket_host', '')
    port = str(config.get('server.socket_port'))
    env = config.get('server.environment')
    name = package + ": " + env
    type = "_http._tcp"

    cmds = [['/usr/bin/avahi-publish-service', ["-H", host, name, type, port]],
            ['/usr/bin/dns-sd', ['-R', name, type, "."+host, port, "path=/"]]]

    for cmd, args in cmds:
        # TODO:. This check is flawed.  If one has both services installed and
        # avahi isn't the one running, then this won't work.  We should either
        # try registering with both or checking what service is running and use
        # that.  Program availability on the filesystem was never enough...
        if exists(cmd):
            DNS_SD_PID = os.spawnv(os.P_NOWAIT, cmd, [cmd]+args)
            atexit.register(stop_bonjour)
            break
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:34,代码来源:startup.py


示例15: undeprecated_cla_done

def undeprecated_cla_done(person):
    '''Checks if the user has completed the cla.

    As opposed to :func:`cla_done`, this method returns information about both
    whether the cla has been satisfied and whether the cla has been satisfied
    by a deprecated method.  This is useful if you have switched to a new CLA
    and want to have a transition period where either CLA is okay but you want
    to warn people that they need to sign the new version.

    :arg person: People object or username to check for FPCA status
    :rtype: tuple
    :returns: The first element of the tuple is True if the cla_done_group is
        approved otherwise False.  The second element of the tuple is True if
        a non-deprecated cla group is approved, otherwise False.
    '''
    cla_done_group = config.get('cla_done_group')
    cla_deprecated = frozenset(config.get('cla_deprecated_groups', []))

    if isinstance(person, basestring):
        name = person
    else:
        name = person.username

    cla_roles = set()
    for role in PersonRoles.query.filter_by(role_status='approved').join('group'
            ).filter(GroupsTable.c.group_type=='cla').join('member'
                    ).filter_by(username=name).all():
        cla_roles.add(role.group.name)

    # If the cla is considered signed only because of deprecated groups, 
    # return negative here.
    cla_roles.difference_update(cla_deprecated)
    if len(cla_roles) >= 2:
        return (cla_done_group in cla_roles, True)
    return (cla_done_group in cla_roles, False)
开发者ID:Affix,项目名称:fas,代码行数:35,代码来源:auth.py


示例16: login

  def login(self, SAMLRequest, RelayState='', *args, **kw):
    if config.get('apps.use_header_auth'):
      # header auth
      # retrieve user name from header
      key = config.get('apps.auth_header_key')
      user_name = cherrypy.request.headers.get(key, None)
      if user_name is None:
        raise errors.GheimdallException('Can not retrieve user name.')

      ret = utils.createLoginDict(SAMLRequest, RelayState, user_name)
      ret['tg_template'] = 'gheimdall.templates.gheimdall-login-success'
      return ret

    remember_me = None
    authenticated = None
    remember_me = cherrypy.session.get('remember_me', False)
    authenticated = cherrypy.session.get('authenticated', False)
    if remember_me and authenticated:
      auth_time = cherrypy.session.get('auth_time', 0)
      valid_time = cherrypy.session.get('valid_time', 0)
      now = time.time()
      if auth_time < now and now < valid_time:
        ret = utils.createLoginDict(SAMLRequest, RelayState,
                                    cherrypy.session.get('user_name'),
                                    set_time=False)
        ret['tg_template'] = 'gheimdall.templates.gheimdall-login-success'
        return ret

    tg_exception = kw.get('tg_exceptions', None)
    if tg_exception is not None:
      log.error(tg_exception)
    return dict(form=login_form_widget,
                values=dict(SAMLRequest=SAMLRequest,RelayState=RelayState))
开发者ID:aidanappleCO,项目名称:gheimdall,代码行数:33,代码来源:controllers.py


示例17: __init__

 def __init__(self, *args, **kw):
     super(ErrorCatcher, self).__init__(*args, **kw)
     self.sender_email = config.get("error_catcher.sender_email")
     self.admin_email = config.get("error_catcher.admin_email")
     self.smtp_host = config.get("error_catcher.smtp_host", "localhost")
     self.smtp_user = config.get("error_catcher.smtp_user")
     self.smtp_passwd = config.get("error_catcher.smtp_passwd")
开发者ID:agrover,项目名称:BandRadar,代码行数:7,代码来源:errorlogger.py


示例18: get_carbon

def get_carbon():
    global _carbon
    if _carbon is not None:
        return _carbon
    _carbon = CarbonSender(config.get('carbon.address'),
            config.get('carbon.prefix', 'beaker.'))
    return _carbon
开发者ID:beaker-project,项目名称:beaker,代码行数:7,代码来源:metrics.py


示例19: update_comps

    def update_comps(self):
        """
        Update our comps module, so we can pass it to mash to stuff into
        our repositories
        """
        log.debug("Updating comps...")
        comps_dir = config.get("comps_dir")
        comps_url = config.get("comps_url")
        if not exists(comps_dir):
            if comps_url.startswith("git://"):
                cmd = "git clone %s" % (comps_url,)
            else:
                cmd = "cvs -d %s co comps" % (comps_url,)
            log.debug("running command: %s" % cmd)
            subprocess.call(cmd, shell=True, cwd=comps_dir)
        if comps_url.startswith("git://"):
            log.debug("Running git pull")
            p = subprocess.Popen("git pull", shell=True, cwd=comps_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            out, err = p.communicate()
            log.debug(out)
            if err:
                log.error(err)
        else:
            subprocess.call("cvs update", shell=True, cwd=comps_dir)

        log.info("Merging translations")
        p = subprocess.Popen("make", shell=True, cwd=comps_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out, err = p.communicate()
        log.debug(out)
        if err:
            log.error(err)
开发者ID:kmcdowell85,项目名称:bodhi,代码行数:31,代码来源:masher.py


示例20: absolute_url

def absolute_url(tgpath, tgparams=None, scheme=None, 
                 labdomain=False, webpath=True, **kw):
    """
    Like turbogears.url, but makes the URL absolute (with scheme, hostname, 
    and port from the tg.url_scheme and tg.url_domain configuration 
    directives).
    If labdomain is True we serve an alternate tg.proxy_domain if defined
    in server.cfg.  This is to support multi-home systems which have
    different external vs internal names.
    """
    order = []
    if labdomain:
        order.append(config.get('tg.lab_domain'))
    order.extend([config.get('tg.url_domain'),
                  config.get('servername'),
                  socket.getfqdn()])

    # TODO support relative paths
    if webpath:
        theurl = url(tgpath, tgparams, **kw)
    else:
        theurl = url_no_webpath(tgpath, tgparams, **kw)
    assert theurl.startswith('/')
    scheme = scheme or config.get('tg.url_scheme', 'http')
    host_port = filter(None, order)[0]
    return '%s://%s%s' % (scheme, host_port, theurl)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:26,代码来源:util.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python config.update函数代码示例发布时间:2022-05-27
下一篇:
Python turbogears.url函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap