tis-template-package-sources
0-6
Une fois importé, lancez la fonction update_package() pour générer automatiquement votre paquetage de sources
874 téléchargements
Voir le résultat de la construction Voir l'analyse de VirusTotal
Description
- package : tis-template-package-sources
- name : Package Sources Template
- version : 0-6
- categories : Dependency
- maintainer : WAPT Team,Tranquil IT,Clément BAZIRET
- installed_size :
- editor :
- licence : proprietary_free,wapt_public
- signature_date : 2024-01-05T12:00:06.724410
- size : 19.03 Ko
- locale :
- target_os : all
- impacted_process :
- architecture : all
- Page d'accueil : https://www.wapt.fr/en/doc
control
package : tis-template-package-sources
version : 0-6
architecture : all
section : base
priority : optional
name : Package Sources Template
categories : Dependency
maintainer : WAPT Team,Tranquil IT,Clément BAZIRET
description : Once imported, run the update_package() function to automatically generate your sources package
depends :
conflicts :
maturity : PROD
locale :
target_os : all
min_wapt_version : 2.3
sources :
installed_size :
impacted_process :
description_fr : Une fois importé, lancez la fonction update_package() pour générer automatiquement votre paquetage de sources
description_pl : Po zaimportowaniu uruchom funkcję update_package(), aby automatycznie wygenerować pakiet źródeł
description_de : Führen Sie nach dem Import die Funktion update_package() aus, um Ihr Quellpaket automatisch zu erstellen
description_es : Una vez importado, ejecute la función update_package() para generar automáticamente su paquete de fuentes
description_pt : Uma vez importado, execute a função update_package() para gerar automaticamente o seu pacote de fontes
description_it : Una volta importato, eseguire la funzione update_package() per generare automaticamente il pacchetto di sorgenti
description_nl : Voer na het importeren de functie update_package() uit om automatisch uw broncodepakket te genereren
description_ru : После импорта выполните функцию update_package() для автоматической генерации пакета исходных текстов
audit_schedule :
editor :
keywords : template,package,packages,source,sources
licence : proprietary_free,wapt_public
homepage : https://www.wapt.fr/en/doc
package_uuid : f010fcfc-2a08-4fdf-86b0-88a0c169ac8d
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version :
max_os_version :
icon_sha256sum : d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834
signer : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature : GExPpGXdVU8OweJyBfzpjc1B4dn1fQ3BRtGaVJcuEB5hC2irUGiXhIZuLFpHmWx7gZ4ukL/eeK3clpRUjKY9VzXihvowAhHQCebBmJlHli2PkKEwgJMWgbx3h6uVN+NbjvaZA2uBgoj6Zyr3NouwcTnd9RCSW+OogkHCl95znHONLnSroEG+MoQ54mnZe4+x2SYJJ9hz+K76BWdyugUtgqFntiBJH4B/00szHjKi1nEuDhIMRR4g3Nu2u3+3F+v9tXEzykLQI9uljmq3CcrAIzdMmRHeA4jdK0RfEK++CwVEAS7bWA9iF+n4AJo8BW5S54jkiWRxpzG0LC06vz3mvQ==
signature_date : 2024-01-05T12:00:06.724410
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
Setup.py
# -*- coding: utf-8 -*-
from setuphelpers import *
from typing import Union
import shutil
import json
# Define depends_package if you want to remove source when package is installed
depends_package = ""
sources_dir_name = "sources"
def install():
sources_location = makepath(WAPT.wapt_base_dir, "public", "sources")
sources_list = list(set([os.path.basename(s) for s in glob.glob(makepath(sources_dir_name, "*"))]))
sources_dict = {"sources_list": sources_list}
mkdirs(get_private_persistent_package_dir())
json_write_file(get_private_persistent_package_file("sources.json"), sources_dict)
if not sources_list:
error("You have not provided any sources to copy. Please run the update_package() first or place them manually in the sources directory.")
print(f"Sources will be placed in: {sources_location}")
mkdirs(sources_location)
for source in sources_list:
source_src = makepath(sources_dir_name, source)
source_dst = makepath(sources_location, source)
if isdir(source_src):
print(f"Copying: {source_src} directory to: {source_dst}")
if running_as_system():
if isdir(source_dst):
remove_tree(source_dst)
shutil.move(source_src, source_dst)
else:
copytree2(source_src, source_dst)
if isfile(source_src):
print(f"Copying: {source_src} file to: {source_dst}")
if running_as_system():
if isfile(source_dst):
remove_file(source_dst)
shutil.move(source_src, source_dst)
else:
filecopyto(source_src, source_dst)
def audit():
audit_status = "OK"
if depends_package:
sources_dict = json_load_file(get_private_persistent_package_file("sources.json"))
if sources_dict.get("deleted_by", ""):
print(f'Sources have already been uninstalled since {sources_dict["deleted_by"]} was successfully installed.')
else:
depends_package_is_installed = WAPT.is_installed(depends_package)
if depends_package_is_installed:
# WAPT.is_installed("tis-notepadplusplus").asrequirement()
print(f"Removing sources since {depends_package_is_installed.package} is installed.")
uninstall()
sources_dict.update({"deleted_by": depends_package_is_installed.asrequirement()})
json_write_file(get_private_persistent_package_file("sources.json"), sources_dict)
else:
print(
"You did not define depends_package. sources will remain until the package is removed (note that if you remove this package depends_package may also be removed)."
)
return audit_status
def uninstall():
sources_location = makepath(WAPT.wapt_base_dir, "public", "sources")
sources_list = json_load_file(get_private_persistent_package_file("sources.json"))["sources_list"]
for source in sources_list:
source_dst = makepath(sources_location, source)
if isdir(source_dst):
print(f"Removing: {source_dst} directory.")
remove_tree(source_dst)
if isfile(source_dst):
print(f"Removing: {source_dst} file.")
remove_file(source_dst)
if dir_is_empty(sources_location):
print(f"Removing: {sources_location} sources directory since it is empty.")
remove_tree(sources_location)
def get_private_persistent_package_dir():
if control.package_uuid:
if WAPT.is_installed(control.package) is not None and control.package_uuid == WAPT.is_installed(control.package)["package_uuid"]:
return makepath(WAPT.persistent_root_dir, control.package_uuid)
return makepath(os.getcwd(), "WAPT", "persistent")
def get_private_persistent_package_file(file_name):
file_name = os.path.basename(file_name)
return makepath(get_private_persistent_package_dir(), file_name)
def json_load_file(json_file: str, encoding: str = "utf-8") -> Union[list, dict]:
"""Load content from a JSON file.
Args:
json_file: Path to the JSON file.
encoding: File encoding.
Returns:
Loaded JSON content as a dictionary or a list.
"""
with open(json_file, encoding=encoding) as read_file:
return json.load(read_file)
def json_write_file(json_file: str, data: Union[list, dict], indent: int = 4, sort_keys: bool = False, encoding: str = "utf-8", newline: str = "\n"):
"""Write dictionary or list to a JSON file.
Args:
json_file: Path to the JSON file.
data: Dictionary or list content to be written.
indent: Tabulation size for indentation.
sort_keys: Sort the keys alphabetically or not.
encoding: File encoding.
newline: Newline character(s) to use, default is Line Feed (LF).
"""
with open(json_file, "w", encoding=encoding, newline=newline) as write_file:
json.dump(data, write_file, sort_keys=sort_keys, indent=indent)
update_package.py
# -*- coding: utf-8 -*-
from setuphelpers import *
import os
import sys
if "__file__" in locals():
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
from setupdevhelpers import *
sources_dir_name = "sources"
def update_package():
package_updated = False
mkdirs(sources_dir_name)
if dir_is_empty(sources_dir_name):
# Asking for a dir_or_file
dir_or_file = ask_message(
control.package,
"Do you want to import a directory as sources?\nClick No to import a file as sources.\nClick Cancel for more informations.",
3 + 32,
raise_error=False,
)
# Copying sources to package
if dir_or_file == 6:
source_src = ask_directory("Please select the source directory that will be copied in the package", raise_error=False)
source_name = os.path.basename(source_src)
source_dst = makepath(sources_dir_name, source_name)
if isdir(source_dst):
remove_tree(source_dst)
copytree2(source_src, source_dst)
elif dir_or_file == 7:
source_src = ask_filename("Please select the source file that will be copied in the package", raise_error=False)
source_name = os.path.basename(source_src).rsplit(".", 1)[0]
source_dst = makepath(sources_dir_name, os.path.basename(source_src))
if isfile(source_dst):
remove_file(source_dst)
filecopyto(source_src, source_dst)
else:
# error("Do you want to import a file or a directory?")
ask_message(
control.package,
"You can place your sources manually by editing this package. When the package is ready, it is recommended to run update_package() again.",
64,
)
error("Please edit this package.")
else:
source_name = list(set([os.path.basename(s) for s in glob.glob(makepath(sources_dir_name, "*"))]))[0]
if isfile(source_name):
source_name = source_name.rsplit(".", 1)[0]
# control.installed_size
control.installed_size = get_size(sources_dir_name)
control.save_control_to_wapt()
# Renaming package
if "template" in control.package:
complete_control_package(control, control.package.split("-", 1)[0] + "-" + source_name.lower() + "-sources")
complete_control_name(control, source_name)
if "template" in control.package:
error("Please rename the package.")
else:
version = str(int(control.get_software_version()) + 1)
else:
version = str(int(control.get_software_version()))
# Updating setup.py depends_package variable
depends_package = ask_input("depends_package", "You can define depends_package if you want to remove sources when package is installed:")
if depends_package:
lines = []
with open("setup.py", "r", encoding="utf8") as f:
lines = f.readlines()
for i in range(len(lines)):
line = lines[i]
if line.startswith("depends_package"):
line = 'depends_package = "%s"\n' % depends_package
lines[i] = line
break
with open("setup.py", "w", encoding="utf8", newline="\n") as f:
f.writelines(lines)
# 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 or not update-package-sources
return package_updated
6532b93b7c5ee6a8db48a0fa1d873adb28ed32a7d79db990914a3149f1d39666 : setup.py
2abe9cdf0e2dbf39a07a0ca60879366447782d0cad055979277939fa71732dfa : update_package.py
d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834 : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
f0f45fce4f29593a77cc415bf1c4459b8bee2274857d8a8a666c53bdc4dec958 : setupdevhelpers.py
647b657334cd854a025e2f88058ee33f2f49016b74b60cddbc2f63acee9240a3 : luti.json
684888c0ebb17f374298b65ee2807526c066094c701bcc7ebbe1c1095f494fc1 : sources/.gitignore
a4e89d3ef2058362ee9c191627fba0f42d347ee26163691b567c21a1c0f2a3dc : WAPT/control