Esempio 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')
Esempio 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')
Esempio 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')
Esempio n. 4
0
 def test_dump_as_csv_case_1(self):
     reader = csv.reader(StringIO(''.join(result_dump.dump_as_csv(result_list_error))))
     for row in reader:
         self.assertEqual(len(row), 2)
Esempio n. 5
0
 def test_dump_as_csv(self):
     reader = csv.reader(StringIO(''.join(result_dump.dump_as_csv(results1))))
     for row in reader:
         self.assertEqual(len(row), 4)
 def test_dump_as_csv_case_1(self):
     reader = csv.reader(
         StringIO(''.join(result_dump.dump_as_csv(result_list_error))))
     for row in reader:
         self.assertEqual(len(row), 2)
 def test_dump_as_csv(self):
     reader = csv.reader(
         StringIO(''.join(result_dump.dump_as_csv(results1))))
     for row in reader:
         self.assertEqual(len(row), 4)