From ceda3a6e9e437b8396b9b360198d6e3522e33af5 Mon Sep 17 00:00:00 2001 From: Alice Ferrazzi Date: Sat, 1 Jul 2017 10:45:10 +0000 Subject: add UserID for parallel build and minor fix --- elivepatch_server/resources/dispatcher.py | 48 ++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'elivepatch_server') diff --git a/elivepatch_server/resources/dispatcher.py b/elivepatch_server/resources/dispatcher.py index 56407c7..65b0b59 100644 --- a/elivepatch_server/resources/dispatcher.py +++ b/elivepatch_server/resources/dispatcher.py @@ -5,8 +5,8 @@ # Distributed under the terms of the GNU General Public License v2 or later -from flask import Flask, jsonify, abort, make_response -from flask_restful import Api, Resource, reqparse, fields, marshal +from flask import jsonify, make_response +from flask_restful import Resource, reqparse, fields, marshal import werkzeug from elivepatch_server.resources.livepatch import PaTch @@ -47,7 +47,7 @@ class BuildLivePatch(Resource): pass def get(self): - #lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') + # lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') return {'packs': [marshal(pack, pack_fields) for pack in packs]} def post(self): @@ -57,7 +57,7 @@ class BuildLivePatch(Resource): if kernel_config and kernel_patch: lpatch.set_lp_status('working') print("build livepatch: " + str(args)) - #lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') + # lpatch.build_livepatch(kernel_dir, kernel_dir + '/vmlinux') pack = { 'id': packs['id'] + 1, 'KernelVersion': args['KernelVersion'], @@ -96,8 +96,8 @@ class GetLivePatch(Resource): def post(self): return make_response(jsonify({'message': 'These are not the \ - patches you are looking for'}) - , 403) + patches you are looking for'}), 403) + class GetConfig(Resource): @@ -117,14 +117,14 @@ class GetConfig(Resource): def get(self): return make_response(jsonify({'message': 'These are not the \ - patches you are looking for'}) - , 403) + patches you are looking for'}), 403) def post(self): args = self.reqparse.parse_args() print("get config: " + str(args)) parse = reqparse.RequestParser() - parse.add_argument('file', type=werkzeug.datastructures.FileStorage, location='files') + parse.add_argument('file', type=werkzeug.datastructures.FileStorage, + location='files') args = parse.parse_args() audioFile = args['file'] audioFile_name = args['file'].filename @@ -152,18 +152,40 @@ class GetPatch(Resource): def get(self): return make_response(jsonify({'message': 'These are not the \ - patches you are looking for'}) - , 403) + patches you are looking for'}), 403) def post(self): args = self.reqparse.parse_args() print("get patch: " + str(args)) parse = reqparse.RequestParser() - parse.add_argument('file', type=werkzeug.datastructures.FileStorage, location='files') + parse.add_argument('file', type=werkzeug.datastructures.FileStorage, + location='files') args = parse.parse_args() audioFile = args['file'] audioFile_name = args['file'].filename print(audioFile_name) print(audioFile) audioFile.save(audioFile_name) - lpatch.set_patch(audioFile_name) \ No newline at end of file + lpatch.set_patch(audioFile_name) + + +class GetID(Resource): + + def __init__(self): + self.reqparse = reqparse.RequestParser() + self.reqparse.add_argument('UserID', type=str, required=False, + help='No task title provided', + location='json') + super(GetID, self).__init__() + pass + + def get(self): + return make_response(jsonify({'message': 'These are not the \ + patches you are looking for'}), 403) + + def post(self): + args = self.reqparse.parse_args() + print("get ID: " + str(args)) + + +#def id_check() -- cgit v1.2.3-65-gdbad