tis-barrier icon

Barrier

Silent install package for Barrier

2.4.0.1-0

  • package: tis-barrier
  • name: Barrier
  • version: 2.4.0.1-0
  • categories: Utilities
  • maintainer: WAPT Team,Jimmy PELÉ
  • target_os: windows
  • impacted_process: barrier
  • architecture: all
  • signature_date:
  • size: 9.14 Mo

package           : tis-barrier
version           : 2.4.0.1-0
architecture      : all
section           : base
priority          : optional
name              : Barrier
categories        : Utilities
maintainer        : WAPT Team,Jimmy PELÉ
description       : Barrier is software that mimics the functionality of a KVM switch, which historically would allow you to use a single keyboard and mouse to control multiple computers
depends           : 
conflicts         : 
maturity          : PROD
locale            : 
target_os         : windows
min_wapt_version  : 
sources           : 
installed_size    : 
impacted_process  : barrier
description_fr    : Barrier est un logiciel qui imite la fonctionnalité d'un commutateur KVM, qui vous permettait historiquement d'utiliser un seul clavier et une seule souris pour contrôler plusieurs ordinateurs
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 43ae632e-f6cd-48c6-a997-8cae6e5b4f8a
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 
max_os_version    : 
icon_sha256sum    : a12955a43a4dfaec61767c13f2c73beb5ef27bd561789376e759666189d2b39c
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature         : YQFcfoTfvAQvCUKZj5wvAm7laJ8+by5P5CLjESa+UeBJeZaI7M2GsIrsITlnyTmlAq4SKLE2p9aDQkKKqkKqcgL9y8Jwp5CdcQUBgKqHCg2V2E08KziQPYJkZ8zM9aMoOOs46GKLzToyN9mh/dyJaPt1QC0qjLihIGy0lu6fMi8q8YVTF/t2+q+REG98MPXPl0o/ynsNMTk3H4R9dtoVbEFxDoj7oWfI9beBBDGA6xaCCbHXd7FHiB1Hr+mKZWEC6lGXgXAqdxYRNnmp1jB+oKp4gMTIzapFfoVVc3/EpTrDF5shEoRf+imZfVUTE8WAAyL4GGqZa7sNl1wvHNQROw==
signature_date    : 2022-03-15T23:44:24.829940
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

# -*- coding: utf-8 -*-
from setuphelpers import *
import platform
import json


uninstallkey = []

# Declaring specific app values (TO CHANGE)
bin_contains = "Barrier"
silent_args = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
app_uninstallkey = "{41036EA6-3F7A-4803-8AE0-469E5E91EFCC}_is1"


def install():
    package_version = control.get_software_version()
    bin_name = glob.glob("*%s*.exe" % bin_contains)[0]

    # Installing the package
    install_exe_if_needed(bin_name, silentflags=silent_args, key=app_uninstallkey, min_version=package_version)


def update_package():
    # Declaring local variables
    result = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    api_url = "https://api.github.com/repos/debauchee/barrier/releases/latest"
    arch_contains = ".exe"

    # Getting latest version information from official sources
    print("API used is: %s" % api_url)
    json_load = json.loads(wgets(api_url, proxies=proxies))
    for download in json_load["assets"]:
        if bin_contains in download["name"] and arch_contains in download["name"]:
            download_url = download["browser_download_url"]
            version = json_load["tag_name"].replace("v", "")
            latest_bin = download["name"]
            break

    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_version_from_binary(latest_bin, property_name="FileVersion")
        # if not version_from_file.startswith(version) and version_from_file != '':
        if Version(version_from_file) != Version(version) and version_from_file != "":
            print("Changing version to the version number of the binary")
            os.rename(latest_bin, bin_contains + version_from_file + arch_contains)
            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(version)

    # Validating update-package-sources
    return result


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 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]

a5812bc293f70a6c831cc988ec1dc9527ce50abf7f012d43a4e606b84d9d319d : setup.py
7e66b7b4d13312e607edd06f8ea38f3c9b09b3e8aea2b55250c00b25f9892885 : Barrier2.4.0.1.exe
a12955a43a4dfaec61767c13f2c73beb5ef27bd561789376e759666189d2b39c : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
cab80d0ce3856d08d6abe4224b193789a2bb70186eb3473c109937157303115b : luti.json
6739beed5025fc846db7d075a48f25f0f7ce50a4ab4209e63b0c86813c4783e0 : WAPT/control