From 7e0d052006b5718c081b0bbc746b46b14c756828 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 16:49:31 +0000 Subject: [PATCH 1/2] Check that file exists --- notifications_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifications_client.py b/notifications_client.py index c93f27e6a..130074d4f 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -329,6 +329,8 @@ def _getSpeakerJsonFromIndex(boxName: str, index: int) -> {}: publishedYear + '/' + publishedMonth + '/' + indexList[index]) + if not os.path.isfile(speakerJsonFilename): + return None return loadJson(speakerJsonFilename) @@ -441,8 +443,6 @@ def _showLocalBox(boxName: str, content += ' ' if speakerJson.get('detectedLinks'): if len(speakerJson['detectedLinks']) > 0: - print("speakerJson['detectedLinks']: " + - str(speakerJson['detectedLinks'])) content = '🔗' + content content = (content[:40]) if len(content) > 40 else content print(indent + str(posStr) + ' | ' + str(name) + ' | ' + From 774462925756389aeae2e3c61fdf3539e8792dd8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Mar 2021 17:00:23 +0000 Subject: [PATCH 2/2] Opening links --- notifications_client.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/notifications_client.py b/notifications_client.py index 130074d4f..4f7d41b80 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -1153,11 +1153,11 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, else: print('No --screenreader option was specified') elif keyPress.startswith('open'): - currIndex = currInboxIndex - if currTimeline == 'dm': - currIndex = currDMIndex - elif currTimeline == 'sent': - currIndex = currSentIndex + currIndex = 0 + if ' ' in keyPress: + postIndex = keyPress.split(' ')[1].strip() + if postIndex.isdigit(): + currIndex = int(postIndex) speakerJson = \ _getSpeakerJsonFromIndex(currTimeline, currIndex) if not speakerJson: @@ -1165,12 +1165,6 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, linkOpened = False if speakerJson.get('detectedLinks'): if len(speakerJson['detectedLinks']) > 0: - if ' ' in keyPress: - postIndex = keyPress.split(' ')[1].strip() - if postIndex.isdigit(): - speakerJson = \ - _getSpeakerJsonFromIndex(currTimeline, - int(postIndex)) for url in speakerJson['detectedLinks']: if '://' in url: webbrowser.open(url) @@ -1179,7 +1173,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, sayStr = 'Opened web links' _sayCommand(sayStr, sayStr, originalScreenReader, systemLanguage, espeak) - else: + if not linkOpened: sayStr = 'There are no web links to open.' _sayCommand(sayStr, sayStr, originalScreenReader, systemLanguage, espeak)