From 6ad25b96eeae1ad3d7f6643dfa80b7fe761e03a7 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Mon, 9 Mar 2015 14:06:37 +0200 Subject: [PATCH] Add error message on open_dir fail --- youtube_dl_gui/mainframe.py | 8 +++++++- youtube_dl_gui/utils.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index ddcdb3b..2d375c6 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -98,6 +98,9 @@ class MainFrame(wx.Frame): UPDATE_ERR_MSG = _("Youtube-dl download failed [{0}]") UPDATE_SUCC_MSG = _("Youtube-dl downloaded correctly") + OPEN_DIR_ERR = _("Unable to open directory: '{dir}'. " + "The specified path does not exist") + VIDEO_LABEL = _("Title") SIZE_LABEL = _("Size") PERCENT_LABEL = _("Percent") @@ -269,7 +272,10 @@ class MainFrame(wx.Frame): else: self._create_popup(self.DL_COMPLETED_MSG, self.INFO_LABEL, wx.OK | wx.ICON_INFORMATION) if self.opt_manager.options['open_dl_dir']: - open_dir(self.opt_manager.options['save_path']) + success = open_dir(self.opt_manager.options['save_path']) + + if not success: + self._status_bar_write(self.OPEN_DIR_ERR.format(dir=self.opt_manager.options['save_path'])) def _status_list_handler(self, msg): """downloadmanager.Worker thread handler. diff --git a/youtube_dl_gui/utils.py b/youtube_dl_gui/utils.py index d3fb908..e6c8e31 100644 --- a/youtube_dl_gui/utils.py +++ b/youtube_dl_gui/utils.py @@ -46,14 +46,19 @@ def get_lib_path(): def open_dir(path): - """Open path using default file navigator. """ + """Open path using default file navigator. + Return True if path exists else False. """ path = remove_shortcuts(path) + if not os.path.exists(path): + return False + if os.name == 'nt': os.startfile(path) else: subprocess.call(('xdg-open', path)) + return True def check_path(path): """Create path if not exist. """