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


Python Report.get_by_id方法代码示例

本文整理汇总了Python中models.Report.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Report.get_by_id方法的具体用法?Python Report.get_by_id怎么用?Python Report.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Report的用法示例。


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

示例1: stats

# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import get_by_id [as 别名]
def stats(table, zone=None, format="csv"):

    reports = request.args.get('reports', None)
    if not reports:
        abort(400)
    try:
        reports = map(int, reports.split(','))
    except ValueError:
        logging.error("bad format for report id")
        abort(400)

    this_report = ReportType.factory(format)
    this_report.init(zone)
    this_report.write_header()

    logging.info("table id is %s ", table)
    logging.info("and we see %s ", FustionTablesNames.all().filter('table_id =', table).fetch(1))
    logging.info("and zone %s ", zone)
    logging.info("and format %s ", format)

    reports = [Report.get_by_id(x) for x in reports]
    for r in reports:
        if not r:
            logging.error("report not found")
            abort(404)

        stats = this_report.get_stats(r, table)

        for s in stats:
            this_report.write_row(r, s, table)

    this_report.write_footer()
    return this_report.response("report_%s" % table)
开发者ID:dyeden,项目名称:DeforestationAnalysisTool,代码行数:35,代码来源:api.py

示例2: report_get

# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import get_by_id [as 别名]
 def report_get(self, request):
     item = Report.get_by_id(request.id)
     current_user = users.get_current_user()
     if item and item.author == current_user.author:
         return item.to_message()
     else:
         raise endpoints.NotFoundException('Report %s not found.' %
                                           (request.id,))
开发者ID:htomika,项目名称:gaeFeedFind,代码行数:10,代码来源:parser_api.py

示例3: polygon_stats

# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import get_by_id [as 别名]
def polygon_stats(format=None):
    reports = request.args.get('reports', None)
    if not reports:
        abort(400)
    try:
        reports = map(int, reports.split(','))
    except ValueError:
        logging.error("bad format for report id")
        abort(400)

    try:
        reports = [Report.get_by_id(x) for x in reports]
    except ValueError:
        logging.error("can't find some report")
        abort(404)

    #TODO: test if polygon is ccw
    # exchange lat, lon -> lon, lat
    polygon = json.loads(request.args.get('polygon', None))
    polygon.append(polygon[0])
    logging.info(polygon)
    logging.info(path_to_kml([polygon]))
    if not polygon:
        abort(404)
    ee = Stats()
    normalized_poly = [(coord[1], coord[0]) for coord in polygon]
    stats = ee.get_stats_for_polygon([(str(r.key().id()), r.assetid) for r in reports], [normalized_poly])

    this_report = ReportType.factory(format)
    this_report.init("custom polygon")
    try:
        this_report.write_header()
        for i,s in enumerate(stats):
            r = reports[i]
            this_report.write_row(r, s, None, path_to_kml([polygon]))

        this_report.write_footer()
        return this_report.response("report_polygon")
    except (KeyError, ValueError, IndexError):
        abort(404)
开发者ID:davethau,项目名称:DeforestationAnalysisTool,代码行数:42,代码来源:api.py


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