Mercurial > hg > documentViewer
diff SrvTxtUtils.py @ 546:2928037f9a75
ASSIGNED - # 249: Annotations shared in groups
https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/ticket/249
author | casties |
---|---|
date | Tue, 28 Aug 2012 20:24:01 +0200 |
parents | f8a5f63eafc0 |
children | 2fe04b61ed95 |
line wrap: on
line diff
--- a/SrvTxtUtils.py Wed Aug 22 16:51:21 2012 +0200 +++ b/SrvTxtUtils.py Tue Aug 28 20:24:01 2012 +0200 @@ -11,7 +11,7 @@ import logging -srvTxtUtilsVersion = "1.4.1" +srvTxtUtilsVersion = "1.5" def getInt(number, default=0): """returns always an int (0 in case of problems)""" @@ -37,7 +37,7 @@ except: return s.decode('latin-1') else: - return unicode(s) + return s def utf8ify(s): """encode unicode object or string into byte string in utf-8 representation. @@ -47,7 +47,7 @@ if isinstance(s, str): return s else: - return unicode(s).encode('utf-8') + return s.encode('utf-8') def getText(node, recursive=0): """returns all text content of a node and its subnodes""" @@ -75,7 +75,7 @@ -def getHttpData(url, data=None, num_tries=3, timeout=10): +def getHttpData(url, data=None, num_tries=3, timeout=10, noExceptions=False): """returns result from url+data HTTP request""" # we do GET (by appending data to url) if isinstance(data, str) or isinstance(data, unicode): @@ -116,6 +116,9 @@ response.close() return data + if noExceptions: + return None + raise IOError("ERROR fetching HTTP data from %s: %s"%(url,errmsg)) #return None