From ad8c1ab6fa3e68e301b55e0715a79bd88ba81c3a Mon Sep 17 00:00:00 2001 From: JackDandy Date: Fri, 11 Sep 2020 16:24:09 +0100 Subject: [PATCH] Fix autoProcessTV.py to use `config.readfp` under py2 as `config.read_file` is py3.x+. Under py3, config.`readfp` is marked deprecated with advice to use `read_file` instead. However, py2 doesn't have `read_file`, so a little defensive coding is added here. --- CHANGES.md | 7 ++++++- autoProcessTV/autoProcessTV.py | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3771a34..4ee4b7a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,9 @@ -### 0.21.44 (2020-09-11 10:10:00 UTC) +### 0.21.45 (2020-09-11 16:25:00 UTC) + +* Fix autoProcessTV.py to use `config.readfp` under py2 as `config.read_file` is py3.x+. + + +### 0.21.44 (2020-09-11 10:10:00 UTC) * Fix thesubdb subtitle service under py3 * Change autoProcessTV.py to remove bytestring identifiers that are printed under py3 diff --git a/autoProcessTV/autoProcessTV.py b/autoProcessTV/autoProcessTV.py index 8e2ede1..2aecc53 100755 --- a/autoProcessTV/autoProcessTV.py +++ b/autoProcessTV/autoProcessTV.py @@ -76,7 +76,14 @@ def process_files(dir_to_process, org_nzb_name=None, status=None): print('Loading config from %s\n' % config_filename) with open(config_filename, 'r') as fp: - config.read_file(fp) + """ Under py3, `config.readfp` is flagged deprecated with advice to use read_file instead. + However, py2 doesn't have `read_file`, so a little defensive coding is added here + """ + if callable(getattr(config, 'read_file', None)): + config.read_file(fp) + else: + # noinspection PyDeprecation + config.readfp(fp) # Replace default values with config_file values host = config.get('SickBeard', 'host')