From nobody Tue May 13 19:41:34 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 1530281205929648.5007571513372; Fri, 29 Jun 2018 07:06:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6ADD33082287; Fri, 29 Jun 2018 14:06:45 +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 509D9308BDB6; Fri, 29 Jun 2018 14:06:45 +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 419A74A465; Fri, 29 Jun 2018 14:06:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5TE6Zem023769 for ; Fri, 29 Jun 2018 10:06:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1689792302; Fri, 29 Jun 2018 14:06:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0670318768 for ; Fri, 29 Jun 2018 14:06:30 +0000 (UTC) Received: from mail-pl0-f54.google.com (mail-pl0-f54.google.com [209.85.160.54]) (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 DBB3F30001DC for ; Fri, 29 Jun 2018 14:06:19 +0000 (UTC) Received: by mail-pl0-f54.google.com with SMTP id z9-v6so4524107plo.1 for ; Fri, 29 Jun 2018 07:06:19 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.81]) by smtp.gmail.com with ESMTPSA id 14-v6sm20208806pgc.63.2018.06.29.07.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jun 2018 07:06:17 -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=TPcSfZC5Wj7D8QDqVsJXdDAt+V33DWzmNql+BNclfLnaT8Ks4HuAqyHKlLt+dpacdt D9oFdryGkyGNp9StG69WR8syCCwiS/tPzaVySv3jrz1gdUybv+2/x7apMa85+gksmL0P 5jOR8sivRpBgFkmTb6D2m30rC/ejmpObIVa3lZgPwhlNuYPNY8UlacmzFrR5TfAtpYkW ye9BUvUS3SyOj4bKmXlPgYeZ887hw4F0v1VSn03o6AniS4ZV+GDLIVpyu6Kwo+XbROeH eThfSLURVArGAu9Ls11b1HxjGAZ4kJdJcKkd7uXCxRkqSq2yb9Pa9xdD8sVdHGh3P07V RVIw== 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=QczC7VftEnn+rOOt9qcKkH3xnSKPgWWZI94382aX0ym2dwsCACf2byOsQyBhYa1wHs cTqGW0h7NPYo6m5sVRWDayXG/aLt2iysW3NjGKcAeR/Xv99HI2WbJhrNcXjOI1k9JJC/ v0bgvNFcmmWXdMzFuu+ksoAIjoNpS8tnXRY/bOfqNBun7QjGB8iHyDi1dV4HyiPPuWie JuREUdMg6EKIt4n0k31TrVncFHXdey7J6pv509ufbTm9EiWGASGUdLd6Ljc6sXZTYnSM 1aiaA7BpxF/J6NUwRAC0F/iFN7v0mdXNPgo4ZDoJRK6hx+cis59kYAAei7m4aPHeRsBh Ne4Q== X-Gm-Message-State: APt69E1bBA8CRi68VwbqiAmJ8LmfMms7BC5w+FKjsiQR3cFqllFjDQP2 LBCQbRQU3aQApPYW0I2GkissuA== X-Google-Smtp-Source: ADUXVKK0Z8zn6IeMEnuomkpU3D9Jm0vQKeRHruDPzi0U70J5O4yD0JIPHqq9Do7HKRXjGZkiK1Mv7w== X-Received: by 2002:a17:902:9b82:: with SMTP id y2-v6mr15174513plp.69.1530281178904; Fri, 29 Jun 2018 07:06:18 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Fri, 29 Jun 2018 19:35:49 +0530 Message-Id: <20180629140551.99829-2-shubhamjain7495@gmail.com> In-Reply-To: <20180629140551.99829-1-shubhamjain7495@gmail.com> References: <20180629140551.99829-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 29 Jun 2018 14:06:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 29 Jun 2018 14:06:20 +0000 (UTC) for IP:'209.85.160.54' DOMAIN:'mail-pl0-f54.google.com' HELO:'mail-pl0-f54.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.160.54 mail-pl0-f54.google.com 209.85.160.54 mail-pl0-f54.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v2 1/3] Make Patchew cli 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 29 Jun 2018 14:06:45 +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