Пример #1
0
 def get(self):
     session_id = get_session_id(session, request)
     dao = ObstacleDAO(session_id)
     objts = dao.get_obstacles_summary()
     dao.close()
     resp = make_response(json_serialize(objts, session_id=session_id))
     resp.headers['Content-Type'] = "application/json"
     return resp
Пример #2
0
 def get(self):
   session_id = get_session_id(session, request)
   dao = ObstacleDAO(session_id)
   objts = dao.get_obstacles_summary()
   dao.close()
   resp = make_response(json_serialize(objts, session_id=session_id))
   resp.headers['Content-Type'] = "application/json"
   return resp
Пример #3
0
 def post(self, name):
     session_id = get_session_id(session, request)
     dao = ObstacleDAO(session_id)
     dao.generate_vulnerability(name)
     dao.close()
     resp_dict = {'message': 'Vulnerability successfully generated'}
     resp = make_response(json_serialize(resp_dict), OK)
     resp.headers['Content-type'] = 'application/json'
     return resp
Пример #4
0
 def post(self,name):
   session_id = get_session_id(session, request)
   dao = ObstacleDAO(session_id)
   dao.generate_vulnerability(name)
   dao.close()
   resp_dict = {'message': 'Vulnerability successfully generated'}
   resp = make_response(json_serialize(resp_dict), OK)
   resp.headers['Content-type'] = 'application/json'
   return resp
Пример #5
0
    def get(self, environment):
        session_id = get_session_id(session, request)

        dao = ObstacleDAO(session_id)
        goals = dao.get_obstacle_names(environment=environment)
        dao.close()

        resp = make_response(json_serialize(goals, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Пример #6
0
  def get(self, environment):
    session_id = get_session_id(session, request)

    dao = ObstacleDAO(session_id)
    goals = dao.get_obstacle_names(environment=environment)
    dao.close()

    resp = make_response(json_serialize(goals, session_id=session_id))
    resp.headers['Content-Type'] = "application/json"
    return resp
Пример #7
0
  def get(self, name):
    session_id = get_session_id(session, request)

    dao = ObstacleDAO(session_id)
    found_obstacle = dao.get_obstacle_by_name(name)
    dao.close()

    resp = make_response(json_serialize(found_obstacle, session_id=session_id))
    resp.headers['Content-Type'] = "application/json"
    return resp
Пример #8
0
    def get(self, name):
        session_id = get_session_id(session, request)

        dao = ObstacleDAO(session_id)
        found_obstacle = dao.get_obstacle_by_name(name)
        dao.close()

        resp = make_response(
            json_serialize(found_obstacle, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Пример #9
0
    def get(self):
        session_id = get_session_id(session, request)
        constraint_id = request.args.get('constraint_id', -1)

        dao = ObstacleDAO(session_id)
        obstacles = dao.get_obstacles(constraint_id=constraint_id)
        dao.close()

        resp = make_response(json_serialize(obstacles, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Пример #10
0
  def delete(self, name):
    session_id = get_session_id(session, request)

    dao = ObstacleDAO(session_id)
    dao.delete_obstacle(name)
    dao.close()

    resp_dict = {'message': 'Obstacle successfully deleted'}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.contenttype = 'application/json'
    return resp
Пример #11
0
  def get(self):
    session_id = get_session_id(session, request)
    constraint_id = request.args.get('constraint_id', -1)

    dao = ObstacleDAO(session_id)
    obstacles = dao.get_obstacles(constraint_id=constraint_id)
    dao.close()

    resp = make_response(json_serialize(obstacles, session_id=session_id))
    resp.headers['Content-Type'] = "application/json"
    return resp
Пример #12
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = ObstacleDAO(session_id)
        dao.delete_obstacle(name)
        dao.close()

        resp_dict = {'message': 'Obstacle successfully deleted'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
Пример #13
0
  def put(self, name):
    session_id = get_session_id(session, request)

    dao = ObstacleDAO(session_id)
    upd_obs = dao.from_json(request)
    dao.update_obstacle(upd_obs, name)
    dao.close()

    resp_dict = {'message': 'Obstacle successfully updated'}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.contenttype = 'application/json'
    return resp
Пример #14
0
  def post(self):
    session_id = get_session_id(session, request)

    dao = ObstacleDAO(session_id)
    new_obstacle = dao.from_json(request)
    new_obstacle_id = dao.add_obstacle(new_obstacle)
    dao.close()

    resp_dict = {'message': 'Obstacle successfully added'}
    resp = make_response(json_serialize(resp_dict, session_id=session_id), OK)
    resp.contenttype = 'application/json'
    return resp
Пример #15
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = ObstacleDAO(session_id)
        upd_obs = dao.from_json(request)
        dao.update_obstacle(upd_obs, name)
        dao.close()

        resp_dict = {'message': 'Obstacle successfully updated'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
Пример #16
0
    def post(self):
        session_id = get_session_id(session, request)

        dao = ObstacleDAO(session_id)
        new_obstacle = dao.from_json(request)
        new_obstacle_id = dao.add_obstacle(new_obstacle)
        dao.close()

        resp_dict = {'message': 'Obstacle successfully added'}
        resp = make_response(json_serialize(resp_dict, session_id=session_id),
                             OK)
        resp.contenttype = 'application/json'
        return resp
Пример #17
0
  def get(self, environment, obstacle):
    session_id = get_session_id(session, request)
    model_generator = get_model_generator()

    dao = ObstacleDAO(session_id)
    if obstacle == 'all':  obstacle = ''
    dot_code = dao.get_obstacle_model(environment,obstacle)
    dao.close()

    resp = make_response(model_generator.generate(dot_code, model_type='obstacle',renderer='dot'), OK)
    accept_header = request.headers.get('Accept', 'image/svg+xml')
    if accept_header.find('text/plain') > -1:
      resp.headers['Content-type'] = 'text/plain'
    else:
      resp.headers['Content-type'] = 'image/svg+xml'
    return resp
Пример #18
0
    def get(self, environment, obstacle):
        session_id = get_session_id(session, request)
        model_generator = get_model_generator()

        dao = ObstacleDAO(session_id)
        if obstacle == 'all': obstacle = ''
        dot_code = dao.get_obstacle_model(environment, obstacle)
        dao.close()

        resp = make_response(
            model_generator.generate(dot_code,
                                     model_type='obstacle',
                                     renderer='dot'), OK)
        accept_header = request.headers.get('Accept', 'image/svg+xml')
        if accept_header.find('text/plain') > -1:
            resp.headers['Content-type'] = 'text/plain'
        else:
            resp.headers['Content-type'] = 'image/svg+xml'
        return resp