comparison 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
comparison
equal deleted inserted replaced
862:e3e2effc9a4c 863:20fbca3c949a
68 import os 68 import os
69 os._exit(1) 69 os._exit(1)
70 70
71 71
72 def coerceConnectionType(value): # called from Libervia.OPT_PARAMETERS 72 def coerceConnectionType(value): # called from Libervia.OPT_PARAMETERS
73 if isinstance(value, unicode):
74 # XXX: if value comes from sat.conf, it's unicode,
75 # and we need byte str here (for twisted)
76 value = value.encode('utf-8')
73 allowed_values = ('http', 'https', 'both') 77 allowed_values = ('http', 'https', 'both')
74 if value not in allowed_values: 78 if value not in allowed_values:
75 raise ValueError("%(given)s not in %(expected)s" % {'given': value, 'expected': str(allowed_values)}) 79 raise ValueError("%(given)s not in %(expected)s" % {'given': value, 'expected': str(allowed_values)})
76 return value 80 return value
77 81
78 def coerceDataDir(value): # called from Libervia.OPT_PARAMETERS 82 def coerceDataDir(value): # called from Libervia.OPT_PARAMETERS
83 if isinstance(value, unicode):
84 # XXX: if value comes from sat.conf, it's unicode,
85 # and we need byte str here (for twisted)
86 value = value.encode('utf-8')
87 value = value.encode('utf-8')
79 html = os.path.join(value, C.HTML_DIR) 88 html = os.path.join(value, C.HTML_DIR)
80 if not os.path.isfile(os.path.join(html, C.LIBERVIA_MAIN_PAGE)): 89 if not os.path.isfile(os.path.join(html, C.LIBERVIA_MAIN_PAGE)):
81 raise ValueError("%s is not a Libervia's browser HTML directory" % os.path.realpath(html)) 90 raise ValueError("%s is not a Libervia's browser HTML directory" % os.path.realpath(html))
82 themes_dir = os.path.join(value, C.THEMES_DIR) 91 themes_dir = os.path.join(value, C.THEMES_DIR)
83 if not os.path.isfile(os.path.join(themes_dir, 'default/styles/blog.css')): 92 if not os.path.isfile(os.path.join(themes_dir, 'default/styles/blog.css')):