From ea05235ddcb8d2cb0142842e7c9bf3ca19e3b4b9 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Thu, 3 Dec 2015 16:26:55 -0800 Subject: [PATCH] Fixed crash when opening links from the command line. --- rtv/__main__.py | 18 +++++++++++------- rtv/subreddit.py | 5 +---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/rtv/__main__.py b/rtv/__main__.py index 44d849e..2125185 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -65,10 +65,9 @@ def main(): with curses_session() as stdscr: term = Terminal(stdscr, config['ascii']) with term.loader(catch_exception=False): - reddit = praw.Reddit( - user_agent=user_agent, - decode_html_entities=False, - disable_update_check=True) + reddit = praw.Reddit(user_agent=user_agent, + decode_html_entities=False, + disable_update_check=True) # Authorize on launch if the refresh token is present oauth = OAuthHelper(reddit, term, config) @@ -76,13 +75,18 @@ def main(): oauth.authorize() with term.loader(): - page = SubredditPage( - reddit, term, config, oauth, - name=config['subreddit'], url=config['link']) + page = SubredditPage(reddit, term, config, oauth, + config['subreddit']) if term.loader.exception: return + # Open the supplied submission link before opening the subreddit + if config['link']: + page.open_submission(url=config['link']) + + # Launch the subreddit page page.loop() + except Exception as e: _logger.exception(e) raise diff --git a/rtv/subreddit.py b/rtv/subreddit.py index b010ad9..cb95ef3 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -19,7 +19,7 @@ class SubredditController(PageController): class SubredditPage(Page): - def __init__(self, reddit, term, config, oauth, name, url=None): + def __init__(self, reddit, term, config, oauth, name): """ Params: name (string): Name of subreddit to open @@ -31,9 +31,6 @@ class SubredditPage(Page): self.controller = SubredditController(self) self.nav = Navigator(self.content.get) - if url: - self.open_submission(url=url) - @SubredditController.register(curses.KEY_F5, 'r') def refresh_content(self, name=None, order=None): "Re-download all submissions and reset the page index"