From d41a6ea4fb03635f32392b10a6a9796400a04bf0 Mon Sep 17 00:00:00 2001 From: Gabriel Gendron Date: Wed, 6 Mar 2024 09:21:02 +0100 Subject: [PATCH] first commit --- .env | 2 + .vscode/launch.json | 305 ++++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 13 ++ WAPT/certificate.crt | 20 +++ WAPT/control | 44 ++++++ WAPT/manifest.sha256 | 1 + WAPT/signature.sha256 | 1 + WAPT/wapt.psproj | 235 ++++++++++++++++++++++++++++++++ setup.py | 43 ++++++ update_package.py | 78 +++++++++++ 10 files changed, 742 insertions(+) create mode 100644 .env create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 WAPT/certificate.crt create mode 100644 WAPT/control create mode 100644 WAPT/manifest.sha256 create mode 100644 WAPT/signature.sha256 create mode 100644 WAPT/wapt.psproj create mode 100644 setup.py create mode 100644 update_package.py diff --git a/.env b/.env new file mode 100644 index 0000000..7d8f006 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +VIRTUAL_ENV=C:\Program Files (x86)\wapt\ +PYTHONPATH=C:\Program Files (x86)\wapt\ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..584d5a5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,305 @@ +{ + "version": "0.2.4", + "configurations": [ + { + "name": "WAPT: install", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "install", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "linux": { + "sudo": true + }, + "osx": { + "sudo": true + }, + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: remove", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "remove", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "linux": { + "sudo": true + }, + "osx": { + "sudo": true + }, + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: uninstall", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "uninstall", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "linux": { + "sudo": true + }, + "osx": { + "sudo": true + }, + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: session-setup", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "session-setup", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: audit", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "audit", + "-f", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "linux": { + "sudo": true + }, + "osx": { + "sudo": true + }, + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: update-package", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "update-package-sources", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: -i build-upload", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "-i", + "--use-gui", + "build-upload", + "--no-ide", + "${workspaceFolder}" + ], + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "WAPT: build-package", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "${config:python.wapt-get}", + "args": [ + "build-package", + "--no-ide", + "${workspaceFolder}" + ], + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: import setup.py", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_import_setup_template.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: import update_package.py", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_import_update_template.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: complete-package", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_complete_control.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: translate-control", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_translate_control.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: unify-control files", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_unify_control.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: duplicate-os-package-code", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_duplicate_os_package_code.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: duplicate update_package.py", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_duplicate_update_package.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: change luti.json", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/change_luti_json.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: import .gitignore", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_import_gitignore.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + }, + { + "name": "DEV: quick testing", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "C:/Program Files (x86)/wapt/public/persistent/package-tools/package-template/launch_quick_testing.py", + "console": "integratedTerminal", + "python": "${command:python.interpreterPath}", + "pythonArgs": [ + "-I", + "-B" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1b136ec --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "python.defaultInterpreterPath": "C:\\Program Files (x86)\\wapt\\waptpython.exe", + "python.pythonPath": "C:\\Program Files (x86)\\wapt\\waptpython.exe", + "python.wapt-get": "C:\\Program Files (x86)\\wapt\\wapt-get.py", + "python.formatting.provider": "black", + "python.formatting.blackArgs": + [ + "--line-length", + "150" + ], + "editor.insertSpaces": true, + "files.eol": "\n" +} \ No newline at end of file diff --git a/WAPT/certificate.crt b/WAPT/certificate.crt new file mode 100644 index 0000000..6fd2b31 --- /dev/null +++ b/WAPT/certificate.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDNzCCAh+gAwIBAgIUSsaILn1scDCUhHvihORUTceVhO8wDQYJKoZIhvcNAQEL +BQAwJDELMAkGA1UEBhMCRlIxFTATBgNVBAMMDGdnZW5kcm9uX3BlbTAeFw0yMzEx +MDgwODM0MjhaFw0zMzExMDUwODM0MjhaMCQxCzAJBgNVBAYTAkZSMRUwEwYDVQQD +DAxnZ2VuZHJvbl9wZW0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCj +Qt/K76QyhKl8ulRmnrCSRnD3UyHBmgAxSDml14sVxuyjVE+WW3umCqrJ2/QL2Sqy +DbxiBeexaaVSM15pKcsHQSGnCy762IjBhJIc9iW1QxNi1z/BivBVmAZRmM12IsKj +VeVs5oKpHjO5Uw2R+/MKkqg/9rNk3MQNA44YcFIz4RSfU5IElKU3CwzYFPwdRBSv +Sjf+onG4MkbEbL7B0axeMsKYZ2gxyuU9H73eUwWXgs2ICUu0wlyzKil1jJabKlEr +vREIvt+TL1hUFVLzbADgQPmZhCC2aylzdiYlwaKgNUmwEOip3JpZe0ay8XkIhH2O +H0i5RzPHD0FJae1Og9J7AgMBAAGjYTBfMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O +BBYEFIJMVc1b++36XjWfjFhF+5AfxigaMA4GA1UdDwEB/wQEAwIB1jAdBgNVHSUE +FjAUBggrBgEFBQcDAgYIKwYBBQUHAwMwDQYJKoZIhvcNAQELBQADggEBAJkDZMAN +7aI3TPEXKAHWFBI25+CkV1OL+/NIhgdI3JVvu3rQ2iUcFS08+7rMa555OT3YjTFJ +4Cm0onhdXhVS0ENjvlfm2gWoD5t9SP9ZN4t1K19PDY6SCAqV79pYu2KfuHRXhmSZ +2p/tS1i01dkulJ49AKZNSp3BJ3xThL5oJHHOMgF5msRjZHBMRPsz3HgksaKzn3TE +fzyJ2/izHvTzllez7Ns90eVGPKMvZtZDSq+YpAhVSb6Fn46WVS2Z6Ce3GfRUiN6b +RJ4IQ6a+JhTgjJR6XJFQcmfDWFyzHjajd8OhbLuQjTIaiHyYcUNB9oZeyonMZ4ea +5MedsXgtUISHfhs= +-----END CERTIFICATE----- diff --git a/WAPT/control b/WAPT/control new file mode 100644 index 0000000..658f5f7 --- /dev/null +++ b/WAPT/control @@ -0,0 +1,44 @@ +package : comi-update-reboot-template +version : 0-4 +architecture : all +section : base +priority : optional +name : update-reboot +categories : +maintainer : ggendron +description : Package for comi-update-reboot +depends : +conflicts : +maturity : PROD +locale : +target_os : all +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 : 1c4f367f-8c42-40f7-88bc-11af6101c6ba +valid_from : +valid_until : +forced_install_on : +changelog : +min_os_version : +max_os_version : +icon_sha256sum : +signer : ggendron_pem +signer_fingerprint: 244cdf15fa2ea3ead58e4abf232fdf9a30a8a28a798677f71d6a3e76e65f9003 +signature_date : 2024-03-04T13:04:42.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 : Evh5PPkeXVAJjbdUBEjwSo4ykGWfih6VPVpvlgrFjsbO7oBeigOpjnfgGWOIIF2gP0Mp9VISeijZF8gKwj5ejn9x3CYoBT6NNE+0xjac5kjtd6wkgUZFuB0eKEmJJuemcTc3n8Yr63y5URpxB5+ySFliqC3KmYNw5YzoUZxIc16CLuGKVNOvMCqMNwLSeyS+7Ohc06dD7Yv/dsXuL23sYKVmdewrfq6Lw26MLQYO1qU4Z4984XGyAZc9iUqUhfpQI+dLnOEn8chjyVET+XjZzUKuOb02AqsTTpa/sm0QB2mT6o+KmyYayQa4rdtVrogjW8cvOiwfrWyd+gQzUMlcCA== \ No newline at end of file diff --git a/WAPT/manifest.sha256 b/WAPT/manifest.sha256 new file mode 100644 index 0000000..d02c3c4 --- /dev/null +++ b/WAPT/manifest.sha256 @@ -0,0 +1 @@ +[[".env","720b2be3b2d977425b68892f478262e7d3f764ca56c86e4d6aa2f639ea3dd214"],[".vscode/launch.json","7185f7797616d2fefe06cdb959ccb08bf0f677287a21aacc3111a65d4f072584"],[".vscode/settings.json","c4ef3e7d26642471ae3a2faaa131a40791fda1542ede085de266c5144adb2a3c"],["WAPT/certificate.crt","68194bca04eef7aaf4dc3c3bd12b017a1263bb5fcc034919fc7edda0c62db266"],["WAPT/control","c4c920f62d63cfccc1288a97b6c8dafc62e91dcf4f1e3dd163f63c792e818939"],["WAPT/wapt.psproj","c6246be77fa0d87cb8860fc9de433dfc02b56edaaca368712d5b6267141eeee4"],["setup.py","8a39f504219528458d35763a2cc251b6dcd56abd803382104e79de70c5b21350"],["update_package.py","31ed182e6aa93b03a491de1cdb75c6b298a5d8738b02afdd8813447efde26edf"]] \ No newline at end of file diff --git a/WAPT/signature.sha256 b/WAPT/signature.sha256 new file mode 100644 index 0000000..01c5616 --- /dev/null +++ b/WAPT/signature.sha256 @@ -0,0 +1 @@ +U4G6jr/WSHWRevZH3J0MldQpJfIWcDaQ28yw/qELuXb//Doa3X/PH5IlLOYkKRqmstPZHbml8b1+K1aMwEj68SEkPLVHzWC6hLlrgCdbdg1Xc30FJ6qnwjOZlPVrCukFteK6ySHhHoKAejeRuFs58bZRvSeuhjMLXNW3hMpQ8T8OxrdhZ6sZRQKKeN8kWCG1PKHtTuDvvupk3A2yDuvHO7GExyA65wNcHQ6EqOakwHNNaJQvDjL9WKNeSinx+06QDXOtmf8K5rShicAj6zG/Qmh0jHxqGp8Jg8VMMLxwPIwVOwv/wYnpU0teXmQ8geWJkkUO8U9pKwX3o8P4o/PaZw== \ No newline at end of file diff --git a/WAPT/wapt.psproj b/WAPT/wapt.psproj new file mode 100644 index 0000000..31fd757 --- /dev/null +++ b/WAPT/wapt.psproj @@ -0,0 +1,235 @@ +[PyScripter] +Version=3.6.4.0 + +[Project] +ClassName=TProjectRootNode +StoreRelativePaths=TRUE +ShowFileExtensions=FALSE + +[Project\ChildNodes\Node0] +ClassName=TProjectFilesNode + +[Project\ChildNodes\Node0\ChildNodes\Node0] +ClassName=TProjectFolderNode +Name=wapt + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node0] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\common.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node1] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\setuphelpers.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node2] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\setuphelpers_linux.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node3] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\setuphelpers_macos.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node4] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\setuphelpers_unix.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node5] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\setuphelpers_windows.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node6] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\wapt-get.ini + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node7] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\wapt-get.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node8] +ClassName=TProjectFileNode +FileName=C:\Program Files (x86)\wapt\waptpackage.py + +[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes] +Count=9 + +[Project\ChildNodes\Node0\ChildNodes\Node1] +ClassName=TProjectFileNode +FileName=$[Project-Path]changelog.txt + +[Project\ChildNodes\Node0\ChildNodes\Node2] +ClassName=TProjectFileNode +FileName=$[Project-Path]control + +[Project\ChildNodes\Node0\ChildNodes\Node3] +ClassName=TProjectFileNode +FileName=$[Project-Path]..\setup.py + +[Project\ChildNodes\Node0\ChildNodes] +Count=4 + +[Project\ChildNodes\Node1] +ClassName=TProjectRunConfiguationsNode + +[Project\ChildNodes\Node1\ChildNodes\Node0] +ClassName=TProjectRunConfiguationNode +Name=WAPT: install + +[Project\ChildNodes\Node1\ChildNodes\Node0\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Launch package installation. +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=install "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node0\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[ActiveScript-Dir] + +[Project\ChildNodes\Node1\ChildNodes\Node1] +ClassName=TProjectRunConfiguationNode +Name=WAPT: remove + +[Project\ChildNodes\Node1\ChildNodes\Node1\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Launch uninstallation (the uninstallation code found in local wapt database, remember to launch after an installation). +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=remove "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node1\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[ActiveScript-Dir] + +[Project\ChildNodes\Node1\ChildNodes\Node2] +ClassName=TProjectRunConfiguationNode +Name=WAPT: uninstall + +[Project\ChildNodes\Node1\ChildNodes\Node2\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Launch uninstallation code (for debugging purpose, it only runs the code of uninstall function). +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=uninstall "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node2\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[Project-Path].. + +[Project\ChildNodes\Node1\ChildNodes\Node3] +ClassName=TProjectRunConfiguationNode +Name=WAPT: session-setup + +[Project\ChildNodes\Node1\ChildNodes\Node3\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Launch session-setup (it runs directly as current user). +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=session-setup "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node3\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[ActiveScript-Dir] + +[Project\ChildNodes\Node1\ChildNodes\Node4] +ClassName=TProjectRunConfiguationNode +Name=WAPT: audit + +[Project\ChildNodes\Node1\ChildNodes\Node4\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Launch package audit. +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=audit -f "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node4\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[ActiveScript-Dir] + +[Project\ChildNodes\Node1\ChildNodes\Node5] +ClassName=TProjectRunConfiguationNode +Name=WAPT: update-package + +[Project\ChildNodes\Node1\ChildNodes\Node5\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Launch update_package (it usually serve to update binaries of the package). +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=update-package-sources "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node5\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[ActiveScript-Dir] + +[Project\ChildNodes\Node1\ChildNodes\Node6] +ClassName=TProjectRunConfiguationNode +Name=WAPT: -i build-upload + +[Project\ChildNodes\Node1\ChildNodes\Node6\RunConfig] +ScriptName=C:\Program Files (x86)\wapt\wapt-get.py +Description=Build and upload package to the waptserver. +EngineType=peRemote +ReinitializeBeforeRun=TRUE +Parameters=--use-gui -i build-upload "$[Project-Path].." +WorkingDir=$[Project-Path].. +WriteOutputToFile=FALSE +OutputFileName=$[ActiveScript-NoExt].log +AppendToFile=FALSE + +[Project\ChildNodes\Node1\ChildNodes\Node6\RunConfig\ExternalRun] +Caption=External Run +Description=Run script using an external Python Interpreter +ApplicationName=$[PythonExe-Short] +Parameters=$[ActiveScript-Short] +WorkingDirectory=$[ActiveScript-Dir] + +[Project\ChildNodes\Node1\ChildNodes] +Count=7 + +[Project\ChildNodes] +Count=2 + +[Project\ExtraPythonPath] +Count=0 + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b10646f --- /dev/null +++ b/setup.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +from setuphelpers import * +import subprocess + +hour_reboot = '18:00' +day_reboot = 'SUN' + +def install(): + pass + +def check_reboot_pending(hostname): + """ + Fonction pour vérifier si un poste a un reboot en attente. + + Args: + hostname: Le nom d'hôte du poste à vérifier. + + Returns: + True si un reboot est en attente, False sinon. + """ + returncode = run('systeminfo | find "Restart"',accept_returncodes=[0, 1, 3010]) + + if returncode: + return True + else: + return False + +def audit(): + hostnames = ["localhost"] + reboot_pending = check_reboot_pending(hostnames) + print(reboot_pending) + if reboot_pending is True: + print(f"Le poste a un reboot en attente.") + WAPT.write_audit_data_if_changed("Update Reboot", "Reboot Pending", reboot_pending) + run(f'schtasks /create /sc weekly /st {hour_reboot} /RU "NT AUTHORITY\SYSTEM" /d {day_reboot} /tn "Reboot_Update" /tr "shutdown /r /t 0"') + return "WARNING" + else: + print(f"Le poste n'a pas de reboot en attente.") + WAPT.write_audit_data_if_changed("Update Reboot", "Reboot Pending", reboot_pending) + if task_exists("Reboot_Update") is True: + run('schtasks /delete /tn "Reboot_Update" /f') + return "OK" + diff --git a/update_package.py b/update_package.py new file mode 100644 index 0000000..5028faf --- /dev/null +++ b/update_package.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +from setuphelpers import * +from setupdevhelpers import * +import waptguihelper + +def update_package(): + # Modify the values from setup.py + define_hour_reboot = ask_input("Heure de Reboot", "Heure de Reboot", "18:00") + define_day_reboot = ask_input("Jour de Reboot", "Jour de Reboot", "SUN") + + with open("setup.py", "r", encoding="utf8") as f: + for line in f.readlines(): + if line.startswith("hour_reboot"): + line = 'hour_reboot = '+ f'{define_hour_reboot}''\n' + new_lines.append(line) + with open("setup.py", "w", encoding="utf8", newline="\n") as f: + f.writelines(new_lines) + new_lines = [] + with open("setup.py", "r", encoding="utf8") as f: + for line in f.readlines(): + if line.startswith("day_reboot"): + line = 'day_reboot = '+ f'{define_day_reboot}''\n' + new_lines.append(line) + with open("setup.py", "w", encoding="utf8", newline="\n") as f: + f.writelines(new_lines) + + # Edit Control + ask_control_package(control.package, "-template") + control.save_control_to_wapt() + return ask_control_version(control.get_software_version()) + + + +def ask_control_version(version, inc_build=False): + """Requesting that the user supply package version for the `control.version`. Additionally it will make sure user will be able to upload_package from WAPT Console""" + package_updated = False + + # 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: + version_plus = ( + ".".join(version.split(".")[: len(version.split(".")) - 1]) + "." + str(int(version.split(".")[len(version.split(".")) - 1]) + 1) + ) + version = ask_dialog(control.package, "Version must be %s minimum to upload from WAPT Console" % version_plus, version_plus) + if not version: + version = control.get_software_version() + 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 + + control.set_software_version(version) + if inc_build: + control.inc_build() + control.save_control_to_wapt() + return package_updated + +def ask_dialog(title, text, default="", stay_on_top=False): + """This function opens a dialog box with a action input""" + return waptguihelper.input_dialog(title, text, default, stay_on_top) + +def ask_control_package(control_package=None, conditionnal_package_name=None, remove_base_files=False): + """Requesting that the user provide a package name to be entered into the control.package field, and offering the possibility of removing the base files (icon.png and changelog.txt) for template package usage + + Args: + control_package (str) : prefilled control_package (default: actual control_package) + conditionnal_package_name (str) : only ask when the control.package contains conditionnal_package_name (default: always ask for control_package) + remove_base_files (bool) : removes base files if parameter is True and conditionnal_package_name is provided (default: False) + """ + if conditionnal_package_name is None or conditionnal_package_name in control.package: + control.package = waptguihelper.input_dialog( + control.package, + "You can redefine the package name", + control_package.replace(conditionnal_package_name, "") if conditionnal_package_name is not None else control_package, + ) + control.save_control_to_wapt() +