Mercurial > libervia-web
diff src/twisted/plugins/libervia_server.py @ 863:20fbca3c949a
server: fixed bad encoding handling in options parsing
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Feb 2016 19:32:43 +0100 |
parents | e17b15f1f260 |
children | a05f3b24f2ec |
line wrap: on
line diff
--- a/src/twisted/plugins/libervia_server.py Mon Jan 25 17:02:13 2016 +0100 +++ b/src/twisted/plugins/libervia_server.py Fri Feb 12 19:32:43 2016 +0100 @@ -70,12 +70,21 @@ def coerceConnectionType(value): # called from Libervia.OPT_PARAMETERS + if isinstance(value, unicode): + # XXX: if value comes from sat.conf, it's unicode, + # and we need byte str here (for twisted) + value = value.encode('utf-8') allowed_values = ('http', 'https', 'both') if value not in allowed_values: raise ValueError("%(given)s not in %(expected)s" % {'given': value, 'expected': str(allowed_values)}) return value def coerceDataDir(value): # called from Libervia.OPT_PARAMETERS + if isinstance(value, unicode): + # XXX: if value comes from sat.conf, it's unicode, + # and we need byte str here (for twisted) + value = value.encode('utf-8') + value = value.encode('utf-8') html = os.path.join(value, C.HTML_DIR) if not os.path.isfile(os.path.join(html, C.LIBERVIA_MAIN_PAGE)): raise ValueError("%s is not a Libervia's browser HTML directory" % os.path.realpath(html))