tis-irfanview

4.70-12
Affiche et manipule les images Bitmap, les images, les photos. Utile pour les diaporamas, le recadrage, le redimensionnement et la conversion d'images
6649 téléchargements
Télécharger
Voir le résultat de la construction Voir l'analyse de VirusTotal
tis-irfanview icon
  • package : tis-irfanview
  • name : IrfanView
  • version : 4.70-12
  • categories : Media
  • maintainer : WAPT Team,Tranquil IT,Pierre Cosson,Jimmy PELÉ
  • installed_size : 61358080
  • editor : Irfan Skiljan
  • licence : freeware
  • signature_date : 2024-10-16T11:07:22.000000
  • size : 24.70 Mo
  • locale : all
  • target_os : windows
  • impacted_process : i_view32,i_view64
  • architecture : x86
  • Page d'accueil : https://www.irfanview.com/
package           : tis-irfanview
version           : 4.70-12
architecture      : x86
section           : base
priority          : optional
name              : IrfanView
categories        : Media
maintainer        : WAPT Team,Tranquil IT,Pierre Cosson,Jimmy PELÉ
description       : Displays and manipulate Bitmap Pictures, images, photos. Useful for slideshow, cropping, resizing, converting pictures
depends           : 
conflicts         : 
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 1.8
sources           : http://srvdev.tranquilit.local/sources/tis-irfanview-wapt/trunk
installed_size    : 61358080
impacted_process  : i_view32,i_view64
description_fr    : Affiche et manipule les images Bitmap, les images, les photos. Utile pour les diaporamas, le recadrage, le redimensionnement et la conversion d'images
description_pl    : Wyświetla i manipuluje Bitmap Pictures, obrazy, zdjęcia. Przydatne do pokazu slajdów, przycinania, zmiany rozmiaru, konwersji obrazów
description_de    : Anzeige und Bearbeitung von Bitmap-Bildern, Bildern und Fotos. Nützlich für Diashow, Zuschneiden, Größenänderung, Konvertierung von Bildern
description_es    : Muestra y manipula imágenes de mapa de bits, imágenes, fotos. Útil para la presentación de diapositivas, el recorte, el cambio de tamaño, la conversión de imágenes
description_pt    : Exibe e manipula imagens Bitmap, imagens, fotos. Útil para apresentação de diapositivos, recorte, redimensionamento, conversão de imagens
description_it    : Visualizza e manipola immagini Bitmap, immagini e foto. Utile per presentazioni, ritaglio, ridimensionamento, conversione di immagini
description_nl    : Weergeven en manipuleren van Bitmap Foto's, afbeeldingen, foto's. Handig voor diavoorstellingen, bijsnijden, formaat wijzigen, foto's converteren
description_ru    : Отображает и манипулирует растровыми картинками, изображениями, фотографиями. Полезен для слайд-шоу, обрезки, изменения размера, конвертирования изображений
audit_schedule    : 
editor            : Irfan Skiljan
keywords          : slideshow,image,bitmap,picture,viewer,photo
licence           : freeware
homepage          : https://www.irfanview.com/
package_uuid      : 78eacada-3333-4c50-9bbb-871237c901bf
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : https://www.irfanview.com/main_history.htm
min_os_version    : 
max_os_version    : 
icon_sha256sum    : 73654dfa7bb7cdbc6292c7f1d8c012cb1f082dd7cd0dfc5f33e8f8a13f2d57a7
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2024-10-16T11:07:22.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature         : YAZ28smCARPi81Af3jcBhQSiuYBu5RzkbmU1vSDlMB2y1s423MPbrbthW+GQKBUQJkj1+Euzw2lFpF79G1gKsBdWeQSgGjqQi23/WFNQ0eTa+TAjc/mxvovaYkplWCvHi/GwJLC79D9D8TmEgORRzEZ4pdHrUMCeLyh4LSqKiRh8tGAluQO0Hx5KNWjgv77AjLXJGTcQLeA6Ej6TwqU3c7Jy62XdRHFS2dntHhEg8WZj9cQ+VR6uWEIIQ2hmN/29fKWOD67AJPhL87q/7O/kiAJHIooGWzCkwptVlNTk4kuVQ9m2rOLHbH2dYcRNjKKuSI+7cvmCk7zoRGmH2xAZuQ==
# -*- coding: utf-8 -*-
from setuphelpers import *
import platform
import bs4 as BeautifulSoup
import requests
import json


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

