Exemplo n.º 1
0
def spiderweb_download(project):
    projectdb = app.config['projectdb']
    print("hello")
    conn = pymysql.connect(host='127.0.0.1',port=3306,user='******',password='******',db='repository',charset='utf8')
    dbcur= conn.cursor()
    dbcur.execute('select * from shuiliting')
    results = result_dump.select(dbcur)
    _format = 'txt'
    print(results)
    if _format == 'json':
        valid = request.args.get('style', 'rows') == 'full'
        return Response(result_dump.dump_as_json(results, valid),
                        mimetype='application/json')
    elif _format == 'txt':
        return Response(result_dump.dump_as_txt(results),
                        mimetype='text/plain')
    elif _format == 'csv':
        return Response(result_dump.dump_as_csv(results),
                        mimetype='text/csv')
Exemplo n.º 2
0
def dump_result(project, _format):
    resultdb = app.config['resultdb']
    # force update project list
    resultdb.get(project, 'any')
    if project not in resultdb.projects:
        return "no such project.", 404

    offset = int(request.args.get('offset', 0))
    limit = int(request.args.get('limit', 0)) or None
    results = resultdb.select(project, offset=offset, limit=limit)

    if _format == 'json':
        valid = request.args.get('style', 'rows') == 'full'
        return Response(result_dump.dump_as_json(results, valid),
                        mimetype='application/json')
    elif _format == 'txt':
        return Response(result_dump.dump_as_txt(results),
                        mimetype='text/plain')
    elif _format == 'csv':
        return Response(result_dump.dump_as_csv(results), mimetype='text/csv')
Exemplo n.º 3
0
def dump_result(project, _format):
    resultdb = app.config['resultdb']
    # force update project list
    resultdb.get(project, 'any')
    if project not in resultdb.projects:
        return "no such project.", 404

    offset = int(request.args.get('offset', 0)) or None
    limit = int(request.args.get('limit', 0)) or None
    results = resultdb.select(project, offset=offset, limit=limit)

    if _format == 'json':
        valid = request.args.get('style', 'rows') == 'full'
        return Response(result_dump.dump_as_json(results, valid),
                        mimetype='application/json')
    elif _format == 'txt':
        return Response(result_dump.dump_as_txt(results),
                        mimetype='text/plain')
    elif _format == 'csv':
        return Response(result_dump.dump_as_csv(results),
                        mimetype='text/csv')
Exemplo n.º 4
0
 def test_dump_as_txt(self):
     for i, line in enumerate((''.join(
             result_dump.dump_as_txt(results2))).splitlines()):
         url, json_data = line.split('\t', 2)
         self.assertEqual(results2[i]['result'], json.loads(json_data))
 def test_dump_as_txt(self):
     for i, line in enumerate(
         (''.join(result_dump.dump_as_txt(results2))).splitlines()):
         url, json_data = line.split('\t', 2)
         self.assertEqual(results2[i]['result'], json.loads(json_data))