diff --git a/lib/galaxy/web/framework/base.py b/lib/galaxy/web/framework/base.py index b2ef292deb1..7f08994f20c 100644 --- a/lib/galaxy/web/framework/base.py +++ b/lib/galaxy/web/framework/base.py @@ -499,12 +499,12 @@ def send_file(start_response, trans, body): return body -def iterate_file(file): +def iterate_file(fh): """ Progressively return chunks from `file`. """ while 1: - chunk = file.read(CHUNK_SIZE) + chunk = fh.read(CHUNK_SIZE) if not chunk: break yield chunk diff --git a/lib/galaxy/webhooks/__init__.py b/lib/galaxy/webhooks/__init__.py index e32ee2d9ba6..e5d32fdc7d4 100644 --- a/lib/galaxy/webhooks/__init__.py +++ b/lib/galaxy/webhooks/__init__.py @@ -1,6 +1,7 @@ """ This module manages loading of Galaxy webhooks. """ +import io import logging import os @@ -64,8 +65,8 @@ class WebhooksRegistry(object): log.exception(e) def load_webhook_from_config(self, webhook_dir, config_file_path): - with open(config_file_path) as file: - config = yaml.safe_load(file) + with open(config_file_path) as fh: + config = yaml.safe_load(fh) weight = config.get('weight', 1) if weight < 1: @@ -83,8 +84,8 @@ class WebhooksRegistry(object): # single file try: styles_file = os.path.join(webhook_dir, 'styles.css') - with open(styles_file, 'r') as file: - webhook.styles = file.read().replace('\n', '') + with open(styles_file, 'r') as fh: + webhook.styles = fh.read().replace('\n', '') except IOError: pass @@ -92,8 +93,8 @@ class WebhooksRegistry(object): # single file try: script_file = os.path.join(webhook_dir, 'script.js') - with open(script_file, 'r') as file: - webhook.script = file.read() + with io.open(script_file, 'r', encoding='utf-8') as fh: + webhook.script = fh.read() except IOError: pass