def resetPushButtonPressed(self, button): # create an object for PersepolisDB persepolis_db = PersepolisDB() # Reset data base persepolis_db.resetDataBase() # close connections persepolis_db.closeConnections() # Reset persepolis_setting persepolis_setting = QSettings('persepolis_download_manager', 'persepolis') persepolis_setting.clear() persepolis_setting.sync()
def resetPushButtonPressed(self, button): # create an object for PersepolisDB persepolis_db = PersepolisDB() # Reset data base persepolis_db.resetDataBase() # close connections persepolis_db.closeConnections() # Reset persepolis_setting persepolis_setting = QSettings('persepolis_download_manager', 'persepolis') persepolis_setting.clear() persepolis_setting.sync()
f.writelines('Persepolis Download Manager, '\ + current_time\ +'\n') f.close() from persepolis.scripts.data_base import PersepolisDB, PluginsDB # create an object for PersepolisDB persepolis_db = PersepolisDB() # create tables persepolis_db.createTables() # close connections persepolis_db.closeConnections() # create an object for PluginsDB plugins_db = PluginsDB() # create tables plugins_db.createTables() # delete old links plugins_db.deleteOldLinks() # close connections plugins_db.closeConnections() # import persepolis_setting
def compatibility(): if os.path.isfile(queues_list_file): persepolis_db = PersepolisDB() # add categories to category_db_table in data_base f = open(queues_list_file) queues_list = f.readlines() f.close() # remove queues_list_file remove(queues_list_file) else: return category_list = ['All Downloads', 'Single Downloads'] for line in queues_list: queue_name = line.strip() category_list.append(queue_name) for category in category_list: gid_list = [] if category == 'All Downloads': category_info_file = download_list_file else: category_info_file = os.path.join(category_folder, category) f = open(category_info_file) category_info_file_list = f.readlines() f.close() for item in category_info_file_list: gid = item.strip() gid_list.append(gid) category_dict = { 'category': category, 'start_time_enable': 'no', 'start_time': '0:0', 'end_time_enable': 'no', 'end_time': '0:0', 'reverse': 'no', 'limit_enable': 'no', 'limit_value': '0K', 'after_download': 'no', 'gid_list': str(gid_list) } # add category to data_base if category == 'All Downloads' or category == 'Single Downloads': persepolis_db.updateCategoryTable([category_dict]) else: persepolis_db.insertInCategoryTable(category_dict) # add items to download_db_table in data base f_download_list_file = open(download_list_file) download_list_file_lines = f_download_list_file.readlines() f_download_list_file.close() for line in download_list_file_lines: gid = line.strip() download_info_file = os.path.join(download_info_folder, gid) download_info_file_list = readList(download_info_file) add_link_dictionary = download_info_file_list[9] dict = { 'file_name': download_info_file_list[0], 'status': download_info_file_list[1], 'size': download_info_file_list[2], 'downloaded_size': download_info_file_list[3], 'percent': download_info_file_list[4], 'connections': download_info_file_list[5], 'rate': download_info_file_list[6], 'estimate_time_left': download_info_file_list[7], 'gid': download_info_file_list[8], 'link': add_link_dictionary['link'], 'first_try_date': download_info_file_list[10], 'last_try_date': download_info_file_list[11], 'category': download_info_file_list[12] } add_link_dictionary['gid'] = download_info_file_list[8] if 'user-agent' in add_link_dictionary.keys(): add_link_dictionary['user_agent'] = add_link_dictionary.pop( 'user-agent') if 'load-cookies' in add_link_dictionary.keys(): add_link_dictionary['load_cookies'] = add_link_dictionary.pop( 'load-cookies') add_link_dictionary['limit_value'] = 0 keys_list = [ 'gid', 'out', 'start_time', 'end_time', 'link', 'ip', 'port', 'proxy_user', 'proxy_passwd', 'download_user', 'download_passwd', 'connections', 'limit_value', 'download_path', 'referer', 'load_cookies', 'user_agent', 'header', 'after_download' ] for key in keys_list: # if a key is missed in dict, # then add this key to the dict and assign None value for the key. if key not in add_link_dictionary.keys(): add_link_dictionary[key] = None # write information in data_base persepolis_db.insertInDownloadTable([dict]) persepolis_db.insertInAddLinkTable([add_link_dictionary]) # close connections persepolis_db.closeConnections() # remove unwanted files and folders for file in [download_list_file, download_list_file_active]: remove(file) for folder in [category_folder, queue_info_folder]: removeDir(folder)
def compatibility(): if os.path.isfile(queues_list_file): persepolis_db = PersepolisDB() # add categories to category_db_table in data_base f = open(queues_list_file) queues_list = f.readlines() f.close() # remove queues_list_file remove(queues_list_file) else: return category_list = ['All Downloads', 'Single Downloads'] for line in queues_list: queue_name = line.strip() category_list.append(queue_name) for category in category_list: gid_list = [] if category == 'All Downloads': category_info_file = download_list_file else: category_info_file = os.path.join(category_folder, category) f = open(category_info_file) category_info_file_list = f.readlines() f.close() for item in category_info_file_list: gid = item.strip() gid_list.append(gid) category_dict = {'category': category, 'start_time_enable': 'no', 'start_time': '0:0', 'end_time_enable': 'no', 'end_time': '0:0', 'reverse': 'no', 'limit_enable': 'no', 'limit_value': '0K', 'after_download': 'no', 'gid_list': str(gid_list) } # add category to data_base if category == 'All Downloads' or category == 'Single Downloads': persepolis_db.updateCategoryTable([category_dict]) else: persepolis_db.insertInCategoryTable(category_dict) # add items to download_db_table in data base f_download_list_file = open(download_list_file) download_list_file_lines = f_download_list_file.readlines() f_download_list_file.close() for line in download_list_file_lines: gid = line.strip() download_info_file = os.path.join(download_info_folder, gid) download_info_file_list = readList(download_info_file) add_link_dictionary = download_info_file_list[9] dict = {'file_name': download_info_file_list[0], 'status': download_info_file_list[1], 'size': download_info_file_list[2], 'downloaded_size': download_info_file_list[3], 'percent': download_info_file_list[4], 'connections': download_info_file_list[5], 'rate': download_info_file_list[6], 'estimate_time_left': download_info_file_list[7], 'gid': download_info_file_list[8], 'link': add_link_dictionary['link'], 'first_try_date': download_info_file_list[10], 'last_try_date': download_info_file_list[11], 'category': download_info_file_list[12]} add_link_dictionary['gid'] = download_info_file_list[8] if 'user-agent' in add_link_dictionary.keys(): add_link_dictionary['user_agent'] = add_link_dictionary.pop('user-agent') if 'load-cookies' in add_link_dictionary.keys(): add_link_dictionary['load_cookies'] = add_link_dictionary.pop('load-cookies') add_link_dictionary['limit_value'] = 0 keys_list = ['gid', 'out', 'start_time', 'end_time', 'link', 'ip', 'port', 'proxy_user', 'proxy_passwd', 'download_user', 'download_passwd', 'connections', 'limit_value', 'download_path', 'referer', 'load_cookies', 'user_agent', 'header', 'after_download'] for key in keys_list: # if a key is missed in dict, # then add this key to the dict and assign None value for the key. if key not in add_link_dictionary.keys(): add_link_dictionary[key] = None # write information in data_base persepolis_db.insertInDownloadTable([dict]) persepolis_db.insertInAddLinkTable([add_link_dictionary]) # close connections persepolis_db.closeConnections() # remove unwanted files and folders for file in [download_list_file, download_list_file_active]: remove(file) for folder in [category_folder, queue_info_folder]: removeDir(folder)
f.writelines('Persepolis Download Manager, '\ + current_time\ +'\n') f.close() from persepolis.scripts.data_base import PersepolisDB, PluginsDB # create an object for PersepolisDB persepolis_db = PersepolisDB() # create tables persepolis_db.createTables() # close connections persepolis_db.closeConnections() # create an object for PluginsDB plugins_db = PluginsDB() # create tables plugins_db.createTables() # delete old links plugins_db.deleteOldLinks() # close connections plugins_db.closeConnections() # import persepolis_setting