From 357ee4feed9a802532b869c71ebf003db4ff0874 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Tue, 26 Jul 2016 22:31:00 -0700 Subject: [PATCH 1/2] Ignore ResourceWarnings. #263. --- rtv/__main__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rtv/__main__.py b/rtv/__main__.py index e38d9fa..c8605ca 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -5,7 +5,9 @@ import os import sys import locale import logging +import warnings +import six import praw import tornado @@ -34,6 +36,10 @@ def main(): # Squelch SSL warnings logging.captureWarnings(True) + if six.PY3: + # These ones get triggered even when capturing warnings is turned on + warnings.simplefilter('ignore', ResourceWarning) + locale.setlocale(locale.LC_ALL, '') # Set the terminal title From a1b7b7310f679e7297000e4b8fe93d4097536601 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Tue, 26 Jul 2016 23:05:35 -0700 Subject: [PATCH 2/2] Better handling for urlview errors. #262. --- rtv/terminal.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rtv/terminal.py b/rtv/terminal.py index 22c8d8d..f2467e2 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -455,6 +455,16 @@ class Terminal(object): p.communicate(input=data.encode('utf-8')) except KeyboardInterrupt: p.terminate() + + code = p.poll() + if code == 1: + # Clear the "No URLs found." message from stdout + sys.stdout.write("\033[F") + sys.stdout.flush() + + if code == 1: + self.show_notification('No URLs found') + except OSError: self.show_notification( 'Failed to open {0}'.format(urlview))