From 48a99f8934425345ae382ddcd1675f232a2dbc3d Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sun, 11 May 2014 19:15:14 +0300 Subject: [PATCH] Dont shutdown if stopped --- youtube_dl_gui/DownloadThread.py | 2 ++ youtube_dl_gui/YoutubeDLGUI.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/youtube_dl_gui/DownloadThread.py b/youtube_dl_gui/DownloadThread.py index 230022b..2f1a6f3 100644 --- a/youtube_dl_gui/DownloadThread.py +++ b/youtube_dl_gui/DownloadThread.py @@ -28,6 +28,7 @@ class DownloadManager(Thread): self.download_list = download_list self.opt_manager = opt_manager self.log_manager = log_manager + self.stopped = False self._threads_lst = [] self._running = True self._kill = False @@ -68,6 +69,7 @@ class DownloadManager(Thread): self._callafter('close') self._running = False self._kill = kill + self.stopped = True def _download(self, url, index): ''' Download given url ''' diff --git a/youtube_dl_gui/YoutubeDLGUI.py b/youtube_dl_gui/YoutubeDLGUI.py index af15c39..e4bdd20 100644 --- a/youtube_dl_gui/YoutubeDLGUI.py +++ b/youtube_dl_gui/YoutubeDLGUI.py @@ -167,13 +167,15 @@ class MainFrame(wx.Frame): def status_bar_write(self, msg): self.status_bar.SetLabel(msg) - def fin_tasks(self): + def reset(self): + ''' Reset GUI and variables ''' self.download_button.SetLabel('Download') self.update_button.Enable() self.download_thread.join() self.download_thread = None self.ori_url_list = [] - + + def fin_tasks(self): if self.opt_manager.options['shutdown']: shutdown_sys(self.opt_manager.options['sudo_password']) else: @@ -194,9 +196,12 @@ class MainFrame(wx.Frame): if topic == 'download_manager': if data == 'close': self.status_bar_write('Stopping downloads') - elif data == 'finish': + if data == 'finish': self.status_bar_write('Done') - self.fin_tasks() + stopped = self.download_thread.stopped + self.reset() + if not stopped: + self.fin_tasks() def update_handler(self, msg): if msg.data == 'finish':