From ace7e493f4346d5e6c17fc9f4311f88086daf819 Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Sun, 15 Oct 2017 13:46:40 +0200 Subject: [PATCH] Fix port and protocol default values Turns our bare ConfigObjects don't to default passing very automatically. --- python_apps/pypo/pypo/pypofile.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python_apps/pypo/pypo/pypofile.py b/python_apps/pypo/pypo/pypofile.py index 4cf78e9f9..d63252041 100644 --- a/python_apps/pypo/pypo/pypofile.py +++ b/python_apps/pypo/pypo/pypofile.py @@ -63,8 +63,12 @@ class PypoFile(Thread): CONFIG_SECTION = "general" username = self._config.get(CONFIG_SECTION, 'api_key') baseurl = self._config.get(CONFIG_SECTION, 'base_url') - port = self._config.get(CONFIG_SECTION, 'base_port', 80) - protocol = self._config.get(CONFIG_SECTION, 'protocol', str(("http", "https")[int(port) == 443])) + port = self._config.get(CONFIG_SECTION, 'base_port') + if not port: + port = 80 + protocol = self._config.get(CONFIG_SECTION, 'protocol') + if not protocol: + protocol = str(("http", "https")[int(port) == 443]) try: host = [protocol, baseurl, port] @@ -162,7 +166,7 @@ class PypoFile(Thread): def read_config_file(self, config_path): """Parse the application's config file located at config_path.""" - config = ConfigParser.SafeConfigParser() + config = ConfigParser.SafeConfigParser(allow_no_value=True) try: config.readfp(open(config_path)) except IOError as e: