def removeSelected(self,menu): global remove_flag remove_flag = 1 while remove_flag != 2 : sleep(0.1) gid_list = [] for row in range(self.download_table.rowCount()): status = self.download_table.item(row , 1).text() item = self.download_table.item(row , 0) if (item.checkState() == 2) and (status == 'complete' or status == 'error' or status == 'stopped' ): gid = self.download_table.item(row , 8 ).text() gid_list.append(gid) for gid in gid_list: for i in range(self.download_table.rowCount()): row_gid = self.download_table.item(i , 8).text() if gid == row_gid : row = i break file_name = self.download_table.item(row , 0).text() sleep(0.5) self.download_table.removeRow(row) #remove gid of download from download list file f = Open(download_list_file) download_list_file_lines = f.readlines() f.close() f = Open(download_list_file , "w") for i in download_list_file_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove gid of download from active download list file f = Open(download_list_file_active) download_list_file_active_lines = f.readlines() f.close() f = Open(download_list_file_active , "w") for i in download_list_file_active_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove download_info_file download_info_file = download_info_folder + "/" + gid f = Open(download_info_file) f.close() f.remove() #remove file of download form download temp folder if file_name != '***' and status != 'complete' : file_name_path = temp_download_folder + "/" + str(file_name) os.system('rm "' + str(file_name_path) +'"') file_name_aria = file_name_path + str('.aria2') os.system('rm "' + str(file_name_aria) +'"') remove_flag = 0
def checkFlashgot(self): sleep(0.5) flashgot_file = Open("/tmp/persepolis-flashgot") flashgot_line = flashgot_file.readlines() flashgot_file.close() flashgot_file.remove() flashgot_add_link_dictionary_str = flashgot_line[0] flashgot_add_link_dictionary = ast.literal_eval(flashgot_add_link_dictionary_str) self.flashgotAddLink(flashgot_add_link_dictionary)
def removeButtonPressed(self,button): self.removeAction.setEnabled(False) global remove_flag if remove_flag !=3 : remove_flag = 1 while remove_flag != 2 : sleep(0.1) selected_row_return = self.selectedRow() if selected_row_return != None: gid = self.download_table.item(selected_row_return , 8 ).text() file_name = self.download_table.item(selected_row_return , 0).text() status = self.download_table.item(selected_row_return , 1).text() sleep(0.5) self.download_table.removeRow(selected_row_return) #remove gid of download from download list file f = Open(download_list_file) download_list_file_lines = f.readlines() f.close() f = Open(download_list_file , "w") for i in download_list_file_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove gid of download from active download list file f = Open(download_list_file_active) download_list_file_active_lines = f.readlines() f.close() f = Open(download_list_file_active , "w") for i in download_list_file_active_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove download_info_file download_info_file = download_info_folder + "/" + gid f = Open(download_info_file) f.close() f.remove() #remove file of download form download temp folder if file_name != '***' and status != 'complete' : file_name_path = temp_download_folder + "/" + str(file_name) os.system('rm "' + str(file_name_path) +'"') file_name_aria = file_name_path + str('.aria2') os.system('rm "' + str(file_name_aria) +'"') else: self.statusbar.showMessage("Please select an item first!") remove_flag = 0 self.selectedRow()
def removeButtonPressed(self,button): self.removeAction.setEnabled(False) selected_row_return = self.selectedRow() if selected_row_return != None: gid = self.download_table.item(selected_row_return , 8 ).text() try: file_name = self.download_table.item(selected_row_return , 0).text() except: file_name = None sleep(0.5) self.download_table.removeRow(selected_row_return) #remove gid of download from download list file f = Open(download_list_file) download_list_file_lines = f.readlines() f.close() f = Open(download_list_file , "w") for i in download_list_file_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove gid of download from active download list file f = Open(download_list_file_active) download_list_file_active_lines = f.readlines() f.close() f = Open(download_list_file_active , "w") for i in download_list_file_active_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove download_info_file download_info_file = download_info_folder + "/" + gid f = Open(download_info_file) f.close() f.remove() #remove file of download form download temp folder if file_name != None : file_name_path = temp_download_folder + "/" + str(file_name) os.system('rm "' + str(file_name_path) +'"') file_name_aria = file_name_path + str('.aria2') os.system('rm "' + str(file_name_aria) +'"') else: self.statusbar.showMessage("Please select an item first!") self.selectedRow()
def deleteSelected(self,menu): global remove_flag remove_flag = 1 while remove_flag != 2 : sleep(0.1) gid_list = [] for row in range(self.download_table.rowCount()): status = self.download_table.item(row , 1).text() item = self.download_table.item(row , 0) if (item.checkState() == 2) and (status == 'complete' or status == 'error' or status == 'stopped' ): gid = self.download_table.item(row , 8 ).text() gid_list.append(gid) for gid in gid_list: for i in range(self.download_table.rowCount()): row_gid = self.download_table.item(i , 8).text() if gid == row_gid : row = i break file_name = self.download_table.item(row , 0).text() add_link_dictionary_str = self.download_table.item(row , 9).text() add_link_dictionary = ast.literal_eval(add_link_dictionary_str) sleep(0.5) self.download_table.removeRow(row) #remove gid of download from download list file f = Open(download_list_file) download_list_file_lines = f.readlines() f.close() f = Open(download_list_file , "w") for i in download_list_file_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove gid of download from active download list file f = Open(download_list_file_active) download_list_file_active_lines = f.readlines() f.close() f = Open(download_list_file_active , "w") for i in download_list_file_active_lines: if i.strip() != gid: f.writelines(i.strip() + "\n") f.close() #remove download_info_file download_info_file = download_info_folder + "/" + gid f = Open(download_info_file) f.close() f.remove() #remove file of download form download temp folder if file_name != '***' and status != 'complete' : file_name_path = temp_download_folder + "/" + str(file_name) os.system('rm "' + str(file_name_path) +'"') file_name_aria = file_name_path + str('.aria2') os.system('rm "' + str(file_name_aria) +'"') #remove download file if status == 'complete': if 'file_path' in add_link_dictionary: file_path = add_link_dictionary['file_path'] if os.path.isfile(file_path): os.system("rm '" + file_path + "'" ) else: notifySend(str(file_path) ,'Not Found' , 5000 , 'warning' , systemtray = self.system_tray_icon ) remove_flag = 0