示例#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')
示例#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')
示例#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')
示例#4
0
 def test_dump_as_json_valid(self):
     ret = json.loads(''.join(result_dump.dump_as_json(results2, True)))
     for i, j in zip(results2, ret):
         self.assertDictEqual(i, j)
示例#5
0
 def test_dump_as_json(self):
     for i, line in enumerate((''.join(
             result_dump.dump_as_json(results2))).splitlines()):
         self.assertDictEqual(results2[i], json.loads(line))
 def test_dump_as_json_valid(self):
     ret = json.loads(''.join(result_dump.dump_as_json(results2, True)))
     for i, j in zip(results2, ret):
         self.assertDictEqual(i, j)
 def test_dump_as_json(self):
     for i, line in enumerate(
         (''.join(result_dump.dump_as_json(results2))).splitlines()):
         self.assertDictEqual(results2[i], json.loads(line))