From nobody Fri Oct 18 06:19:27 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 1530901974708661.9531863516895; Fri, 6 Jul 2018 11:32:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2211930832EE; Fri, 6 Jul 2018 18:32:54 +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 127C317195; Fri, 6 Jul 2018 18:32:54 +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 028484BB78; Fri, 6 Jul 2018 18:32:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w66IWqDA014135 for ; Fri, 6 Jul 2018 14:32:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8C732A2DF; Fri, 6 Jul 2018 18:32:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A13682A2F5 for ; Fri, 6 Jul 2018 18:32:50 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) (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 47EC13DE3D for ; Fri, 6 Jul 2018 18:32:39 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id k1-v6so3241768plt.2 for ; Fri, 06 Jul 2018 11:32:39 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.85]) by smtp.gmail.com with ESMTPSA id o4-v6sm19941545pfa.128.2018.07.06.11.32.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Jul 2018 11:32:37 -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=+Y5RotMow94VrsDIce50V6zK5o1ZkAIUzSrzf1WhY9M=; b=XOeeVMD2FSaAy3o7t0uI8Ms/5snhtrJVzkCHI5PB/zJBLFjg1DNuIxdWtPY8l0e+R2 We7GPqix9LBf63QXYZFMb0XzKFNC3v32g7ixClfsql91twNnADxQFOs+Fc7PsOyIYhmU ZMDr5xlRwT8uJnx8QP4IEs8mBXTlcAqpaf2VA3kRaUn8Feq+YsOoqlIkR24jD+2xuCf2 YlH5GL8+zkqbsweCjxPU7tb0GOhnFVD4WicAbbVTrtOK0n8GlfZoJ6G7leP8sgiIMLMN w0ra/y4r8kLlpkG3SsgA+aatqZzca80YkRpc0h52zZsE+iUQ+P19rq+iAIFMotTLE9Ae K+pw== 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=+Y5RotMow94VrsDIce50V6zK5o1ZkAIUzSrzf1WhY9M=; b=k7ZmPH9Sz5rCHfzGHj+/3QOnwIgf1Zt/cevfqANHTGfP79DGeMlHj6a5rOyabPyilC d2M4ldzP+84bhlKRGXcgXMIjsGAyNp1uEGuP+qGDKI8SzmT03vWAuiiXyRZnEMnfJUfM tmXPUnIFtWfrsxgXs3OWSgIoaIhVzvP703s238u4VqCbJ7qKKRxY1VKZqRaCQWDxZP3E fYajUFhuv/jA8tqoW3nWjyElIlFC3r5K5esmzcUzhaZdoaTGSP3e+BQC2xvgw79kKCjV icwisgJZu9Tg+lNgwNVfYEKicXe7QIRggvDduWPEAlK+Pm+l7NsWycFi7nlkBe6FrcwD H1hg== X-Gm-Message-State: APt69E1fHUmRreKbYlpHwNQLbafEXO39jy8KqxI4GwoCRieHoa0Aniij Sh2SMaA5Mq5D9XYWYWqFqrDvVA== X-Google-Smtp-Source: AAOMgpextrGX0JIxMjwtb/Jrvr2QFV1dn6GMUHuPkIwbVJyAD6o9SpFJvHsy0NdH32ea8MC6c2feOg== X-Received: by 2002:a17:902:8d91:: with SMTP id v17-v6mr11483473plo.9.1530901958253; Fri, 06 Jul 2018 11:32:38 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Sat, 7 Jul 2018 00:02:05 +0530 Message-Id: <20180706183207.31842-3-shubhamjain7495@gmail.com> In-Reply-To: <20180706183207.31842-1-shubhamjain7495@gmail.com> References: <20180706183207.31842-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 06 Jul 2018 18:32:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 06 Jul 2018 18:32:39 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.531 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.160.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v4 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 06 Jul 2018 18:32:54 +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 | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/api/rest.py b/api/rest.py index 45dab6e..39bdda0 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..9d9fde0 100755 --- a/patchew-cli +++ b/patchew-cli @@ -125,7 +125,7 @@ class SubCommand(object): else: r =3D None return r - =20 + def do(self, args, argv): """Do command""" print("Not implemented") @@ -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,18 @@ 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, request_method=3D'post', + 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