Пример #1
0
 def resetPushButtonPressed(self, button):
     osCommands.removeDir(str(config_folder))
Пример #2
0
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)
Пример #3
0
                                         "download_list_file_active")

# single_downloads_list_file contains gid of non categorised downloads
single_downloads_list_file = os.path.join(category_folder, "Single Downloads")

# persepolis tmp folder in /tmp
if os_type != 'Windows':
    user_name_split = home_address.split('/')
    user_name = user_name_split[2]
    persepolis_tmp = '/tmp/persepolis_' + user_name
else:
    persepolis_tmp = os.path.join(str(home_address), 'AppData', 'Local',
                                  'persepolis_tmp')

# removing persepolis_tmp at persepolis startup
osCommands.removeDir(persepolis_tmp)

# persepolis_shutdown
persepolis_shutdown = os.path.join(persepolis_tmp, 'shutdown')
# shutil.rmtree(persepolis_shutdown, ignore_errors=True, onerror=None)

# creating folders
for folder in [
        config_folder, download_info_folder, persepolis_tmp, category_folder,
        queue_info_folder, persepolis_shutdown
]:
    osCommands.makeDirs(folder)

# creating files
for file in [
        queues_list, download_list_file, download_list_file_active,
Пример #4
0
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)
Пример #5
0
        if url:
            args.link = str(url)
            if 'referrer' in data.keys():
                args.referer = data['referrer']

            if 'filename' in data.keys() and data['filename'] != '':
                args.name = os.path.basename(str(data['filename']))

            if 'useragent' in data.keys():
                args.agent = data['useragent']

            if 'cookies' in data.keys():
                args.cookie = data['cookies']

if args.clear:
    status = osCommands.removeDir(str(config_folder))
    if status == 'ok' or status == 'no':
        print('Download list cleard!')
    else:
        print("persepolis can't clear download list")

    sys.exit(0)

if args.default:
    persepolis_setting = QSettings('persepolis_download_manager', 'persepolis')
    persepolis_setting.clear()
    persepolis_setting.sync()
    print('Persepolis restored default')
    sys.exit(0)

if args.tray:
elif os_type == 'Windows':
    config_folder = os.path.join(
        str(home_address), 'AppData', 'Local', 'persepolis_download_manager')


# persepolis tmp folder path
if os_type != 'Windows':
    user_name_split = home_address.split('/')
    user_name = user_name_split[2]
    persepolis_tmp = '/tmp/persepolis_' + user_name
else:
    persepolis_tmp = os.path.join(
        str(home_address), 'AppData', 'Local', 'persepolis_tmp')

# remove old persepolis_tmp at persepolis startup
osCommands.removeDir(persepolis_tmp)

# persepolis_shutdown
persepolis_shutdown = os.path.join(persepolis_tmp, 'shutdown')


# create folders
for folder in [config_folder, persepolis_tmp, persepolis_shutdown]:
    osCommands.makeDirs(folder)

# create an object for PersepolisDB
persepolis_db = PersepolisDB()

# create tables
persepolis_db.createTables()
Пример #7
0
 def resetPushButtonPressed(self, button):
     osCommands.removeDir(str(config_folder))
Пример #8
0
            args.link = str(url)
            if 'referrer' in data.keys():
                args.referer = data['referrer']

            if 'filename' in data.keys() and data['filename'] != '':
                args.name = os.path.basename(str(data['filename']))
                
            if 'useragent' in data.keys():
                args.agent = data['useragent']
                
            if 'cookies' in data.keys():
                args.cookie = data['cookies']

# persepolis --clear >> remove config_folder
if args.clear:
    status = osCommands.removeDir(str(config_folder))
    if status == 'ok' or status == 'no' :
        print ('Download list cleard!')
    else:
        print("persepolis can't clear download list")

    sys.exit(0)

# persepolis --default >> remove persepolis setting.
if args.default:
    persepolis_setting = QSettings('persepolis_download_manager', 'persepolis')
    persepolis_setting.clear()
    persepolis_setting.sync()
    print ('Persepolis restored default')
    sys.exit(0)
Пример #9
0
        "Library/Application Support/persepolis_download_manager")
elif os_type == 'Windows':
    config_folder = os.path.join(str(home_address), 'AppData', 'Local',
                                 'persepolis_download_manager')

# persepolis tmp folder path
if os_type != 'Windows':
    user_name_split = home_address.split('/')
    user_name = user_name_split[2]
    persepolis_tmp = '/tmp/persepolis_' + user_name
else:
    persepolis_tmp = os.path.join(str(home_address), 'AppData', 'Local',
                                  'persepolis_tmp')

# remove old persepolis_tmp at persepolis startup
osCommands.removeDir(persepolis_tmp)

# persepolis_shutdown
persepolis_shutdown = os.path.join(persepolis_tmp, 'shutdown')

# create folders
for folder in [config_folder, persepolis_tmp, persepolis_shutdown]:
    osCommands.makeDirs(folder)

# create an object for PersepolisDB
persepolis_db = PersepolisDB()

# create tables
persepolis_db.createTables()

# close connections