コード例 #1
0
def service_get(service_id, session=None):
    result = model_query(service_models.Service, session=session). \
        filter_by(id=service_id). \
        first()
    if not result:
        raise exception.ServiceNotFound(service_id=service_id)
    return result
コード例 #2
0
def count_insert_or_update(name, url):
    print name, url
    session = get_session()
    result = model_query(APICount, session=session). \
        filter_by(name=name). \
        filter_by(url=url). \
        first()
    if not result:
        with session.begin():
            result = APICount()
            result.update({'name': name, 'url': url, 'count': 1})
            result.save()
    else:
        result.count += 1
        result.save(session=session)
    return result
コード例 #3
0
def service_get_by_args(host, binary):
    return model_query(service_models.Service). \
        filter_by(host=host). \
        filter_by(binary=binary). \
        first()
コード例 #4
0
def count_list():
    return model_query(APICount).all()
コード例 #5
0
def service_list():
    return model_query(service_models.Service).all()