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

Python pyconfig.get函数代码示例

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

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



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

示例1: test_watching

def test_watching():
    # Enable watching
    os.environ['PYCONFIG_ETCD_WATCH'] = 'true'

    pyconfig.Config().clear()
    pyconfig.set('pyconfig.etcd.prefix', 'pyconfig_test/watching')
    pyconfig.reload()

    # Wait for 20ms before writing to ensure the watcher thread is ready
    time.sleep(0.020)

    # Write a new value directly to etcd
    pyconfig.etcd().client.write('pyconfig_test/watching/it.works', 
            pytool.json.as_json(True))

    # Try to get the value... this is a bit sloppy but good luck doing
    # something better
    retry = 50
    while retry:
        retry -= 1
        if pyconfig.get('it.works', None) is not None:
            break
        # Wait 20ms more for it to show up
        time.sleep(0.020)

    eq_(pyconfig.get('it.works', False), True)
开发者ID:shakefu,项目名称:pyconfig,代码行数:26,代码来源:test_etcd.py


示例2: __init__

 def __init__(self):
     self.host = cfg.get('DBHOST')
     self.port = cfg.get('DBPORT')
     self.name = cfg.get('DBNAME')
     self.collection = cfg.get('COLLECTION')
     self.url = self.get_database_url()
     self.client = MongoClient(self.url)
     self.database = self.client[self.name]
开发者ID:karenberntsen,项目名称:mongo-bdb,代码行数:8,代码来源:database.py


示例3: run_tlsanl

