Refactor setup.py: Removed unused imports, simplified code, and improved readability
This commit is contained in:
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# Do not commit binaries:
|
||||
*.exe
|
||||
*.msi
|
||||
*.msu
|
||||
*.msp
|
||||
*.deb
|
||||
*.rpm
|
||||
*.dmg
|
||||
*.pkg
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.msix
|
||||
*.msixbundle
|
||||
*.vsix
|
||||
*.iso
|
||||
*.jar
|
||||
*.cab
|
||||
*.zip
|
||||
*.7z
|
||||
*.tar*
|
||||
*.part
|
||||
|
||||
# Do not commit autogenerated WAPT files:
|
||||
**/WAPT/*.crt
|
||||
**/WAPT/*.sha256
|
||||
**/WAPT/*.sha1
|
||||
**/WAPT/*.psproj
|
||||
**/.vscode/
|
||||
*.pyc
|
||||
*.wapt
|
||||
.env
|
||||
|
||||
# Specific to this package (use ! as prefix to allow commit):
|
||||
44
WAPT/control
Normal file
44
WAPT/control
Normal file
@@ -0,0 +1,44 @@
|
||||
package : comi-rustdesk
|
||||
version : 1.2.4-1
|
||||
architecture : all
|
||||
section : base
|
||||
priority : optional
|
||||
name : rustdesk
|
||||
categories : System and network
|
||||
maintainer : Comitari,Pierre COSSON
|
||||
description : RustDesk is an open-source remote desktop application that allows yout to control your computer from another device over the internet
|
||||
depends :
|
||||
conflicts :
|
||||
maturity : PROD
|
||||
locale : all
|
||||
target_os : windows
|
||||
min_wapt_version : 2.3
|
||||
sources : https://help.comitari.fr
|
||||
installed_size : 66634348
|
||||
impacted_process : rustdesk
|
||||
description_fr : RustDesk est une application de bureau à distance open-source qui vous permet de contrôler votre ordinateur à partir d'un autre appareil via Internet
|
||||
description_pl : RustDesk to aplikacja zdalnego pulpitu o otwartym kodzie źródłowym, która umożliwia sterowanie komputerem z innego urządzenia przez Internet
|
||||
description_de : RustDesk ist eine Open-Source-Remote-Desktop-Anwendung, mit der Sie Ihren Computer von einem anderen Gerät aus über das Internet steuern können
|
||||
description_es : RustDesk es una aplicación de escritorio remoto de código abierto que le permite controlar su ordenador desde otro dispositivo a través de Internet
|
||||
description_pt : O RustDesk é uma aplicação de ambiente de trabalho remoto de código aberto que lhe permite controlar o seu computador a partir de outro dispositivo através da Internet
|
||||
description_it : RustDesk è un'applicazione open-source per il desktop remoto che consente di controllare il computer da un altro dispositivo tramite Internet
|
||||
description_nl : RustDesk is een open-source remote desktop applicatie waarmee je je computer vanaf een ander apparaat via het internet kunt bedienen
|
||||
description_ru : RustDesk - это приложение для удаленного рабочего стола с открытым исходным кодом, которое позволяет управлять компьютером с другого устройства через интернет
|
||||
audit_schedule :
|
||||
editor : RustDesk
|
||||
keywords : teamviewer,anydesk,remote,control,desktop
|
||||
licence : opensource_free,cpe:/a:gnu:gpl_v3,wapt_private
|
||||
homepage : https://rustdesk.com/
|
||||
package_uuid : 555e3ad0-33be-4c4a-bf8f-f1cd63443512
|
||||
valid_from :
|
||||
valid_until :
|
||||
forced_install_on :
|
||||
changelog :
|
||||
min_os_version :
|
||||
max_os_version :
|
||||
icon_sha256sum : c078a71b256b235e8228f17e202abf38e2c6f24e3f85eb38e1663ad564d2843b
|
||||
signer : pcosson_key
|
||||
signer_fingerprint: a25582410cf03bad179a60c189f459a0b03821c92c0cedf209e82448a66a9b4e
|
||||
signature_date : 2024-03-04T14:50:02.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 : dDd9BKWXkMrKcvDnEWWhbHlonDmr2YH5/rRevCpPG+x2Wa3TARhBHZeSL8flig3w1uUJYSdbNIywI6UTWS5KHo5bAgS89KJQQURfV5oKS9VWKUw3B498UiRhLQH4XrD7EvZHCcJUKgH7WwymTP9nyEbwczx5mOpI10MOV+tyZmZWJG1v2mEnb6uIYiRR9kDrxFI0dhv6aTSovx7sQDeMRK4FAeYWu1A80ccKyERrt4y3FfY9RuNH32FCiQGVnx9/CBoN3dcA8U0auvDaZOQSMZsM8WRWewLHs8BlxfL5pA+5Fq5TAYtDxQAnMJvpDqnZYqOpHPwhvnQ5RoBezUx1QQ==
|
||||
BIN
WAPT/icon.png
Normal file
BIN
WAPT/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
104
setup.py
104
setup.py
@@ -1,108 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from setuphelpers import *
|
||||
import shutil
|
||||
import re
|
||||
import subprocess
|
||||
import string
|
||||
from waptcrypto import *
|
||||
import random
|
||||
import platform
|
||||
import json
|
||||
|
||||
|
||||
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
|
||||
#uninstallstring='"C:\Program Files\RustDesk\RustDesk.exe" --uninstall'
|
||||
|
||||
def update_package():
|
||||
# Declaring local variables
|
||||
package_updated = False
|
||||
proxies = get_proxies()
|
||||
if not proxies:
|
||||
proxies = get_proxies_from_wapt_console()
|
||||
api_url = "https://api.github.com/repos/rustdesk/rustdesk/releases/latest"
|
||||
download_dict = {
|
||||
"windows-all": "x86_64.exe",
|
||||
"windows-x64": "x86_64.exe",
|
||||
"windows-x86": "x86_64.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 to_download in json_load["assets"]:
|
||||
if download_dict[f"{control.target_os}-{control.architecture}"] in to_download["name"]:
|
||||
download_url = to_download["browser_download_url"]
|
||||
newversion = json_load["tag_name"]
|
||||
print (newversion)
|
||||
latest_bin = to_download["name"]
|
||||
break
|
||||
|
||||
# Downloading latest binaries
|
||||
print("Latest %s version is: %s" % (control.name, newversion))
|
||||
print("Download URL is: %s" % download_url)
|
||||
if not isfile(latest_bin):
|
||||
print("Downloading: %s" % latest_bin)
|
||||
wget(download_url, latest_bin, proxies=proxies)
|
||||
else:
|
||||
print("Binary is present: %s" % latest_bin)
|
||||
|
||||
# Checking version from file
|
||||
version_from_file = get_version_from_binary(latest_bin)
|
||||
print (version_from_file)
|
||||
if Version(version_from_file) != Version(newversion) and version_from_file != "":
|
||||
print("Changing version to the version number of the binary")
|
||||
os.rename(latest_bin, latest_bin.replace(newversion, version_from_file))
|
||||
else:
|
||||
print("Binary file version corresponds to online version")
|
||||
|
||||
# Changing version of the package
|
||||
if Version(newversion) > Version(control.get_software_version()):
|
||||
print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(newversion)))
|
||||
package_updated = True
|
||||
else:
|
||||
print("Software version up-to-date (%s)" % Version(newversion))
|
||||
control.set_software_version(newversion)
|
||||
control.save_control_to_wapt()
|
||||
|
||||
# Deleting outdated binaries
|
||||
remove_outdated_binaries(newversion)
|
||||
|
||||
# Validating update-package-sources
|
||||
return package_updated
|
||||
|
||||
def install():
|
||||
bin_name = glob.glob("rustdesk-*.exe")[0]
|
||||
# préraration du dossier de config
|
||||
destdir = makepath('C:', 'Windows', 'ServiceProfiles', 'LocalService', 'AppData', 'Roaming', 'RustDesk', 'config')
|
||||
|
||||
if isdir(destdir):
|
||||
print("Config folder exist")
|
||||
|
||||
else:
|
||||
print("Create Config folder")
|
||||
mkdirs(destdir)
|
||||
|
||||
shutil.copy ("RustDesk2.toml", "C:/Windows/ServiceProfiles/LocalService/AppData/Roaming/RustDesk/config")
|
||||
|
||||
# Installing the software
|
||||
print("Installing: ", bin_name)
|
||||
install_exe_if_needed(bin_name,
|
||||
silentflags='--silent-install',
|
||||
install_exe_if_needed(
|
||||
"rustdesk.exe",
|
||||
silentflags="--silent-install",
|
||||
key="RustDesk",
|
||||
min_version=control.get_software_version(),
|
||||
)
|
||||
# Create the uninstall key
|
||||
uninstallkey.clear()
|
||||
|
||||
|
||||
def uninstall():
|
||||
run_notfatal(r'"C:\Program Files\RustDesk\RustDesk.exe" --uninstall')
|
||||
remove_tree(r'C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk', ignore_errors=True,)
|
||||
remove_tree(
|
||||
r"C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\RustDesk",
|
||||
ignore_errors=True,
|
||||
)
|
||||
|
||||
|
||||
def audit():
|
||||
def get_rustdesk_id():
|
||||
# Run the command and capture its output
|
||||
result = subprocess.run(['C:\\Program Files\\RustDesk\\rustdesk.exe', '--get-id'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
result = subprocess.run(["C:\\Program Files\\RustDesk\\rustdesk.exe", "--get-id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
# Check if the command was successful
|
||||
if result.returncode == 0:
|
||||
# Store the output in a variable
|
||||
@@ -114,7 +39,6 @@ def audit():
|
||||
# If there was an error, print the error message
|
||||
print("Error:", result.stderr)
|
||||
return final_id
|
||||
|
||||
WAPT.write_audit_data("RustDesk", "id", get_rustdesk_id(), max_count=3)
|
||||
return "OK"
|
||||
|
||||
|
||||
|
||||
46
update_package.py
Normal file
46
update_package.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from setuphelpers import *
|
||||
from setupdevhelpers import *
|
||||
|
||||
|
||||
def update_package():
|
||||
# Declaring local variables
|
||||
package_updated = False
|
||||
proxies = get_proxies()
|
||||
if not proxies:
|
||||
proxies = get_proxies_from_wapt_console()
|
||||
download_url = control.sources
|
||||
latest_bin = "rustdesk.exe"
|
||||
|
||||
# Deleting binaries
|
||||
remove_outdated_binaries("*")
|
||||
|
||||
# Downloading latest binaries
|
||||
print("Download URL is: %s" % download_url)
|
||||
if not isfile(latest_bin):
|
||||
print("Downloading: %s" % latest_bin)
|
||||
wget(download_url, latest_bin, proxies=proxies)
|
||||
else:
|
||||
print("Binary is present: %s" % latest_bin)
|
||||
|
||||
# Checking version from file
|
||||
if get_os_name() == "Windows" and "windows" in control.target_os.lower():
|
||||
file_version = get_file_properties(latest_bin)["FileVersion"]
|
||||
if len(file_version.split(".")) > 3:
|
||||
version = ".".join(file_version.split(".")[:3])
|
||||
else:
|
||||
version = file_version
|
||||
else:
|
||||
version = control.get_software_version()
|
||||
|
||||
# Changing version of the package
|
||||
if Version(version, 4) > Version(control.get_software_version(), 4):
|
||||
print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
|
||||
package_updated = True
|
||||
else:
|
||||
print("Software version up-to-date (%s)" % Version(version))
|
||||
control.set_software_version(version)
|
||||
control.save_control_to_wapt()
|
||||
|
||||
# Validating update-package-sources
|
||||
return package_updated
|
||||
Reference in New Issue
Block a user