nuimo_components.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:senic-hub 作者: getsenic 项目源码 文件源码
def get_nuimo_component_view(request):
    component_id = request.matchdict['component_id']
    mac_address = request.matchdict['mac_address'].replace('-', ':')
    with open(request.registry.settings['nuimo_app_config_path'], 'r') as f:
        config = yaml.load(f)

    try:
        nuimo = config['nuimos'][mac_address]
    except (KeyError, TypeError):
        return HTTPNotFound("No Nuimo with such ID")

    components = nuimo['components']
    try:
        return next(c for c in components if c['id'] == component_id)
    except StopIteration:
        raise HTTPNotFound
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号