def run_tlsanl(pdb_file_path, xyzout, pdb_id, log_out_dir=".",
               verbose_output=False):
    """Run TLSANL.

    A REFMAC file with residual isotropic B-factors and proper TLS descriptions
    is expected. Total isotropic B-factors are written out in the ATOM and
    ANISOU records.

    WARNING: it is assumed that ATOM & HETATM records in the input PDB must
    first be sorted on chain ID and residue number before the TLS ranges
    can be interpreted.

    Detailed documentation for TLSANL can be found at
    http://www.ccp4.ac.uk/html/tlsanl.html.
    """
    _log.info("Preparing TLSANL run...")
    success = False
    keyworded_input = "BINPUT t\nBRESID t\nISOOUT FULL\nNUMERIC\nEND\n"
    p = subprocess.Popen(["tlsanl", "XYZIN", pdb_file_path, "XYZOUT", xyzout],
                         stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    (stdout, stderr) = p.communicate(input=keyworded_input)
    try:
        with open(os.path.join(log_out_dir, pyconfig.get("TLSANL_LOG")),
                  "w") as tlsanl_log:
            tlsanl_log.write(stdout)
            if verbose_output:
                print(stdout)
        with open(os.path.join(log_out_dir, pyconfig.get("TLSANL_ERR")),
                  "w") as tlsanl_err:
            tlsanl_err.write(stderr)
            if verbose_output:
                print(stderr)
    except IOError as ex:
        _log.error(ex)
    if p.returncode != 0:
        message = "Problem with TLS group definitions (TLSANL run unsuccessful)"
        write_whynot(pdb_id, message)
        _log.error("{0:s}".format(message))
    elif os.stat(xyzout).st_size <= 2000:
        # from script at http://deposit.rcsb.org/adit/REFMAC.html
        message = "TLSANL problem"
        write_whynot(pdb_id, message)
        _log.error("{0:s}".format(message))
    elif os.stat(os.path.join(log_out_dir,
                              pyconfig.get("TLSANL_ERR"))).st_size > 0:
        message = "Problem with TLS group definitions (TLSANL run unsuccessful)"
        write_whynot(pdb_id, message)
        _log.error("{0:s}".format(message))
    else:
        success = True
        _log.info("TLSANL ran without problems.")
    return success
开发者ID:cmbi,项目名称:bdb,代码行数:53,代码来源:tlsanl_wrapper.py


示例4: test_mongo_uri_with_database

def test_mongo_uri_with_database():
    if _version._lt('2.6.0'):
        raise SkipTest("Needs version 2.6.0 or later")

    host = pyconfig.get('humbledb.test.db.host', 'localhost')
    port = pyconfig.get('humbledb.test.db.port', 27017)
    uri = 'mongodb://{}:{}/{}'.format(host, port, database_name())

    class DBuri(Mongo):
            config_uri = uri

    with DBuri:
        eq_(DBuri.database.name, database_name())
        eq_(Mongo.context.database.name, database_name())
开发者ID:shakefu,项目名称:humbledb,代码行数:14,代码来源:test_mongo.py


示例5: main

def main():
    """Create mongo-bdb."""

    parser = argparse.ArgumentParser(
        description='Create a MongoDB document store from bdb json files.')
    parser.add_argument(
        '-q', '--quiet',
        help='show less verbose output',
        action='store_true')
    mode = parser.add_mutually_exclusive_group()
    mode.add_argument('-i', '--insall', help='Insert all documents without ' +
                      'checking if they already exist in the store.',
                      action='store_true')
    mode.add_argument('-u', '--upsert', help='Update all documents. If the ' +
                      'document does not yet exist, it is created.',
                      action='store_true')
    args = parser.parse_args()

    # Set the log level depending on verbosity
    if args.quiet:
        LOG.setLevel(logging.INFO)
        LOG.debug('Configured less verbose logging.')

    crawler = DocumentFinder(cfg.get('DOCUMENT_WILDCARD'))
    LOG.info('Preparing to store {0:d} bdb documents...'.format(
        len(crawler.document_paths)))
    database = Database()

    if args.insall:
        insert_all(database, crawler)
    elif args.upsert:
        upsert_all(database, crawler)

    LOG.info('Finished creating mongo-bdb.')
开发者ID:karenberntsen,项目名称:mongo-bdb,代码行数:34,代码来源:application.py


示例6: create_strava_authorization

def create_strava_authorization():
        id = idgen.getId()
        redirect_url = request.args.get('redirect_uri')

        if redirect_url is None:
            abort(400, 'no redirect_uri parameter provided')

        params = {
                  'client_id': pyconfig.get('strava.client_id'),
                  'redirect_uri': redirect_url,
                  'response_type': 'code',
                  'scope': 'public',
                  'approval_prompt': 'force',
                  'state': id
        }

        auth = {
                'id': id,
                'url': 'https://www.strava.com/oauth/authorize?{params}'.format(params=urllib.urlencode(params)),
                'createdTs': datetime.datetime.utcnow()
        }
        con.authorizations.insert(auth)

        return Response(dumps({
            'id': auth['id'],
            'url': auth['url'],
            'createdTs': str(auth['createdTs'])
        }), mimetype='application/json')
开发者ID:ssteveli,项目名称:stravasocial,代码行数:28,代码来源:api.py


示例7: test_get_default_with_various_values

def test_get_default_with_various_values():
    eq_(pyconfig.get('default_num', 1), 1)
    eq_(pyconfig.get('default_num', 1.0), 1.0)
    eq_(pyconfig.get('default_none', None), None)
    eq_(pyconfig.get('default_true', True), True)
    eq_(pyconfig.get('default_false', False), False)
    eq_(pyconfig.get('default_unicode', 'Test'), 'Test')
    eq_(pyconfig.get('default_expr', 60*24), 60*24)
    eq_(pyconfig.get('ns.test_namespace', 'pyconfig'), 'pyconfig')
开发者ID:QuentinBarrand,项目名称:pyconfig,代码行数:9,代码来源:test_config.py


示例8: test_mongo_uri_database_with_conflict_raises_error

def test_mongo_uri_database_with_conflict_raises_error():
    if _version._lt('2.6.0'):
        raise SkipTest("Needs version 2.6.0 or later")

    host = pyconfig.get('humbledb.test.db.host', 'localhost')
    port = pyconfig.get('humbledb.test.db.port', 27017)
    uri = 'mongodb://{}:{}/{}'.format(host, port, database_name())

    class DBuri(Mongo):
            config_uri = uri

    from humbledb import Document
    class TestDoc(Document):
        config_database = database_name() + '_is_different'
        config_collection = 'test'

    with DBuri:
        TestDoc.find()
开发者ID:shakefu,项目名称:humbledb,代码行数:18,代码来源:test_mongo.py


示例9: start

 def start(cls):
     """ Public function for manually starting a session/context. Use
         carefully!
     """
     if cls in Mongo.contexts:
         raise NestedConnection("Do not nest a connection within itself, it "
                 "may cause undefined behavior.")
     if pyconfig.get('humbledb.allow_explicit_request', True):
         pass#cls.connection.start_request()
     Mongo.contexts.append(cls)
开发者ID:sidneijp,项目名称:humbledb,代码行数:10,代码来源:mongo.py


示例10: end

 def end(cls):
     """ Public function for manually closing a session/context. Should be
         idempotent. This must always be called after :meth:`Mongo.start`
         to ensure the socket is returned to the connection pool.
     """
     if pyconfig.get('humbledb.allow_explicit_request', True):
         pass#cls.connection.end_request()
     try:
         Mongo.contexts.pop()
     except (IndexError, AttributeError):
         pass
开发者ID:sidneijp,项目名称:humbledb,代码行数:11,代码来源:mongo.py


示例11: reload

    def reload(self):
        self.client = MongoClient(pyconfig.get('mongodb.host', 'strava-mongodb'), int(pyconfig.get('mongodb.port', '27017')))
        self.db = self.client.stravasocial
        self.comparisons = self.db.comparisons
        self.authorizations = self.db.authorizations
        self.roles = self.db.roles

        self.gearman_connections = [
            'strava-gearmand:4730'
        ]
        self.gearmanClient = GearmanClient(self.gearman_connections)
        self.ff = FeatureFlags()
开发者ID:ssteveli,项目名称:stravasocial,代码行数:12,代码来源:api.py


示例12: test_auto_increment_errors_with_wrong_db

def test_auto_increment_errors_with_wrong_db():
    if _version._lt('2.6.0'):
        raise SkipTest

    host = pyconfig.get('humbledb.test.db.host', 'localhost')
    port = pyconfig.get('humbledb.test.db.port', 27017)
    uri = 'mongodb://{}:{}/{}'.format(host, port, database_name())

    class DBuri(Mongo):
        config_uri = uri

    class MyDoc2(Document):
        config_database = database_name()
        config_collection = 'test'

        auto = 'a', auto_increment(database_name() + '_is_different', SIDECAR,
                'MyDoc2')


    doc = MyDoc2()
    with DBuri:
        doc.auto
开发者ID:paulnues,项目名称:humbledb,代码行数:22,代码来源:test_helpers.py


示例13: as_live

    def as_live(self):
        """
        Return this call as if it were being assigned in a pyconfig namespace,
        but load the actual value currently available in pyconfig.

        """
        key = self.get_key()
        default = pyconfig.get(key)
        if default:
            default = repr(default)
        else:
            default = self._default() or NotSet()
        return "%s = %s" % (key, default)
开发者ID:bonline,项目名称:pyconfig,代码行数:13,代码来源:scripts.py


示例14: ensure

    def ensure(self, cls):
        """ Does an ensure_index call for this index with the given `cls`.

            :param cls: A Document subclass

        """
        # Allow disabling of index creation
        if not pyconfig.get('humbledb.ensure_indexes', True):
            return

        # Map the attribute name to its key name, or just let it ride
        index = self._resolve_index(cls)

        # Make the ensure index call
        cls.collection.ensure_index(index, **self.kwargs)
开发者ID:shakefu,项目名称:humbledb,代码行数:15,代码来源:index.py


示例15: write_whynot

def write_whynot(pdb_id, reason):
    """Create a WHY NOT file.

    Return a Boolean.
    """
    directory = pyconfig.get("BDB_FILE_DIR_PATH")
    filename = pdb_id + ".whynot"
    _log.warn("Writing WHY NOT entry.")
    try:
        with open(os.path.join(directory, filename), "w") as whynot:
            whynot.write("COMMENT: " + reason + "\n" +
                         "BDB," + pdb_id + "\n")
            return True
    except IOError as ex:
        _log.error(ex)
        return False
开发者ID:cmbi,项目名称:bdb,代码行数:16,代码来源:bdb_utils.py


示例16: test_get_no_default

def test_get_no_default():
    pyconfig.get('get_no_default1', allow_default=False)
开发者ID:QuentinBarrand,项目名称:pyconfig,代码行数:2,代码来源:test_config.py


示例17: test_set_get_change

def test_set_get_change():
    pyconfig.set('set_get_change', 'testing')
    eq_(pyconfig.get('set_get_change'), 'testing')
    pyconfig.set('set_get_change', 'tested')
    eq_(pyconfig.get('set_get_change'), 'tested')
开发者ID:QuentinBarrand,项目名称:pyconfig,代码行数:5,代码来源:test_config.py


示例18: test_set_and_get

def test_set_and_get():
    pyconfig.set('set_and_get', 'tested')
    eq_(pyconfig.get('set_and_get'), 'tested')
开发者ID:QuentinBarrand,项目名称:pyconfig,代码行数:3,代码来源:test_config.py


示例19: test_allow_default

def test_allow_default():
    eq_(pyconfig.get('test_allow_default1'), None)
    eq_(pyconfig.get('test_allow_default2', default=None), None)
    eq_(pyconfig.get('test_allow_default3', 'default_value', allow_default=True),
        'default_value')
开发者ID:QuentinBarrand,项目名称:pyconfig,代码行数:5,代码来源:test_config.py


示例20: reload

 def reload(self):
     self.mongo = MongoClient(pyconfig.get('mongodb.host', 'strava-mongodb'), int(pyconfig.get('mongodb.port', '27017')))
     self.db = self.mongo.stravasocial
     self.plans = self.db.plans
     self.comparisons = self.db.comparisons
开发者ID:ssteveli,项目名称:stravasocial,代码行数:5,代码来源:plans.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pycosat.itersolve函数代码示例发布时间:2022-05-25
下一篇:
Python pyconfdlib._log函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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