From nobody Thu Apr 25 05:10:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533730194757292.40952395069996; Wed, 8 Aug 2018 05:09:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D5543086262; Wed, 8 Aug 2018 12:09:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F02416D34; Wed, 8 Aug 2018 12:09:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 421431800B68; Wed, 8 Aug 2018 12:09:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w78C670O012318 for ; Wed, 8 Aug 2018 08:06:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 878A0308BDB3; Wed, 8 Aug 2018 12:06:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77B57308BDB2 for ; Wed, 8 Aug 2018 12:06:04 +0000 (UTC) Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57A29820E9 for ; Wed, 8 Aug 2018 12:06:03 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id a11-v6so1002396pgw.6 for ; Wed, 08 Aug 2018 05:06:03 -0700 (PDT) Received: from localhost.localdomain ([182.74.40.122]) by smtp.gmail.com with ESMTPSA id 73-v6sm14660516pfu.20.2018.08.08.05.05.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Aug 2018 05:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=x8t/S3G8d7q1S3xApTcFz0TWQ1Hhm0Hu9XiSYP4n2lU=; b=VAiRHT++oH4UJiShGpXRELaMso1KJeHZMwSlRWncYICtLfjx621iNxPqTcnE63bwdJ T/S/Yyihz7su0hn6F5vBIjaZNVvJ7R3jo7Glx0kSHPYY3qrt1nJlGJhOxYw4docb8ql+ VfYZzcX8HkWTRzygrWbnAwVodK8ewbnR4cku+hG8ykgszubgLFcilTlxxTCPT1F51DqL Ht1dcRtXEWjpaEAjyueQCSCN43bzzwlzeiKkMJkMQE2Nz74z2baf3yE91mpOOlJj4tW0 Hs2u/ZpZF/DCbvap73B39f13/x20M0QxAGpC/6K7/GHSJcggtdUfc70edUDDeSPu3oBP CTug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=x8t/S3G8d7q1S3xApTcFz0TWQ1Hhm0Hu9XiSYP4n2lU=; b=jEjetR7VC0VYndsG/LJTShhjcOBlN7KNQXDYiYAtwVTZojtaGNEryKRgtt1jiDv6xX 181mKeeGbWRRs7ENedL91aAG1x5q/6xi1E9bWie9AJgimKYYVHZ4u3JRNvhQQASqn6HE Gl+ZNbxxUqTcd7yYlzH9fsQLk59shTG7VYCWk3C0e9kvqpqsxzewDmc+A08G7ayN0SBA Gy+PwM/Fn8jAYchPzs5VulVjU4jf1zGGQ6LauNhTvQwNsMJYYmHBTDl+Xyku0GgohWW1 6d7FoHBY7VjYg/1Zy7LT2avRwqO6Crhh87osavxYvuBv2MNoukT8FamIsjveCHi0bAgm UTcg== X-Gm-Message-State: AOUpUlFqsZ5BGet+CAUvQUdHzHMMEYoPMqQBwRxfoUn1FH0xCW9u+XYw wfty4V2FtBrSGrvLWDhAe1kAZtxIMW0= X-Google-Smtp-Source: AA+uWPz14DZpY0Si6XNN6Lhe62D6u9xgH4Fg+Aq4V5ILzjBgckOU11Ojj8+ZK5tmRwLIWn3QKcTMsw== X-Received: by 2002:a63:9d47:: with SMTP id i68-v6mr2345286pgd.172.1533729962195; Wed, 08 Aug 2018 05:06:02 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Wed, 8 Aug 2018 17:35:49 +0530 Message-Id: <20180808120549.55732-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 08 Aug 2018 12:06:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 08 Aug 2018 12:06:03 +0000 (UTC) for IP:'209.85.215.173' DOMAIN:'mail-pg1-f173.google.com' HELO:'mail-pg1-f173.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.14 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.215.173 mail-pg1-f173.google.com 209.85.215.173 mail-pg1-f173.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH] Make patchew-cli use PUT of results X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 08 Aug 2018 12:09:53 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Convert patchew-cli *-report to use result PUT --- patchew-cli | 87 ++++++++++++++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 66 insertions(+), 21 deletions(-) diff --git a/patchew-cli b/patchew-cli index cdedbb6..cf6fdf2 100755 --- a/patchew-cli +++ b/patchew-cli @@ -23,6 +23,7 @@ import traceback import time import hashlib import fcntl +import datetime =20 COOKIE_FILENAME =3D os.path.expanduser("~/.patchew.cookie") =20 @@ -125,7 +126,7 @@ class SubCommand(object): else: r =3D None return r - =20 + def do(self, args, argv): """Do command""" print("Not implemented") @@ -620,7 +621,10 @@ class TesterCommand(SubCommand): except: traceback.print_exc(file=3Dlogf) finally: - passed =3D rc =3D=3D 0 + if rc =3D=3D 0: + passed =3D "success" + else: + passed =3D "failure" try: try: logf.seek(0) @@ -629,15 +633,28 @@ class TesterCommand(SubCommand): log =3D "N/A. Internal error while reading log file\n" print(" Result:", "Passed" if passed else "Failed") logging.debug(log) - self.api_do("testing-report", project=3Dr["project"], - identity=3Dr["identity"], - test=3Dr["test"]["name"], - tester=3Dname, - head=3Dr["head"], - base=3Dr["base"], - passed=3Dpassed, - log=3Dlog, - is_timeout=3Dis_timeout) + project_url =3D self.base_url + "/api/v1/projects/?name=3D= " + project + test_name =3D "testing." + r['test']['name'] + pr =3D self.rest_api_do(url_cmd=3Dproject_url) + if identity["type"] =3D=3D "project": + url =3D pr['results'][0]['results'] + test_name + "/" + else: + url =3D pr['results'][0]['series'] + identity['message= _id'] + "/results/" + test_name + "/" + json_data=3D { + "name": test_name, + "status": passed, + "last_update": datetime.datetime.now().strftime('%= Y-%m-%dT%H:%M:%S.%f'), + "data": { + "is_timeout": is_timeout, + "head": r["head"], + "tester": name + }, + "log": log + } + self.rest_api_do(url_cmd=3Durl, + request_method=3D'put', + content_type=3D'application/json', + data=3Djson.dumps(json_data)) logf.close() finally: if not no_clean_up: @@ -785,6 +802,11 @@ class ApplyCommand(SubCommand): push_repo =3D toapply.get("git.push_to") public_repo =3D toapply.get("git.public_repo") wd =3D tempfile.mkdtemp(dir=3D"/var/tmp") + project =3D toapply['project'] + message_id =3D toapply['message-id'] + project_url =3D self.base_url + "/api/v1/projects/?name=3D" + proj= ect + pr =3D self.rest_api_do(url_cmd=3Dproject_url) + report_url =3D pr['results'][0]['series'] + message_id + "/result= s/git/" try: if toapply.get("git.repo"): remote, head =3D toapply["git.repo"], toapply["git.base"] @@ -806,6 +828,7 @@ class ApplyCommand(SubCommand): if push_repo: self._push(wd, push_repo, tag, logf) url =3D toapply.get("git.url_template", "").replace("%t", tag) + tag =3D "refs/tags/" + tag except Exception as e: if not isinstance(e, ApplyFailedException): traceback.print_exc(file=3Dlogf) @@ -814,11 +837,22 @@ class ApplyCommand(SubCommand): if push_repo: log =3D log.replace(push_repo, public_repo) print(log) - self.api_do("applier-report", - project=3Dtoapply["project"], - message_id=3Dtoapply["message-id"], - tag=3DNone, url=3DNone, base=3DNone, repo=3DNone, - failed=3DTrue, log=3Dlog) + json_data =3D { + "name": "git", + "status": "failure", + "last_update": datetime.datetime.now().strftime('%= Y-%m-%dT%H:%M:%S.%f'), + "data": { + "repo": "", + "url": "", + "base": "", + "tag": "" + }, + "log": log + } + self.rest_api_do(url_cmd=3Dreport_url, + request_method=3D'put', + content_type=3D'application/json', + data=3Djson.dumps(json_data)) return 1 finally: shutil.rmtree(wd) @@ -826,11 +860,22 @@ class ApplyCommand(SubCommand): log =3D logf.read() if push_repo: log =3D log.replace(push_repo, public_repo) - self.api_do("applier-report", - project=3Dtoapply["project"], - message_id=3Dtoapply["message-id"], - tag=3Dtag, url=3Durl, base=3Dbase, repo=3Dpublic_repo, - failed=3DFalse, log=3Dlog) + json_data =3D { + "name": "git", + "status": "success", + "last_update": datetime.datetime.now().strftime('%Y-%m= -%dT%H:%M:%S.%f'), + "data": { + "repo": public_repo, + "url": url, + "base": base, + "tag": tag + }, + "log": log + } + self.rest_api_do(url_cmd=3Dreport_url, + request_method=3D'put', + content_type=3D'application/json', + data=3Djson.dumps(json_data)) return 0 =20 def do(self, args, argv): --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel