Example #1
0
    def update(self, status):
        """
        Updates the job's status on the server that created it.

        :param dict status: The new status of the job
        """
        self.status = status
        body = hoplite_dumps({
            "api_key": self._api_key,
            "status": status
        })
        url = self._daemon_addr + '/jobs/{0}'.format(self._uuid)
        headers = {'content-type': 'application/json'}
        r = requests.put(url, data=body, headers=headers)
        if r.status_code == 404:
            raise JobDoesNotExistError
Example #2
0
def get_running_jobs(url, request):
    if request.method == 'GET':
        return response(200, hoplite_dumps({"jobs": [{"uuid": 111}]}))
Example #3
0
 def _json_data(self, kwargs, csrf_enabled=True):
     if 'data' in kwargs:
         kwargs['data'] = hoplite_dumps(kwargs['data'])
     if not kwargs.get('content_type'):
         kwargs['content_type'] = 'application/json'
     return kwargs
Example #4
0
 def _json_data(self, kwargs):
     if 'data' in kwargs:
         kwargs['data'] = hoplite_dumps(kwargs['data'])
     if not kwargs.get('headers', None):
         kwargs['headers'] = {'Content-type': 'application/json'}
     return kwargs
Example #5
0
File: utils.py Project: ni/hoplite
 def _json_data(self, kwargs, csrf_enabled=True):
     if 'data' in kwargs:
         kwargs['data'] = hoplite_dumps(kwargs['data'])
     if not kwargs.get('content_type'):
         kwargs['content_type'] = 'application/json'
     return kwargs
Example #6
0
def kill_job(url, request):
    if request.method == 'PUT':
        return response(200, hoplite_dumps(killed_dict),
                        {'content-type': 'application/json'})
Example #7
0
def get_specific_job_named_something(url, request):
    return response(200, hoplite_dumps(job_dict_name_something),
                    {'content-type': 'application/json'})
Example #8
0
def post_jobs(url, request):
    if request.method == 'POST' and request.headers[
            'Content-type'] == 'application/json':
        return response(200, hoplite_dumps(job_dict_name_something),
                        {'content-type': 'application/json'})
Example #9
0
def get_specific_job(url, request):
    return response(200, hoplite_dumps(job_dict), {'content-type': 'application/json'})
Example #10
0
def get_with_exception(url, request):
    return response(200, hoplite_dumps(excepted_job), {'content-type': 'application/json'})
Example #11
0
def delete(url, request):
    if request.method == 'DELETE' and _request_has_json_content_type(request)\
            and request.body == hoplite_dumps(DATA):
        return response(200)
Example #12
0
def patch(url, request):
    if request.method == 'PATCH' and _request_has_json_content_type(request)\
            and request.body == hoplite_dumps(DATA):
        return response(200)
Example #13
0
def post(url, request):
    print request.body
    if request.method == 'POST' and _request_has_json_content_type(request)\
            and request.body == hoplite_dumps(DATA):
        return response(200)
Example #14
0
def get_running_jobs(url, request):
    if request.method == 'GET':
        return response(200, hoplite_dumps({"jobs": [{"uuid": 111}]}))
Example #15
0
def get_with_exception(url, request):
    return response(200, hoplite_dumps(excepted_job),
                    {'content-type': 'application/json'})
Example #16
0
def post_jobs(url, request):
    if request.method == 'POST' and request.headers['Content-type'] == 'application/json':
        return response(200, hoplite_dumps(job_dict_name_something), {'content-type': 'application/json'})
Example #17
0
def get_specific_job(url, request):
    return response(200, hoplite_dumps(job_dict),
                    {'content-type': 'application/json'})
Example #18
0
def post_jobs_400(url, request):
    if request.method == 'POST' and request.headers['Content-type'] == 'application/json':
        return response(400, hoplite_dumps({"error": "Job not found"}), {'content-type': 'application/json'})
Example #19
0
def post_jobs_400(url, request):
    if request.method == 'POST' and request.headers[
            'Content-type'] == 'application/json':
        return response(400, hoplite_dumps({"error": "Job not found"}),
                        {'content-type': 'application/json'})
Example #20
0
def get_specific_job_named_something(url, request):
    return response(200, hoplite_dumps(job_dict_name_something), {'content-type': 'application/json'})
Example #21
0
def get_specific_job_running_false_finished_true(url, request):
    return response(200, hoplite_dumps(job_dict_2),
                    {'content-type': 'application/json'})
Example #22
0
def get_specific_job_running_false_finished_true(url, request):
    return response(200,  hoplite_dumps(job_dict_2), {'content-type': 'application/json'})
Example #23
0
 def _json_data(self, kwargs):
     if 'data' in kwargs:
         kwargs['data'] = hoplite_dumps(kwargs['data'])
     if not kwargs.get('headers', None):
         kwargs['headers'] = {'Content-type': 'application/json'}
     return kwargs
Example #24
0
def kill_job(url, request):
    if request.method == 'PUT':
        return response(200,  hoplite_dumps(killed_dict), {'content-type': 'application/json'})
Example #25
0
def jsonify(*args, **kwargs):
    """
        jsonify that uses hoplite's serial encoder
    """
    return werkzeug.Response(
        hoplite_dumps(dict(*args, **kwargs)), mimetype='application/json')
Example #26
0
def jsonify(*args, **kwargs):
    """
        jsonify that uses hoplite's serial encoder
    """
    return werkzeug.Response(hoplite_dumps(dict(*args, **kwargs)),
                             mimetype='application/json')