From nobody Tue May 13 12:49:30 2025 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 1530870179646355.52803916845244; Fri, 6 Jul 2018 02:42:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 050DA308A950; Fri, 6 Jul 2018 09:42:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA31CC4AB2; Fri, 6 Jul 2018 09:42:58 +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 D59804BB78; Fri, 6 Jul 2018 09:42:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w669gwIJ012011 for ; Fri, 6 Jul 2018 05:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 243A7C4ABE; Fri, 6 Jul 2018 09:42:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CE1FC4AB2 for ; Fri, 6 Jul 2018 09:42:55 +0000 (UTC) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) (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 E2EFA4E918 for ; Fri, 6 Jul 2018 09:42:44 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id s21-v6so7999352pfm.6 for ; Fri, 06 Jul 2018 02:42:44 -0700 (PDT) Received: from localhost.localdomain ([182.74.40.122]) by smtp.gmail.com with ESMTPSA id r87-v6sm15257688pfb.1.2018.07.06.02.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Jul 2018 02:42:42 -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:in-reply-to:references; bh=rAHfLCpvGqL4zYjWK5jVRgQcn5p4rTTtT2ZX+B8Q+Tk=; b=vd+2OPItdCIKOIMZI//p1OtMu0hTC9h2dNDUAtdVSsRmkC5JK94l9beArBVdnIqxje IHF7x2s1h7Qx2hlimw8M2E/kJIgiSMP4bfTdJvKoKIzCRnX6UgUsS4z8GpzbmX3eG02R DCRVrGoTiQrBFnFdKffHU/49+z2jYT26WzGj4zDZTZOZCZNV2Qns9pymUM1RjPpx6OFm 9e6no/iD+jsbFfah5XQ4qNdxvDPioWualeVBmLlAK1UQLji+OYh3ZGMfmNB9PWwpw87d UIx6BBme1hpZ0plPRBAY7I8IWNEEwQpiOWiGm11zM4/5sIsQsxpitjOQwr4kDgAjgmaA Xi6Q== 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:in-reply-to :references; bh=rAHfLCpvGqL4zYjWK5jVRgQcn5p4rTTtT2ZX+B8Q+Tk=; b=DxHsiYyFldngqR4PI6JcdHQWTSIjqZ+yOy91WqZ/0OnPkmJtZo4a5oUZdLitaCjVop KxaCvC30ikmnQJ8b0nfzccGapomiTTlU86fsxHg4tioai5krBkUksu0eAp0OLZNbic8s Eiij4SP1GfLwbX479VdL9LX+noG/eMKkd7Ba1z2ZhG3h7MWuzD7mpvSZbZ1frfx9mub0 0X6G39jjUCQVLfaK2vD7NlBCw4eJm+EELNZA0euqbZyyYUddNWP4vUnzZgfKQbHnjeg3 or6YT7h9T6nIgMxRXMTq8cvgLUM0sEq5YdikP/4AJttMNnW88WOsvzzGKby7P9O0+k8Q ZhYA== X-Gm-Message-State: APt69E32Hnt55VelzM6d4bn5ltH1YBeF2+juIhXoZXBMG6AmY41Sk1nR dg6jZLhMO1t85cJUfdK/06VaJQ== X-Google-Smtp-Source: AAOMgpc1JoT0aKnUFYqJWCJ9T2PkTzSaICuW1rUqVC5A++oEFT79uoJdIV6M3bZurHrybFXFDgaHkg== X-Received: by 2002:a63:6b86:: with SMTP id g128-v6mr8973998pgc.344.1530870163979; Fri, 06 Jul 2018 02:42:43 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Fri, 6 Jul 2018 15:09:45 +0530 Message-Id: <20180706093947.20025-3-shubhamjain7495@gmail.com> In-Reply-To: <20180706093947.20025-1-shubhamjain7495@gmail.com> References: <20180706093947.20025-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Jul 2018 09:42:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Jul 2018 09:42:45 +0000 (UTC) for IP:'209.85.192.196' DOMAIN:'mail-pf0-f196.google.com' HELO:'mail-pf0-f196.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.55 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.196 mail-pf0-f196.google.com 209.85.192.196 mail-pf0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v3 2/4] Make Patchew cli's Project use rest api 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 06 Jul 2018 09:42:59 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" -Make ProjectCommand use rest_api_do instead of api_do --- api/rest.py | 3 ++- patchew-cli | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/api/rest.py b/api/rest.py index 66644ba..39bdda0 100644 --- a/api/rest.py +++ b/api/rest.py @@ -31,7 +31,7 @@ class CsrfExemptSessionAuthentication(SessionAuthenticati= on): =20 def enforce_csrf(self, request): return # To not perform the csrf check previously happening - =20 + SEARCH_PARAM =3D 'q' =20 # patchew-specific permission classes @@ -146,6 +146,7 @@ class ProjectsViewSet(viewsets.ModelViewSet): queryset =3D Project.objects.all().order_by('id') serializer_class =3D ProjectSerializer permission_classes =3D (PatchewPermission,) + authentication_classes =3D (CsrfExemptSessionAuthentication, ) =20 @action(methods=3D['post'], detail=3DTrue, permission_classes=3D[Impor= tPermission]) def update_project_head(self, request, pk=3DNone): diff --git a/patchew-cli b/patchew-cli index e510e74..8425db2 100755 --- a/patchew-cli +++ b/patchew-cli @@ -255,11 +255,11 @@ class ProjectCommand(SubCommand): parser.add_argument("--verbose", "-v", action=3D"store_true", help=3D"Show details about projects") args =3D parser.parse_args(argv) - r =3D self.api_do("get-projects") + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') if args.raw: print(json.dumps(r, indent=3D2, separators=3D",:")) return 0 - for p in r: + for p in r['results']: print(p["name"]) if args.verbose: for k, v in p.items(): @@ -273,8 +273,8 @@ class ProjectCommand(SubCommand): parser.add_argument("name", nargs=3D"+", help=3D"The name of project to show info") args =3D parser.parse_args(argv) - r =3D self.api_do("get-projects") - for p in r: + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') + for p in r['results']: if not p["name"] in args.name: continue if len(args.name) > 1: @@ -297,12 +297,15 @@ class ProjectCommand(SubCommand): parser.add_argument("--desc", "-d", default=3D"", help=3D"Project short discription") args =3D parser.parse_args(argv) - self.api_do("add-project", - name=3Dargs.name, - mailing_list=3Dargs.mailing_list, - url=3Dargs.url, - git=3Dargs.git, - description=3Dargs.desc) + data =3D {'name':args.name, + 'mailing_list':args.mailing_list, + 'url':args.url, + 'git':args.git, + 'description':args.desc} + self.rest_api_do(url_cmd=3D"projects", + request_method=3D'post', + content_type=3D'application/json', + data=3Djson.dumps(data)) =20 def update_one_project(self, wd, project): logging.info("Updating project '%s'", project["name"]) @@ -354,16 +357,17 @@ class ProjectCommand(SubCommand): except Exception as e: logging.warn("Failed to push the new head to patchew mirro= r: %s", str(e)) - self.api_do("update-project-head", project=3Dproject["name"], - old_head=3Dold_head, - new_head=3Dnew_head, - message_ids=3Dmsgids) + url =3D project['resource_uri'] + "/update_project_head/" + self.rest_api_do(url, old_head=3Dold_head, + new_head=3Dnew_head, + message_ids=3Dmsgids) =20 def update_project(self, argv): parser =3D argparse.ArgumentParser() parser.add_argument("--name", "-n", help=3D"Name of the project") args =3D parser.parse_args(argv) - projects =3D self.api_do("get-projects", name=3Dargs.name) + projects =3D self.rest_api_do("projects") + projects =3D [p for p in projects['results'] if p['name'] =3D=3D a= rgs.name] wd =3D tempfile.mkdtemp() logging.debug("TMPDIR: %s", wd) try: --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel