From 7eaa6c06b24016db2db56e28bcecc21ed270e89a Mon Sep 17 00:00:00 2001 From: pcosson Date: Mon, 4 Mar 2024 15:50:31 +0100 Subject: [PATCH] Refactor setup.py: Removed unused imports, simplified code, and improved readability --- .gitignore | 33 +++++++++++++++ WAPT/control | 44 ++++++++++++++++++++ WAPT/icon.png | Bin 0 -> 1772 bytes setup.py | 104 +++++++--------------------------------------- update_package.py | 46 ++++++++++++++++++++ 5 files changed, 137 insertions(+), 90 deletions(-) create mode 100644 .gitignore create mode 100644 WAPT/control create mode 100644 WAPT/icon.png create mode 100644 update_package.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d399572 --- /dev/null +++ b/.gitignore @@ -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): diff --git a/WAPT/control b/WAPT/control new file mode 100644 index 0000000..1756da0 --- /dev/null +++ b/WAPT/control @@ -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== \ No newline at end of file diff --git a/WAPT/icon.png b/WAPT/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e89dc3b30240699e6c5dfc14cff090842a4f5e33 GIT binary patch literal 1772 zcmVaD5FV1Ef=Y#nQmQr$7e%~;7p@X-AgZED zs86LTsYuf*Ra#L*KvW7esX$01$VyV1RqP~0O&vMDtmE~1?|c3{jMux~of*%r*G>6e z&S=g#Gv9a4`CrbNQ6fSaJitESDd0h%15n&v2oMAQ4IBqv2lB;ARVJVpH~~EH5fiKx z=P?I)97+OufxiPAZyT-JFb#YW_>U414{(-`|HxM&3T*dcPDew?iwKt&3q%unCej7s zc|nxW>{avxJ@hqsxv$BKM>WK(`hh3Cm*GwEB zmeuU}SB#N(zQX9?<%tA~1?^tI@5c(n)Ar=iio*kb_TN*V@3z9B3-g?x&sln|TUp_) zsg!#GZ(q_SKW;(3JE-{iLxF~o2lybV9o_GnlP(2l5#GBdW$V3K#P~i+3gfL_`vHn)xsY=KkXQM8BFPJTWk{P3S?UXJFh553CDkPpTm zYojM@J?pkl39yEC3euJ(iYmwI%G{>TO zUbv8DDlMh?7X?_Hc4)=VwuNlTgToBC!OeuQ_h^9&Q+j#C3=eGUR`hp4S6CrRm`VvF zvzq9fwmcNDz6YP%=;8Du5xj=|tk*5zWD=xXGPFsLKLf9_GtO?|yfrJ_yPqxj{{ z0Pj8?s);<9A2{mz#55TfesuoR-m!CZ3t#_XtQzG&Xu(zJx0Evun z;v&5DzVP0Eg=F4YM9?qn`lP{7pTWL<53PYU1;)QB5qTOox|XLDku3-#ljh0B!~!g2 z1W^zPKu-(wbt(qB6#;LK zWBz*(yJAigR9>3en0mHzXnD&|}R{jqF)A^;fIU{2L O0000 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" - - diff --git a/update_package.py b/update_package.py new file mode 100644 index 0000000..67dbb79 --- /dev/null +++ b/update_package.py @@ -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