Browse Source

Dont shutdown if stopped

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
48a99f8934
2 changed files with 11 additions and 4 deletions
  1. 2
      youtube_dl_gui/DownloadThread.py
  2. 13
      youtube_dl_gui/YoutubeDLGUI.py

2
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 '''

13
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':

Loading…
Cancel
Save