def stopPushButtonPressed(self, button): # cancel shut down progress dictionary = { 'category': self.video_finder_plus_gid, 'shutdown': 'canceled' } self.parent.temp_db.updateQueueTable(dictionary) answer = download.downloadStop(self.gid, self.parent) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if answer == 'None': version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() notifySend(QCoreApplication.translate("progress_src_ui_tr", "Aria2 disconnected!"), QCoreApplication.translate( "progress_src_ui_tr", "Persepolis is trying to connect! be patient!"), 10000, 'warning', parent=self.parent)
def pausePushButtonPressed(self, button): if self.status == "downloading": answer = download.downloadPause(self.gid) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if not (answer): version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() download.downloadStop(self.gid, self.parent) notifySend("Aria2 disconnected!", "Persepolis is trying to connect! be patient!", 10000, 'warning', parent=self.parent) else: notifySend( QCoreApplication.translate("progress_src_ui_tr", "Aria2 did not respond!"), QCoreApplication.translate("progress_src_ui_tr", "Try again!"), 10000, 'critical', parent=self.parent)
def downloadCompleteAction(parent, path, download_path, file_name, file_size): # remove query from name, If file_name contains query components. # check if query existed. # query form is 1.mp3?foo=bar 2.mp3?blatz=pow 3.mp3?fizz=buzz file_name_split = file_name.split('.') file_extension = file_name_split[-1] file_name_without_extension = file_name_split[0] # if '?' in file_extension, then file_name contains query components. if '?' in file_extension: file_extension = file_extension.split('?')[0] file_name = '.'.join([file_name_without_extension, file_extension]) # rename file if file already existed i = 1 file_path = os.path.join(download_path, file_name) while os.path.isfile(file_path): file_name_split = file_name.split('.') extension_length = len(file_name_split[-1]) + 1 new_name = file_name[0:-extension_length] + \ '_' + str(i) + file_name[-extension_length:] file_path = os.path.join(download_path, new_name) i = i + 1 free_space = freeSpace(download_path) if free_space != None and file_size != None: # compare free disk space and file_size if free_space >= file_size: # move the file to the download folder try: # use shutil.copy instead of the default copy2 shutil.move(str(path) ,str(file_path) ,shutil.copy ) except: logger.sendToLog('Persepolis can not move file', "ERROR") file_path = path else: # notify user if we have insufficient disk space # and do not move file from temp download folder to download folder file_path = path logger.sendToLog('Insufficient disk space in download folder', "ERROR") # show notification notifySend("Insufficient disk space!", 'Please change download folder', 10000, 'fail', parent=parent) else: # move the file to the download folder try: shutil.move(str(path) ,str(file_path) ,shutil.copy ) except: logger.sendToLog('Persepolis can not move file', "ERROR") file_path = path return str(file_path)
def stopPushButtonPressed(self, button): answer = download.downloadStop(self.gid) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if answer == 'None': version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() notifySend("Aria2 disconnected!", "Persepolis is trying to connect!be patient!", 10000, 'warning', systemtray=self.parent.system_tray_icon)
def downloadCompleteAction(parent, path, download_path, file_name, file_size): i = 1 file_path = os.path.join(download_path, file_name) # rename file if file already existed while os.path.isfile(file_path): file_name_split = file_name.split('.') extension_length = len(file_name_split[-1]) + 1 new_name = file_name[0:-extension_length] + \ '_' + str(i) + file_name[-extension_length:] file_path = os.path.join(download_path, new_name) i = i + 1 free_space = freeSpace(download_path) if free_space != None and file_size != None: # compare free disk space and file_size if free_space >= file_size: # move the file to the download folder try: shutil.copy(str(path), str(file_path)) os.remove(path) except: print('Persepolis can not move file') logger.sendToLog('Persepolis can not move file', "ERROR") file_path = path else: # notify user if we have insufficient disk space # and do not move file from temp download folder to download folder file_path = path logger.sendToLog('Insufficient disk space in download folder', "ERROR") # show notification notifySend("Insufficient disk space!", 'Please change download folder', 10000, 'fail', systemtray=parent.system_tray_icon) else: # move the file to the download folder try: shutil.copy(str(path), str(file_path)) os.remove(path) except: print('Persepolis can not move file') logger.sendToLog('Persepolis can not move file', "ERROR") file_path = path return str(file_path)
def resumePushButtonPressed(self, button): if self.status == "paused": answer = download.downloadUnpause(self.gid) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if not(answer): version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() notifySend(QCoreApplication.translate("progress_src_ui_tr", "Aria2 disconnected!"), QCoreApplication.translate("progress_src_ui_tr", "Persepolis is trying to connect! be patient!"), 10000, 'warning', parent=self.parent) else: notifySend(QCoreApplication.translate("progress_src_ui_tr", "Aria2 did not respond!"), QCoreApplication.translate("progress_src_ui_tr", "Please try again."), 10000, 'warning', parent=self.parent)
def resumePushButtonPressed(self, button): if self.status == STATUS.DOWNLOAD.PAUSED: answer = download.downloadUnpause(self.gid) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if not(answer): version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() notifySend(QCoreApplication.translate("progress_src_ui_tr", "Aria2 disconnected!"), QCoreApplication.translate("progress_src_ui_tr", "Persepolis is trying to connect! be patient!"), 10000, 'warning', parent=self.parent) else: notifySend(QCoreApplication.translate("progress_src_ui_tr", "Aria2 did not respond!"), QCoreApplication.translate("progress_src_ui_tr", "Please try again."), 10000, 'warning', parent=self.parent)
def resumePushButtonPressed(self, button): if self.status == "paused": answer = download.downloadUnpause(self.gid) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if not(answer): version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() notifySend("Aria2 disconnected!", "Persepolis is trying to connect!be patient!", 10000, 'warning', systemtray=self.parent.system_tray_icon) else: notifySend("Aria2 did not respond!", "Try agian!", 10000, 'warning', systemtray=self.parent.system_tray_icon)
def stopPushButtonPressed(self, button): dict = {'gid': self.gid, 'shutdown': 'canceled'} self.parent.temp_db.updateSingleTable(dict) answer = download.downloadStop(self.gid, self.parent) # if aria2 did not respond , then this function is checking for aria2 # availability , and if aria2 disconnected then aria2Disconnected is # executed if answer == 'None': version_answer = download.aria2Version() if version_answer == 'did not respond': self.parent.aria2Disconnected() notifySend(QCoreApplication.translate("progress_src_ui_tr", "Aria2 disconnected!"), QCoreApplication.translate("progress_src_ui_tr", "Persepolis is trying to connect! be patient!"), 10000, 'warning', parent=self.parent)