From f69ee9b6ab1072f48842439afa3fed4dd012b92a Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 25 Jul 2013 14:43:00 -0400 Subject: [PATCH] change date link to something more understandable change the date link to something human creatable (the uri escapes got obtuse quickly). Also change it to something which is a valid css class name so that we could highlight the lines later. This required some changes to span parsing to inject the additional css class. Finally add a couple of fixups suggested by clarkb and fungi on the last round. This should be ready for main log server. Change-Id: Ia5111873ee60c174a5c7ddc479fa0c63ead9d97d --- .../files/logs/htmlify-screen-log.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/openstack_project/files/logs/htmlify-screen-log.py b/modules/openstack_project/files/logs/htmlify-screen-log.py index 2eae8d10f9..70cb4e6dff 100755 --- a/modules/openstack_project/files/logs/htmlify-screen-log.py +++ b/modules/openstack_project/files/logs/htmlify-screen-log.py @@ -20,7 +20,6 @@ import fileinput import os.path import re import sys -import urllib import wsgiref.util @@ -30,7 +29,7 @@ LOGMATCH = '(?P%s)(?P \d+)? (?P%s)' % (DATEFMT, STATUSFMT) def _html_close(): - return ("\n") + return ("\n") def _css_preamble(): @@ -46,7 +45,7 @@ a:hover {text-decoration: underline} .WARN, .WARN a {color: #D89100; font-weight: bold} .INFO, .INFO a {color: #006; font-weight: bold} -
\n""")
+
\n""")
 
 
 def color_by_sev(line):
@@ -70,12 +69,13 @@ def escape_html(line):
 
 def link_timestamp(line):
     m = re.match(
-        '(?P]*>)?(?P%s)(?P.*)' % DATEFMT,
+        '([^\']+)\'>)?(?P%s)(?P.*)' % DATEFMT,
         line)
     if m:
-        date = urllib.quote(m.group('date'))
-        return "%s%s%s\n" % (
-            m.group('span'), date, date, m.group('date'), m.group('rest'))
+        date = "_" + re.sub('[\s\:\.]', '_', m.group('date'))
+
+        return "%s%s\n" % (
+            m.group('class'), date, date, date, m.group('date'), m.group('rest'))
     else:
         return line
 
@@ -112,7 +112,7 @@ def htmlify_stdin():
 
 
 def safe_path(root, environ):
-    """Pull out a save path from a url.
+    """Pull out a safe path from a url.
 
     Basically we need to ensure that the final computed path
     remains under the root path. If not, we return None to indicate
@@ -121,7 +121,7 @@ def safe_path(root, environ):
     path = wsgiref.util.request_uri(environ)
     match = re.search('htmlify/(.*)', path)
     raw = match.groups(1)[0]
-    newpath = os.path.abspath("%s/%s" % (root, raw))
+    newpath = os.path.abspath(os.path.join(root, raw))
     if newpath.find(root) == 0:
         return newpath
     else: