From 1e79deb14c7a9bad16d75e0bc6cef8c282bffc1c Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 21 Jul 2012 12:03:32 +0200 Subject: tracking: Fixed some newly added encoding oddities. --- modules/tracking.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/tracking.py b/modules/tracking.py index 7303e37..3a11d7a 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -48,6 +48,9 @@ class Consignment(Base): s += ' (%s)' % self.label.encode('utf-8') return s + def __unicode__(self): + return str(self).decode('utf-8') + class Package(Base): __tablename__ = 'package' @@ -67,6 +70,9 @@ class Package(Base): s += ' (%s)' % self.consignment.label.encode('utf-8') return s + def __unicode__(self): + return str(self).decode('utf-8') + class PackageError(Exception): pass class NoPackageFound(PackageError): pass @@ -235,7 +241,7 @@ class Module: try: self.track_update(row.code, propagate_error = True) except PackageError as e: - results.append('Failed to fetch data for %s.' % row) + results.append('Failed to fetch data for %s.' % unicode(row)) continue i = 0 @@ -245,14 +251,14 @@ class Module: desc = package.status if date and desc: - s = '%s %s - %s' % (package, date, desc) + s = '%s %s - %s' % (unicode(package), date, desc) else: - s = 'No tracking info found for %s' % package + s = 'No tracking info found for %s' % unicode(package) results.append(s) if i == 0: - results.append('No packages found for %s' % row) + results.append('No packages found for %s' % unicode(row)) if len(results): msg = results -- cgit v1.2.3