tis-template-package-sources
0-7
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-7
- categories : Dependency
- maintainer : WAPT Team,Tranquil IT,Clément BAZIRET,Jimmy PELÉ
- installed_size :
- editor :
- licence : proprietary_free,wapt_public
- signature_date : 2024-01-10T18:00:06.499276
- size : 19.06 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-7
architecture : all
section : base
priority : optional
name : Package Sources Template
categories : Dependency
maintainer : WAPT Team,Tranquil IT,Clément BAZIRET,Jimmy PELÉ
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 : d7a30ee2-1110-4694-b917-4475a761dd4a
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version :
max_os_version :
icon_sha256sum : d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834
signer : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature : rVBQ9w9XTBmyNntFANcOh9yYQmuGlTNz6Rm5KAFS4nUDzW/g8SkezZ6ECvm9qlw/4hC4x48T7XFp/zVlFPywaD8vdZ76pjKi1zHLeZntb+r0e/vjrEQ2TfTHmcAugstMl5ucH1O2UdnNeN/uzlbqeiOj815/KDoDp+7t9SGUV4VYSyJeItrlgzZxu72GlTGvzNhsgM30no+GiNsgG2FmGC4+z9+YXuPMVOD5zb4D+eSyQ1pqLu6KzuSxX5Fo0IYa6Ii9sn871imxy8oi5gc/DMv7MxB7onYweOAATriY43c2Ke33JtPCGx56oM1s3lkyu9AeVhQlzKBdtdatqebHAg==
signature_date : 2024-01-10T18:00:06.499276
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)
remove_file(makepath(sources_dir_name, ".gitignore"))
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
e930fc38b0abd86505b44c62e030edcf0a26a710e41b7f63ead525acbe13ff1b : update_package.py
d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834 : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
f0f45fce4f29593a77cc415bf1c4459b8bee2274857d8a8a666c53bdc4dec958 : setupdevhelpers.py
73a4d00db1633a6f4ba4cb4e2be61b94b96c79aa926880735f3cb06d5f86fcd0 : luti.json
684888c0ebb17f374298b65ee2807526c066094c701bcc7ebbe1c1095f494fc1 : sources/.gitignore
69e3bf6b341effc487c0c7c506688df51a9ed4fb927bec5b11f494891dbcbd86 : WAPT/control