[Others]
INI_Folder=%APPDATA%\IrfanView

[Language]
DLL=FRENCH1.DLL
Lang=Francais


"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_lang_contains = "irfanview_lang_"
app_dir = makepath(programfiles, "IrfanView")


def install():
    # Declaring local variables
    package_version = control.version.split("-")[0]
    if control.architecture == "x64":
        ini_file = "i_view64.ini"
        app_uninstallkey = "IrfanView64"
    else:
        ini_file = "i_view32.ini"
        app_uninstallkey = "IrfanView"

    # getting binaries names
    binaries = glob.glob("*.exe")
    for binary in binaries:
        if "plugin" in binary.lower():
            plugin_binary = binary
        else:
            install_binary = binary

    # Installing the software
    print("Installing: %s" % install_binary)
    install_exe_if_needed(
        install_binary,
        #'/silent thumbs=0 /group=1 /allusers=1 /assoc=0 /assocallusers /ini="%s"' % app_dir,
        "/silent thumbs=0 /group=1 /allusers=1 /assoc=0 /assocallusers",
        key=app_uninstallkey,
        min_version=package_version,
    )

    # Adding QuietUninstallString for app
    quiet_uninstall_string = installed_softwares(uninstallkey=app_uninstallkey)[0]["uninstall_string"] + " /silent"
    register_uninstall(app_uninstallkey, quiet_uninstall_string=quiet_uninstall_string, win64app=iswin64())

    # Installing plugins
    print("Installing plugins: %s" % plugin_binary)
    install_exe_if_needed(plugin_binary, "/silent")

    # Adding LPs
    if control.locale == "fr":
        bin_lang = glob.glob("*%s*.zip" % bin_lang_contains)[0]
        print("Installing %s" % bin_lang)
        unzip(bin_lang, makepath(app_dir, "Languages"))

    # Writting global conf file
    app_conf_path = makepath(app_dir, ini_file)
    if isfile(app_conf_path):
        remove_file(app_conf_path)
    inifile_writestring(app_conf_path, "Others", "INI_Folder", r"%APPDATA%\IrfanView")


def session_setup():
    if is64:
        ini_file = "i_view64.ini"
    else:
        ini_file = "i_view32.ini"
    app_name = "IrfanView"
    user_app_conf_dir = makepath(user_appdata, "IrfanView")
    user_app_conf_path = makepath(user_app_conf_dir, ini_file)
    registry_readstring(HKEY_CURRENT_USER, r"SOFTWARE\WAPT\%s" % app_name, "ApplyLocaleOnce")

    if get_language() == "fr":
        if not registry_readstring(HKEY_CURRENT_USER, r"SOFTWARE\WAPT\%s" % app_name, "ApplyLocaleOnce") or force:
            if not isdir(user_app_conf_dir):
                mkdirs(user_app_conf_dir)
            if isfile(user_app_conf_path):
                remove_file(user_app_conf_path)
            inifile_writestring(user_app_conf_path, "Language", "DLL", "FRENCH1.DLL")
            inifile_writestring(user_app_conf_path, "Language", "Lang", "Francais")
            registry_setstring(HKEY_CURRENT_USER, r"SOFTWARE\WAPT\%s" % app_name, "ApplyLocaleOnce", "Done")


def update_package():
    # Declaring local variables
    result = False
    language = control.locale
    app_name = control.name
    arch = control.architecture
    if arch == "x64":
        arch = "_x64"
        arch_dl = "64"

    else:
        arch = ""
        arch_dl = "32"
    url = "https://www.fosshub.com/IrfanView.html"

    # Getting proxy informations from WAPT settings
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    version = bs_find(
        url,
        "dd",
        "itemprop",
        "softwareVersion",
        proxies=proxies,
    ).text
    dotless_version = version.replace(".", "")

    # FOSSHUB function
    bin_url_dl = get_download_url_from_fosshub(url, file_type="%s-bit Windows Installer" % arch_dl, proxies=proxies)
    plugin_url_dl = get_download_url_from_fosshub(url, file_type="All Plugins - %s-bit Windows Installer" % arch_dl, proxies=proxies)

    latest_bin = bin_url_dl.split("/")[-1]
    latest_plugin = plugin_url_dl.split("/")[-1]
    print("Latest %s version is: %s" % (app_name, version))
    print("Download url is: %s" % bin_url_dl)

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

        # Downloading plugins
        if not isfile(latest_plugin):
            print("Downloading: %s" % latest_plugin)
            wget(plugin_url_dl, latest_plugin, proxies=proxies)

        # Checking version from file
        version_from_file = get_version_from_binary(latest_bin)
        if not version_from_file.startswith(version) and version_from_file != "":
            print("Changing version to the version number of the binary")
            os.rename(latest_bin, "iview" + arch + "-" + version_from_file + "_setup.exe")
            os.rename(latest_plugin, "iview" + arch + "-" + version_from_file + "_all_plugins_setup.exe")
            version = version_from_file
            dotless_version = version_from_file.replace(".", "")
        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(dotless_version)

    # Downloading language
    if language == "fr":
        lang_installer_url = "https://www.irfanview.net/lang/irfanview_lang_french.zip"
        lang_installer = lang_installer_url.rsplit("/", 1)[1]
        wget(lang_installer_url, lang_installer, proxies=proxies)

    # Validating or not update-package-sources
    return result


def get_download_url_from_fosshub(url, file_type="64-bit Windows Installer", proxies=None):
    url_api_fosshub = "https://university.fosshub.com/projects.json"

    for script in bs_find_all(
        url, "script", proxies=proxies, headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0"}
    ):
        if (len(script.contents) >= 1) and ("var settings" in script.contents[0]):
            var_settings = script.contents[0].replace("\n  var settings =", "").replace("\n", "")
            break

    for readapifosshub in json.loads(wgets(url_api_fosshub, proxies=proxies))["projects"]:
        if readapifosshub["url"].endswith(url.split("//")[-1]):
            for filename in readapifosshub["files"]:
                if filename["type"] == file_type:
                    file_name = filename["name"]

    settings = json.loads(var_settings)

    apiUrl = "https://api." + settings["domain"]
    downloadUrl = apiUrl + "/download/"

    def forming_fosshub_url(a, b, c, d, e):
        params = {"projectId": a, "releaseId": b, "projectUri": c, "fileName": d, "source": e}
        r = requests.post(downloadUrl, data=params)
        return r

    pool = settings["pool"]
    f = pool["f"]

    for c in f:
        r = forming_fosshub_url(pool["p"], c["r"], pool["u"], file_name, pool["c"])

    r = forming_fosshub_url(pool["p"], c["r"], pool["u"], file_name, pool["c"])
    rj = r.json()
    return rj["data"]["url"]


def get_version_from_binary(filename):
    if filename.endswith(".msi"):
        return get_msi_properties(filename)["ProductVersion"]
    else:
        return get_file_properties(filename)["ProductVersion"]


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 = conf_file_readstring(waptconsole_ini_path, "global", "http_proxy")
        if proxy_wapt:
            proxies = {"http": proxy_wapt, "https": proxy_wapt}
    return proxies


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

    """
    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, list_extensions=["exe", "msi", "deb", "rpm", "dmg", "pkg"], filename_contains=None):
    r"""Remove files based on the version contained in his filename, failing over on file version on compatible OSes

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

    Returns:
        list: list of deleted files

    .. versionadded:: 2.0

    .. versionchanged:: 2.2
        Now returns removed files, now checking .exe and .msi file versions

    """
    files = []
    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:
                if platform.system() == "Windows":
                    if file_ext == ".exe" or file_ext == ".msi":
                        if Version(version) == Version(get_version_from_binary(bin_in_dir, "FileVersion")) or Version(version) == Version(
                            get_version_from_binary(bin_in_dir, "ProductVersion")
                        ):
                            print("%s file or product version is correct (%s)" % (bin_in_dir, version))
                            continue
                remove_file(bin_in_dir)
                files.append(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)
                        files.append(bin_in_dir)
    return [fn for fn in files]
38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
e6ad6ba82b6d9ae02b9feb5c4c777dd33ddc1bfc73b089a23d9443f356bb8e44 : WAPT/control
73654dfa7bb7cdbc6292c7f1d8c012cb1f082dd7cd0dfc5f33e8f8a13f2d57a7 : WAPT/icon.png
fbaa225688d45217a809ac2695ebea2024214b3443bc4d2af90aa1a06c4cf1c2 : iview470_plugins_setup.exe
3c7d575feb92719934f6c8d4ca31d0dc235a91705ec24d1f8220204da8e55729 : iview470_setup.exe
cbbb48ce006d845ded4931371ee18b9275a4a5b80b715d509a020f0a7f85f7f2 : luti.json
8019f7cc629ade92903491e480431c61250cc1981826b45e5b752297cd872e92 : setup.py