tis-7zip

21.06-34
7-Zip is a free and open-source file archiver with a high compression ratio
95100 downloads
Download
View on luti logo
tis-7zip icon

  Description 

  • package : tis-7zip
  • version : 21.06-34
  • architecture : x86
  • categories : Utilities
  • maintainer : WAPT Team,Tranquil IT,Jimmy PELÉ
  • description : 7-Zip is a free and open-source file archiver with a high compression ratio
  • locale : all
  • target_os : windows
  • min_wapt_version : 1.7
  • sources : https://www.7-zip.org/download.html
  • installed_size :
  • impacted_process : 7zFM,7z,7zG
  • description_fr : 7-Zip est un logiciel gratuit et open source d'archivage de fichiers avec un taux de compression élevé
  • description_pl :
  • description_de : 7-Zip ist ein Datenkompressionsprogramm mit einer hohen Kompressionsrate
  • description_es : 7-Zip es un archivador de ficheros con una alta relación de compresión
  • description_pt : O 7-Zip é um compactador de arquivos com alta taxa de compressão
  • description_it :
  • description_nl :
  • description_ru : 7-Zip свободный файловый архиватор с высокой степенью сжатия данных
  • editor : Igor Pavlov
  • licence : LGPL
  • signature_date : 2021-12-02T17:23:10.040355
  • Homepage : https://www.7-zip.org/

  Setup.py 

# -*- coding: utf-8 -*-
from setuphelpers import *
import platform
import bs4 as BeautifulSoup

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_contains = '7z'
ext_file_association = ['.001','.7z','.arj','.bz2','.bzip2','.cab','.cpio','.deb','.dmg','.esd','.fat','.gz','.gzip','.hfs','.lha','.lzh','.lzma','.ntfs','.rar','.rpm','.squashfs','.swm','.tar','.taz','.tbz','.tbz2','.tgz','.tpz','.txz','.vhd','.wim','.xar','.xz','.z','.zip','.zipe'] # ,'.iso'


def install():
    # Initializing variables
    package_version = control.version.split('-',1)[0]
    bin_name = glob.glob('*%s*.msi' % bin_contains)[0]

    # Uninstalling other versions of the software
    for uninstall in installed_softwares(name='7-Zip'):
        if Version(uninstall['version'],2) < Version(package_version,2) or force:
            print("Removing: %s (%s)" % (uninstall['name'], uninstall['version']))
            killalltasks(control.impacted_process.split(','))
            try:
                run(uninstall_cmd(uninstall['key']))
                wait_uninstallkey_absent(uninstall['key'])
            except:
                unregister_uninstall(uninstall['key'], win64app=iswin64())

    # Installing the software
    print("Installing: %s" % bin_name)
    install_msi_if_needed(bin_name,
        min_version=package_version)

    # File association for 7-Zip
    for ext in (ext_file_association):
        register_ext('7-zip',ext,'"%s" "%%1"' % (makepath(programfiles, '7-zip', '7zFM.exe')), icon="%s,1" % (makepath(programfiles, '7-zip', '7z.dll')))


def update_package():
    # Declaring local variables
    result = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    url = 'https://www.7-zip.org/download.html'
    if control.architecture == 'x64':
        sub_bin_name = '7z%s-x64.msi'
    else:
        sub_bin_name = '7z%s.msi'

    # Getting latest version from official website
    print('URL used is: ' + url)
    version = bs_find_all(url, 'b', proxies=proxies)[1].text.split('Zip ')[-1].split(' (')[0]
    splitted_version = version.replace('.', '')
    latest_bin = sub_bin_name % splitted_version
    download_url = 'https://www.7-zip.org/a/%s' % latest_bin

    print("Latest %s version is: %s" % (app_name, version))
    print("Download URL is: %s" % download_url)

    # Downloading latest binaries
    if not isfile(latest_bin):
        print('Downloading: %s' % latest_bin)
        wget(download_url,latest_bin, proxies=proxies)

        # Checking version from file
        version_from_file = get_msi_properties(latest_bin)['ProductName'].split(' ')[1]
        if Version(version) != Version(version_from_file) and version_from_file != '':
            print("Changing version to the version number of the binary (from: %s to: %s)" % (version, version_from_file))
            os.rename(latest_bin, sub_bin_name % version_from_file)
            version = version_from_file
        else:
            print("Binary file version corresponds to online version")

    # Changing version of the package
    if Version(version) > Version(control.get_software_version()):
        print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
        result = True
    else:
        print("Software version up-to-date (%s)" % Version(version))
    control.version = '%s-%s' % (Version(version), control.version.split('-', 1)[-1])

    #control.set_software_version(version)
    control.save_control_to_wapt()

    # Deleting outdated binaries
    remove_outdated_binaries(splitted_version)

    # Validating update-package-sources
    return result




def wait_uninstallkey_absent(key=None, max_loop=120):
    import time
    loop=0
    while uninstall_key_exists(key):
        loop = loop + 1
        if loop > max_loop:
            return "timout"
        time.sleep(1)


