From nobody Thu Sep 19 00:58:34 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 153136932633184.53414397914162; Wed, 11 Jul 2018 21:22:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 808D65AFD2; Thu, 12 Jul 2018 04:22:05 +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 710D3600D1; Thu, 12 Jul 2018 04:22:05 +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 6167B4BB78; Thu, 12 Jul 2018 04:22:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4M3PD020327 for ; Thu, 12 Jul 2018 00:22:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id E41773001A54; Thu, 12 Jul 2018 04:22:03 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DBCDB3001A47 for ; Thu, 12 Jul 2018 04:22:03 +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 7A8F3C057FA2 for ; Thu, 12 Jul 2018 04:21:52 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id b17-v6so19785387pfi.0 for ; Wed, 11 Jul 2018 21:21:52 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:50 -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=XS3y5g5NPy8qnQSqrHw4ufA9JHOcW2CdhLFrKP5qMpg=; b=VYX5433aHk8IPwGS7oSt5uXR28m0sNTBvxY0OG9ZXuSMx5I7wX0D/sQIOygKlJMUHk HTx1lpF36jdsUt7avRq4AsuHt4tkg4HC8o7xSlEJ8ABWhZSE/2LtbuegSadbDUS58Vl0 irjBOuDQe9FhCGJcFiJeavYNSYPbc67UjL74xQyTu8evvrClrMGcBGIX+bxq+V9Ya72M Vq/+9FhIhL4p3Y51xPQVdWRzjrFMfiIpsH13015RFZqN2SpB3N6dQICeWTSqRdcKkHJ3 emnNTie9/7r/iqYCO5Z6Kr28c+HLuUeGOrbup6P3gOXqEVwqHsKkfwea9Iudiv+//i4A lErA== 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=XS3y5g5NPy8qnQSqrHw4ufA9JHOcW2CdhLFrKP5qMpg=; b=S16S6+LO1KZh4DmwFrqAwdleSTgiKXk4rTfqDmNJpPm5VuMxfVHwMRSvErk4i4HJuw JjKof3D0QEySW11QMEKKYEkJH5cCGGw1m9potfhkx7ifEV+YIOTFpHK/jkWSfB/ml2yq gz25azuJuYYoeO8DAniUOLOp37gQJBdTecF8NY6pID3UzLIl2RqydBQKvRm7UuUfuVYv +xNbsckYlZjox6sGz33HusHjP1GENB1pJDjM8xMGxdmcQGdedYP8Abvib8xKH495l412 IX4xW76WqGfI8wkqkxk90OJmhq176XGLfVRWoBwfY/Mob/Pn1+2LigtQkgqlI8Zsmqy/ rYDQ== X-Gm-Message-State: AOUpUlHKD88h2K2lTJwsi1VNo2M4TcxM/U0rykxilLi035rZCt8B0eo9 11RQzyoOZS0x/iBpjIicqPT5jg== X-Google-Smtp-Source: AAOMgpeRmHPygP9520h2pV+lPygcFjWT03G3iQ/OEt5DzJYvr5O4Mujq9qMkJBAHK1MaJkJqIUxCtA== X-Received: by 2002:a63:f919:: with SMTP id h25-v6mr584184pgi.401.1531369311562; Wed, 11 Jul 2018 21:21:51 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:18 +0530 Message-Id: <20180712042120.2831-5-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 12 Jul 2018 04:21:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 12 Jul 2018 04:21:52 +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: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, 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.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 4/6] 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 12 Jul 2018 04:22:05 +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 | 1 + patchew-cli | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/api/rest.py b/api/rest.py index c9a131c..3045516 100644 --- a/api/rest.py +++ b/api/rest.py @@ -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 2069885..8029751 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,21 @@ 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/" + data =3D {"old_head": old_head, + "new_head": new_head, + "message_ids": msgids} + self.rest_api_do(url, request_method=3D'post', + content_type=3D'application/json', + data=3Djson.dumps(data)) + =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) + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') + projects =3D [p for p in r['results'] if p['name'] =3D=3D args.nam= e or args.name =3D=3D None] 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