From nobody Mon Dec 15 23:13:59 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528886279672967.5634328784012; Wed, 13 Jun 2018 03:37:59 -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 30716308FB9A; Wed, 13 Jun 2018 10:37:59 +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 1E98C17B40; Wed, 13 Jun 2018 10:37:59 +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 136361808800; Wed, 13 Jun 2018 10:37:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5DAbtQx009810 for ; Wed, 13 Jun 2018 06:37:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id C4FE92026987; Wed, 13 Jun 2018 10:37:55 +0000 (UTC) Received: from donizetti.redhat.com (unknown [10.36.118.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B79220244E1 for ; Wed, 13 Jun 2018 10:37:55 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 13 Jun 2018 12:37:44 +0200 Message-Id: <20180613103744.30891-11-pbonzini@redhat.com> In-Reply-To: <20180613103744.30891-1-pbonzini@redhat.com> References: <20180613103744.30891-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 10/10] logviewer: let subclasses return a Result 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.43]); Wed, 13 Jun 2018 10:37:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no need for subclasses to return the log directly; they can just get the result, and the log viewer can check whether the result has a log attached to it. Signed-off-by: Paolo Bonzini --- mods/git.py | 7 ++----- mods/testing.py | 5 ++--- patchew/logviewer.py | 14 ++++++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/mods/git.py b/mods/git.py index 2b24b24..a2b6d86 100644 --- a/mods/git.py +++ b/mods/git.py @@ -35,15 +35,12 @@ Message.git_result =3D property(_get_git_result) =20 =20 class GitLogViewer(LogView): - def content(self, request, **kwargs): + def get_result(self, request, **kwargs): series =3D kwargs['series'] obj =3D Message.objects.find_series(series) if not obj: raise Http404("Object not found: " + series) - r =3D obj.git_result - if r is None or not r.is_completed(): - raise Http404("Git apply log not found") - return r.log + return obj.git_result =20 =20 class GitModule(PatchewModule): diff --git a/mods/testing.py b/mods/testing.py index 7dfc5a2..0a80b3d 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -35,7 +35,7 @@ exit 0 """ =20 class TestingLogViewer(LogView): - def content(self, request, **kwargs): + def get_result(self, request, **kwargs): project_or_series =3D kwargs['project_or_series'] testing_name =3D kwargs['testing_name'] if request.GET.get("type") =3D=3D "project": @@ -44,8 +44,7 @@ class TestingLogViewer(LogView): obj =3D Message.objects.find_series(project_or_series) if not obj: raise Http404("Object not found: " + project_or_series) - r =3D _instance.get_testing_result(obj, testing_name) - return r.log + return _instance.get_testing_result(obj, testing_name) =20 =20 class TestingModule(PatchewModule): diff --git a/patchew/logviewer.py b/patchew/logviewer.py index fe0f3ca..f986727 100644 --- a/patchew/logviewer.py +++ b/patchew/logviewer.py @@ -436,7 +436,7 @@ def ansi2html(input, white_bg=3DFalse): =20 class LogView(View, metaclass=3Dabc.ABCMeta): @abc.abstractmethod - def content(request, **kwargs): + def get_result(request, **kwargs): return None =20 # Unfortunately
 items cannot be focused; for arrow keys to
@@ -463,16 +463,18 @@ if (parent.jQuery && parent.jQuery.colorbox) {
     });
 }""")
=20
-    def generate_html(self):
+    def generate_html(self, log):
         yield self.HTML_PROLOG
-        yield from ansi2html(self.text)
+        yield from ansi2html(log)
=20
     def get(self, request, **kwargs):
-        self.text =3D self.content(request, **kwargs)
+        result =3D self.get_result(request, **kwargs)
+        if result is None or not result.is_completed() or result.log is No=
ne:
+            raise Http404("No log found")
         if request.GET.get('html', None) !=3D '1':
-            return HttpResponse(self.text, content_type=3D'text/plain')
+            return HttpResponse(result.log, content_type=3D'text/plain')
=20
-        return StreamingHttpResponse(self.generate_html())
+        return StreamingHttpResponse(self.generate_html(result.log))
=20
 if __name__ =3D=3D "__main__":
     import io
--=20
2.17.0

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel