Merge pull request #334 from radiorabe/revert/pypofile-changes

Revert pypofile try block move
This commit is contained in:
Robb 2017-10-17 20:12:46 -04:00 committed by GitHub
commit 3258983b21
1 changed files with 12 additions and 5 deletions

View File

@ -2,6 +2,7 @@
from threading import Thread from threading import Thread
from Queue import Empty from Queue import Empty
from ConfigParser import NoOptionError
import logging import logging
import shutil import shutil
@ -61,12 +62,18 @@ class PypoFile(Thread):
self.logger.info("copying from %s to local cache %s" % (src, dst)) self.logger.info("copying from %s to local cache %s" % (src, dst))
CONFIG_SECTION = "general" CONFIG_SECTION = "general"
username = self._config.get(CONFIG_SECTION, 'api_key')
baseurl = self._config.get(CONFIG_SECTION, 'base_url')
try: try:
username = self._config.get(CONFIG_SECTION, 'api_key') port = self._config.get(CONFIG_SECTION, 'base_port')
baseurl = self._config.get(CONFIG_SECTION, 'base_url') except NoOptionError, e:
port = self._config.get(CONFIG_SECTION, 'base_port', 80) port = 80
protocol = self._config.get(CONFIG_SECTION, 'protocol', str(("http", "https")[int(port) == 443])) try:
protocol = self._config.get(CONFIG_SECTION, 'protocol')
except NoOptionError, e:
protocol = str(("http", "https")[int(port) == 443])
try:
host = [protocol, baseurl, port] host = [protocol, baseurl, port]
url = "%s://%s:%s/rest/media/%s/download" % (host[0], url = "%s://%s:%s/rest/media/%s/download" % (host[0],
host[1], host[1],
@ -162,7 +169,7 @@ class PypoFile(Thread):
def read_config_file(self, config_path): def read_config_file(self, config_path):
"""Parse the application's config file located at config_path.""" """Parse the application's config file located at config_path."""
config = ConfigParser.SafeConfigParser() config = ConfigParser.SafeConfigParser(allow_no_value=True)
try: try:
config.readfp(open(config_path)) config.readfp(open(config_path))
except IOError as e: except IOError as e: