コード例 #1
0
ファイル: run_tiles.py プロジェクト: ommatidia/imgtile
 def handleTrackingDict(self, dictionary):
     f = open(os.path.join(self.dest, 'metadata.json'), 'w')
     metadata = simple_json.dumps(dictionary, indent='    ', sort_keys = True)
     f.write("var metadata = ")
     f.write(metadata)
     f.write(';')
     f.flush()
     f.close()
コード例 #2
0
 def render_GET(self, request):
     request.setHeader("content-type", "application/json")
     return dumps({
         'time': time(),
         'control': sets['control'],
         'balbula_1': sets['balbula_1'],
         'input1': input1
     })
コード例 #3
0
ファイル: pyTaskQ.py プロジェクト: Mars-LGD/pyTaskQ
 def json(self, errno, message, data=None):
     self.set_header("Content-Type", "application/json")
     self.write(
         json.dumps({
             'errno': errno,
             'message': message,
             'data': data
         }))
コード例 #4
0
ファイル: boot.py プロジェクト: kernelci/kernelci-frontend
def _get_boots_count(result):
    """Get the boot counts.

    :param result: The boot element for which to get the count of.
    :type result: dict
    :return: A dictionary with the counts.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % result

    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    result["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    result["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0,
        }

    return count_results
コード例 #5
0
ファイル: boot.py プロジェクト: dzickusrh/kernelci-frontend
def _get_boots_count(result):
    """Get the boot counts.

    :param result: The boot element for which to get the count of.
    :type result: dict
    :return: A dictionary with the counts.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % result

    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    result["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    result["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % result
    })

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0,
        }

    return count_results
コード例 #6
0
ファイル: views.py プロジェクト: natebeaty/pdxguide
def details(request):
#        [more stuff]
    if request.POST:
            # Get all the mark for this recipe
            list_mark = Mark.objects.values('mark').filter(recipe__pk=r.id)
            # loop to get the total
            total = 0
            for element in list_mark:
                    total+= element['mark']
            # round it
            total = round((float(total) /  len(list_mark)),1)
            # update the total
            r.total_mark= total
            # save the user mark
            r.save()

            # Now the intersting part for this tut
            import simple_json
            # it was a french string, if we dont't use unicode
            # the result at the output of json in Dojo is wrong.
            message = unicode( message, "utf-8" )
            #
            jsonList = simple_json.dumps((my_mark, total, form_message ,message))
            return HttpResponse(jsonList)
コード例 #7
0
ファイル: job.py プロジェクト: dzickusrh/kernelci-frontend
def _get_job_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_params["job_id"] = query_params["_id"]["$oid"]
    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % query_params

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_builds",
        "resource": "count",
        "document": "build",
        "query": total_query_str
    })
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_builds",
        "resource": "count",
        "document": "build",
        "query": query_str % query_params
    })

    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_builds",
        "resource": "count",
        "document": "build",
        "query": query_str % query_params
    })

    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60 * 60)

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": u"N/A",
            "failed_builds": u"N/A",
            "other_boots": u"N/A",
            "other_builds": u"N/A",
            "passed_boots": u"N/A",
            "passed_builds": u"N/A",
            "total_boots": u"N/A",
            "total_builds": u"N/A"
        }

    return count_results
コード例 #8
0
 def render_GET(self, request):
     request.setHeader("content-type", "application/json")
     return dumps({'time': time(), 'control': sets['control'], 'balbula_1': sets['balbula_1'], 'input1': input1})
コード例 #9
0
ファイル: pyTaskQ.py プロジェクト: Mars-LGD/pyTaskQ
 def saveToMySQL(self):
     #TODO: save to mysql
     Log("TODO: save to mysql " + json.dumps(self.d))
