ソースを参照

HUE-672 [about] Logs page can't handle non-ascii characters

Converting logs to UTF-8 before rendering them.
500 header layout made prettier
Fix missing </li> in common header
Romain Rigaux 13 年 前
コミット
8139c60bd3

+ 24 - 21
desktop/core/src/desktop/templates/500.html

@@ -37,32 +37,35 @@ limitations under the License.
 		$(document).ready(function(){
 		$(document).ready(function(){
 		});
 		});
 	</script>
 	</script>
-	
+
 </head>
 </head>
 <body>
 <body>
-	<div class="topbar">
-		<div class="topbar-inner">
-			<div class="container-fluid">
-				<a class="brand" href="#">Hue</a>
-				<ul class="nav">
-					<li><a href="/beeswax">Beeswax</a></li>
-					<li><a href="/filebrowser/">File Browser</a></li>
-					<li><a href="/jobsub/">Job Designer</a></li>
-					<li><a href="/jobbrowser/jobs/">Job Browser</a></li>
-					<li><a href="/useradmin/">User Admin</a></li>
-					<li><a href="/shell/">Shell</a></li>
-					<li><a href="/help/">Help</a></li>
-					<li><a href="/about/">About</a></li>
-				</ul>
-			</div>
-		</div>
-	</div>
-	
+  <div class="navbar navbar-fixed-top">
+    <div class="navbar-inner">
+      <div class="container-fluid">
+        <a class="brand" href="#">Hue</a>
+        <div class="nav-collapse">
+          <ul class="nav">
+            <li><a href="/beeswax/">Beeswax</a></li>
+            <li><a href="/filebrowser/">File Browser</a></li>
+            <li><a href="/jobsub/">Job Designer</a></li>
+            <li><a href="/jobbrowser/jobs/">Job Browser</a></li>
+            <li><a href="/useradmin/">User Admin</a></li>
+            <li><a href="/shell/">Shell</a></li>
+            <li><a href="/help/">Help</a></li>
+            <li><a href="/about/">About</a></li>
+            <li class="divider-vertical"></li>
+            <li id="checkConfig"></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+  </div>
+
 	<div class="container-fluid">
 	<div class="container-fluid">
 		<h1>Server Error (500)</h1>
 		<h1>Server Error (500)</h1>
-		<p>There's been an error. It's been reported to the site administrators
+		<p>Sorry, there's been an error. It's been reported to the site administrators
 	  via e-mail and should be fixed shortly. Thanks for your patience.</p>
 	  via e-mail and should be fixed shortly. Thanks for your patience.</p>
-	  
 	</div>
 	</div>
 </body>
 </body>
 </html>
 </html>

+ 1 - 1
desktop/core/src/desktop/templates/common_header.html

@@ -84,7 +84,7 @@ limitations under the License.
 						<li {% is_selected section "help" %}><a href="/help/">Help</a></li>
 						<li {% is_selected section "help" %}><a href="/help/">Help</a></li>
 						<li {% is_selected section "about" %}><a href="/about/">About</a></li>
 						<li {% is_selected section "about" %}><a href="/about/">About</a></li>
 						<li class="divider-vertical"></li>
 						<li class="divider-vertical"></li>
-						<li id="checkConfig"><li>
+						<li id="checkConfig"></li>
 					</ul>
 					</ul>
 					<p class="navbar-text pull-right">Logged in as <strong><span id="username">xxx</span></strong> - <a href="/accounts/logout/">Sign out</a></p>
 					<p class="navbar-text pull-right">Logged in as <strong><span id="username">xxx</span></strong> - <a href="/accounts/logout/">Sign out</a></p>
 				</div>
 				</div>

+ 2 - 1
desktop/core/src/desktop/templates/logs.mako

@@ -15,6 +15,7 @@
 ## limitations under the License.
 ## limitations under the License.
 <%!
 <%!
 from desktop.lib.conf import BoundConfig
 from desktop.lib.conf import BoundConfig
+from desktop.lib.i18n import smart_unicode
 from desktop.views import commonheader, commonfooter
 from desktop.views import commonheader, commonfooter
 import re
 import re
 %>
 %>
@@ -29,7 +30,7 @@ ${layout.menubar(section='log_view')}
 		<% log.reverse() %>
 		<% log.reverse() %>
 		<pre>
 		<pre>
 		% for l in log:
 		% for l in log:
-${l | h}
+${smart_unicode(l) | h}
 		% endfor
 		% endfor
 		</pre>
 		</pre>
 
 

+ 13 - 0
desktop/core/src/desktop/tests.py

@@ -1,4 +1,5 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 # Licensed to Cloudera, Inc. under one
 # Licensed to Cloudera, Inc. under one
 # or more contributor license agreements.  See the NOTICE file
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
 # distributed with this work for additional information
@@ -19,6 +20,7 @@ from desktop.lib import django_mako
 from nose.tools import assert_true, assert_equal
 from nose.tools import assert_true, assert_equal
 from desktop.lib.django_test_util import make_logged_in_client
 from desktop.lib.django_test_util import make_logged_in_client
 from django.conf.urls.defaults import patterns, url
 from django.conf.urls.defaults import patterns, url
+from django.core.urlresolvers import reverse
 from django.http import HttpResponse
 from django.http import HttpResponse
 from django.db.models import query, CharField, SmallIntegerField
 from django.db.models import query, CharField, SmallIntegerField
 from desktop.lib.paginator import Paginator
 from desktop.lib.paginator import Paginator
@@ -63,6 +65,17 @@ def teardown_test_environment():
   django_mako.render_to_string = django_mako.render_to_string_normal
   django_mako.render_to_string = django_mako.render_to_string_normal
 teardown_test_environment.__test__ = False
 teardown_test_environment.__test__ = False
 
 
+def test_log_view():
+  c = make_logged_in_client()
+
+  URL = reverse(views.log_view)
+
+  LOG = logging.getLogger(__name__)
+  LOG.warn('une voix m’a réveillé')
+
+  # UnicodeDecodeError: 'ascii' codec can't decode byte... should not happen
+  response = c.get(URL)
+
 def test_dump_config():
 def test_dump_config():
   c = make_logged_in_client()
   c = make_logged_in_client()
 
 

+ 1 - 1
desktop/core/src/desktop/views.py

@@ -48,7 +48,7 @@ def log_view(request):
   l = logging.getLogger()
   l = logging.getLogger()
   for h in l.handlers:
   for h in l.handlers:
     if isinstance(h, desktop.log.log_buffer.FixedBufferHandler):
     if isinstance(h, desktop.log.log_buffer.FixedBufferHandler):
-	  return render('logs.mako', request, dict(log=[l for l in h.buf]))
+      return render('logs.mako', request, dict(log=[l for l in h.buf]))
 
 
   return render('logs.mako', request, dict(log=["No logs found!"]))
   return render('logs.mako', request, dict(log=["No logs found!"]))