This commit is contained in:
Juke 2011-02-09 02:05:14 +01:00 committed by Romain Bignon
commit 87bf1f0d58
2 changed files with 14 additions and 12 deletions

View file

@ -38,7 +38,8 @@ def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
try_one_last_time = False try_one_last_time = False
break break
except ExceptionToCheck, e: except ExceptionToCheck, e:
logging.debug(u'%s, Retrying in %d seconds...' % (e, mdelay)) logging.debug(u'%s, Retrying in %d seconds...' % (e,
mdelay))
time.sleep(mdelay) time.sleep(mdelay)
mtries -= 1 mtries -= 1
mdelay *= backoff mdelay *= backoff

View file

@ -23,7 +23,8 @@ import traceback
import types import types
__all__ = ['get_backtrace', 'get_bytes_size', 'html2text', 'iter_fields', 'local2utc', 'to_unicode', 'utc2local'] __all__ = ['get_backtrace', 'get_bytes_size', 'html2text', 'iter_fields',
'local2utc', 'to_unicode', 'utc2local']
def get_backtrace(empty="Empty backtrace."): def get_backtrace(empty="Empty backtrace."):
@ -61,8 +62,8 @@ try:
html2text = h2t.html2text html2text = h2t.html2text
except ImportError: except ImportError:
warning('python-html2text is not present. HTML pages will not be converted into text.') warning('python-html2text is not present. HTML pages will not be converted into text.')
def html2text(s): def html2text(html):
return s return html
def iter_fields(obj): def iter_fields(obj):
@ -74,10 +75,10 @@ def iter_fields(obj):
yield attribute_name, attribute yield attribute_name, attribute
def local2utc(d): def local2utc(date):
d = d.replace(tzinfo=tz.tzlocal()) date = date.replace(tzinfo=tz.tzlocal())
d = d.astimezone(tz.tzutc()) date = date.astimezone(tz.tzutc())
return d return date
def to_unicode(text): def to_unicode(text):
@ -102,7 +103,7 @@ def to_unicode(text):
return unicode(text, 'windows-1252') return unicode(text, 'windows-1252')
def utc2local(d): def utc2local(date):
d = d.replace(tzinfo=tz.tzutc()) date = date.replace(tzinfo=tz.tzutc())
d = d.astimezone(tz.tzlocal()) date = date.astimezone(tz.tzlocal())
return d return date