コード例 #10
0
ファイル: soc.py プロジェクト: kernelci/kernelci-frontend
def _get_boot_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&mach=%(mach)s"
    total_query_str = "job=%(job)s&mach=%(mach)s" % query_params

    if query_params.get("job_id", None):
        query_str += "&job_id=" + query_params["job_id"]["$oid"]
        total_query_str += "&job_id=" + query_params["job_id"]["$oid"]

    # In the aggregation result, the _id field is the one that gets aggregated.
    if all([query_params["kernel"],
            query_params["kernel"] == query_params.get("_id", None)]):
        query_str += "&kernel=" + query_params["kernel"]
        total_query_str += "&kernel=" + query_params["kernel"]

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append(
        {
            "method": "GET",
            "operation_id": "passed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append(
        {
            "method": "GET",
            "operation_id": "failed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    data, status, headers = backend.request_post(
        BACKEND_BATCH_URL,
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0
        }

    return count_results
コード例 #11
0
ファイル: util.py プロジェクト: johnnoone/zbx
def escape(value):
    """escape value for zabbix"""
    return json.dumps(value, separators=',:')
コード例 #12
0
ファイル: pyTaskQ.py プロジェクト: Mars-LGD/pyTaskQ
 def saveToLog(self):
     #TODO: save to log
     Log('TODO: save to log ' + json.dumps(self.d))
コード例 #13
0
ファイル: job.py プロジェクト: kernelci/kernelci-frontend
def _get_job_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_params["job_id"] = query_params["_id"]["$oid"]
    query_str = "status=%(status)s&job=%(job)s&kernel=%(kernel)s"
    total_query_str = "job=%(job)s&kernel=%(kernel)s" % query_params

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_builds",
        "resource": "count",
        "document": "build",
        "query": total_query_str
    })
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append(
        {
            "method": "GET",
            "operation_id": "passed_builds",
            "resource": "count",
            "document": "build",
            "query": query_str % query_params
        }
    )

    queries.append(
        {
            "method": "GET",
            "operation_id": "passed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append(
        {
            "method": "GET",
            "operation_id": "failed_builds",
            "resource": "count",
            "document": "build",
            "query": query_str % query_params
        }
    )

    queries.append(
        {
            "method": "GET",
            "operation_id": "failed_boots",
            "resource": "count",
            "document": "boot",
            "query": query_str % query_params
        }
    )

    data, status, headers = backend.request_post(
        backend.create_url(CONFIG_GET("BATCH_API_ENDPOINT")),
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60*60
    )

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": u"N/A",
            "failed_builds": u"N/A",
            "other_boots": u"N/A",
            "other_builds": u"N/A",
            "passed_boots": u"N/A",
            "passed_builds": u"N/A",
            "total_boots": u"N/A",
            "total_builds": u"N/A"
        }

    return count_results
コード例 #14
0
def _get_boot_counts(query_params):
    """Retrieve the builds and boots count.

    :param query_params: The result from the previous query to be used as
    parameter.
    :type query_params: dict
    :return: A dictionary with the buils and boots count.
    """
    queries = []

    query_str = "status=%(status)s&job=%(job)s&mach=%(mach)s"
    total_query_str = "job=%(job)s&mach=%(mach)s" % query_params

    if query_params.get("job_id", None):
        query_str += "&job_id=" + query_params["job_id"]["$oid"]
        total_query_str += "&job_id=" + query_params["job_id"]["$oid"]

    # In the aggregation result, the _id field is the one that gets aggregated.
    if all([
            query_params["kernel"],
            query_params["kernel"] == query_params.get("_id", None)
    ]):
        query_str += "&kernel=" + query_params["kernel"]
        total_query_str += "&kernel=" + query_params["kernel"]

    # Get the totals.
    queries.append({
        "method": "GET",
        "operation_id": "total_boots",
        "resource": "count",
        "document": "boot",
        "query": total_query_str
    })

    # Get the passed ones first.
    query_params["status"] = "PASS"
    queries.append({
        "method": "GET",
        "operation_id": "passed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    # Then the failed ones.
    query_params["status"] = "FAIL"
    queries.append({
        "method": "GET",
        "operation_id": "failed_boots",
        "resource": "count",
        "document": "boot",
        "query": query_str % query_params
    })

    data, status, headers = backend.request_post(
        BACKEND_BATCH_URL,
        json.dumps({"batch": queries}),
        headers={"Content-Type": "application/json"},
        timeout=60 * 60)

    if status == 200:
        count_results = _parse_batch_results(
            backend.extract_gzip_data(data, headers))
    else:
        count_results = {
            "failed_boots": 0,
            "other_boots": 0,
            "passed_boots": 0,
            "total_boots": 0
        }

    return count_results
コード例 #15
0
ファイル: pyTaskQ.py プロジェクト: felix021/pyTaskQ
 def saveToMySQL(self):
     #TODO: save to mysql
     Log("TODO: save to mysql " + json.dumps(self.d))
コード例 #16
0
ファイル: pyTaskQ.py プロジェクト: felix021/pyTaskQ
 def saveToLog(self):
     #TODO: save to log
     Log('TODO: save to log ' + json.dumps(self.d))
コード例 #17
0
ファイル: pyTaskQ.py プロジェクト: felix021/pyTaskQ
 def json(self, errno, message, data=None):
     self.set_header("Content-Type", "application/json")
     self.write(json.dumps({'errno': errno, 'message': message, 'data': data}))