changeset 870:a05f3b24f2ec

server: use C.bool for bool options instead of simple int
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 12:37:58 +0100
parents fa7703642c0e
children 54f6c5b86a87
files src/twisted/plugins/libervia_server.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/twisted/plugins/libervia_server.py	Mon Feb 29 12:37:45 2016 +0100
+++ b/src/twisted/plugins/libervia_server.py	Mon Feb 29 12:37:58 2016 +0100
@@ -93,6 +93,9 @@
         raise ValueError("%s is not a Libervia's server data directory" % os.path.realpath(themes_dir))
     return value
 
+def coerceBool(value):
+    return C.bool(value)
+
 DATA_DIR_DEFAULT = ''
 OPT_PARAMETERS_BOTH = [['connection_type', 't', 'https', _(u"'http', 'https' or 'both' (to launch both servers).").encode('utf-8'), coerceConnectionType],
                        ['port', 'p', 8080, _(u'The port number to listen HTTP on.').encode('utf-8'), int],
@@ -101,8 +104,8 @@
                        ['tls_private_key', '', '', _(u'TLS certificate private key (PEM format)').encode('utf-8'), str],
                        ['tls_certificate', 'c', 'libervia.pem', _(u'TLS public certificate or private key and public certificate combined (PEM format)').encode('utf-8'), str],
                        ['tls_chain', '', '', _(u'TLS certificate intermediate chain (PEM format)').encode('utf-8'), str],
-                       ['redirect_to_https', 'r', 1, _(u'Automatically redirect from HTTP to HTTPS.').encode('utf-8'), int],
-                       ['security_warning', 'w', 1, _(u'Warn user that he is about to connect on HTTP.').encode('utf-8'), int],
+                       ['redirect_to_https', 'r', True, _(u'Automatically redirect from HTTP to HTTPS.').encode('utf-8'), coerceBool],
+                       ['security_warning', 'w', True, _(u'Warn user that he is about to connect on HTTP.').encode('utf-8'), coerceBool],
                        ['passphrase', 'k', '', (_(u"Passphrase for the SàT profile named '%s'") % C.SERVICE_PROFILE).encode('utf-8'), str],
                        ['data_dir', 'd', DATA_DIR_DEFAULT, _(u'Data directory for Libervia').encode('utf-8'), coerceDataDir],
                       ]  # options which are in sat.conf and on command line, see https://twistedmatrix.com/documents/current/api/twisted.python.usage.Options.html