def get_proxies():
    r"""Return system proxy with the urllib python library

    >>> get_proxies()
    {'http': 'http://srvproxy.ad.domain.lan:8080',
    'https': 'http://srvproxy.ad.domain.lan:8080'}

    """
    if platform.python_version_tuple()[0] == '3':
        from urllib.request import getproxies
    else:
        from urllib import getproxies
    return getproxies()


def get_proxies_from_wapt_console():
    r"""Return proxy information from the current user WAPT console

    >>> get_proxies_from_wapt_console()
    {'http': 'http://srvproxy.ad.domain.lan:8080',
    'https': 'http://srvproxy.ad.domain.lan:8080'}

    """
    proxies = {}
    if platform.system() == 'Windows':
        waptconsole_ini_path = makepath(user_local_appdata(), 'waptconsole', 'waptconsole.ini')
    else:
        waptconsole_ini_path = makepath(user_home_directory(), '.config', 'waptconsole', 'waptconsole.ini')
    if isfile(waptconsole_ini_path):
        proxy_wapt = inifile_readstring(waptconsole_ini_path, 'global', 'http_proxy')
        if proxy_wapt:
            proxies = {'http': proxy_wapt, 'https': proxy_wapt}
    return proxies


def bs_find(url, element, attribute=None, value=None, user_agent=None, proxies=None, features='html.parser', **kwargs):
    r""""Parse html web page with BeautifulSoup and get the first result

    Args:
        url (str): url of the web page to parse
        element (str): searched element
        attribute (str): selected attribute of the element
        value (str): value of the selected attribute
        user_agent (str): specify a user-agent if needed
        proxies (dict): specify your proxy if needed
        **kwargs (str): joker for requests parameters
        features (str): bs feature to use


    >>> bs_find('https://www.w3.org/', 'a', 'title', 'Open Web Platform testing')['href']
    'https://web-platform-tests.org/'

    >>> bs_find('https://www.w3.org/', 'span', 'class', 'alt-logo').string
    'W3C'

    .. versionadded:: 2.0

    """
    import requests
    if user_agent:
        page = requests.get(url, proxies=proxies, headers={'User-Agent':'%s' % user_agent}, **kwargs).text
    else:
        page = requests.get(url, proxies=proxies, **kwargs).text
    soup = BeautifulSoup.BeautifulSoup(page, features=features)
    if value:
        return soup.find(element, {attribute: value})
    else:
        return soup.find(element)


def bs_find_all(url, element, attribute=None, value=None, user_agent=None, proxies=None, features='html.parser', **kwargs):
    r""""Parse html web page with BeautifulSoup and get a list of the result

    Args:
        url (str): url of the web page to parse
        element (str): searched element
        attribute (str): selected attribute of the element
        value (str): value of the selected attribute
        user_agent (str): specify a user-agent if needed
        proxies (dict): specify your proxy if needed
        **kwargs (str): joker for requests parameters
        features (str): bs feature to use


    >>> bs_find_all('https://www.w3.org/', 'a', 'title', 'Open Web Platform testing')[0]['href']
    'https://web-platform-tests.org/'

    >>> bs_find_all('https://www.w3.org/', 'span', 'class', 'alt-logo')[0].string
    'W3C'

    .. versionadded:: 2.0

    """
    import requests
    if user_agent:
        page = requests.get(url, proxies=proxies, headers={'User-Agent':'%s' % user_agent}, **kwargs).text
    else:
        page = requests.get(url, proxies=proxies, **kwargs).text
    soup = BeautifulSoup.BeautifulSoup(page, features=features)
    if value:
        return soup.find_all(element, {attribute:value})
    else:
        return soup.find_all(element)


def get_version_from_binary(filename, property_name='ProductVersion'):
    r""" Get installer version from file informations, for now, only exe and msi files are compatibles

    Args:
        filename (str): path to the file
        property_name (str): selected property

    Returns:
        str: version number

     """
    if filename.endswith('.msi'):
        return get_msi_properties(filename)[property_name]
    else:
        return get_file_properties(filename)[property_name]


def remove_outdated_binaries(version, filename_contains=None, list_extensions=['exe','msi','deb','rpm','dmg','pkg']):
    r"""Remove files based on the version contained in his filename

    Args:
        version (str): version number of keeped files
        filename_contains (str or list of str): Part of the filename that must be contained (useful for distinguishing architecture and os)
        list_extensions (str or list of str): file extensions of verified files

    Returns:
        None

    .. versionadded:: 2.0

    """
    if type(list_extensions) != list:
        list_extensions = [list_extensions]
    if filename_contains:
        if type(filename_contains) != list:
            filename_contains = [filename_contains]
    list_extensions = ['.' + ext for ext in list_extensions if ext[0] != '.']
    for file_ext in list_extensions:
        for bin_in_dir in glob.glob('*%s' % file_ext):
            if not version in bin_in_dir:
                remove_file(bin_in_dir)
            if filename_contains:
                for filename_contain in filename_contains:
                    if not filename_contain in bin_in_dir:
                        remove_file(bin_in_dir)


										

  Changelog 



Changelog software url : https://www.7-zip.org/history.txt



No changelog.txt.
									
  manifest.sha256