[damned-lies] Limit length of error message transmitted to bug report



commit 38a9261a9e1689f9f39bb2987a8898e0c0d53574
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Mar 10 22:45:06 2011 +0100

    Limit length of error message transmitted to bug report

 stats/models.py |    2 +-
 stats/utils.py  |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index c9dca60..321c958 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1571,7 +1571,7 @@ class Information(models.Model):
         link = self.statistics.branch.module.get_bugs_enter_url()
         link += "&short_desc=%(short)s&content=%(short)s&comment=%(long)s" % {
             'short': "Error regenerating POT file",
-            'long' : utils.stripHTML(self.get_description()),
+            'long' : utils.ellipsize(utils.stripHTML(self.get_description()), 1600),
         }
         return link
 
diff --git a/stats/utils.py b/stats/utils.py
index 7f0faea..8986bd6 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -54,6 +54,11 @@ def stripHTML(string):
     replacements = {"<ul>": "\n", "</ul>": "\n", "<li>": " * ", "\n</li>": "", "</li>": ""}
     return multiple_replace(replacements, string)
 
+def ellipsize(val, length):
+    if len(val) > length:
+        val = "%s..." % val[:length]
+    return val
+
 def run_shell_command(cmd, env=None, input_data=None, raise_on_error=False):
     if settings.DEBUG: print >>sys.stderr, cmd
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]