Changes attributes in control. Clean code in setup.py

This commit is contained in:
Kevin Guerineau
2019-06-09 21:49:22 +02:00
parent ce6fd5fd68
commit fef093d61e
2 changed files with 35 additions and 49 deletions
+33 -33
View File
@@ -1,37 +1,37 @@
package : kg-disable-access-microphone package : kg-disable-access-microphone
version : 0-3 version : 1-3
architecture : all architecture : all
section : base section : base
priority : optional priority : optional
name : name :
maintainer : Administrator maintainer : Kévin Guérineau <k@kguerineau.net>
description : Package for kg-disable-microphone description : Disable microphone access for applications
depends : depends :
conflicts : conflicts :
maturity : maturity : PROD
locale : locale : all
target_os : target_os : windows
min_os_version : min_os_version : 10
max_os_version : max_os_version :
min_wapt_version : min_wapt_version : 1.6
sources : sources :
installed_size : installed_size :
impacted_process : impacted_process :
description_fr : description_fr : Désactiver l'accès au microphone pour les applications
description_pl : description_pl : Wylaczenie dostepu do mikrofonu dla aplikacji
description_de : description_de : Mikrofonzugriff für Anwendungen deaktivieren
description_es : description_es : Desactivar el acceso al micrófono para aplicaciones
audit_schedule : audit_schedule :
editor : editor :
keywords : keywords :
licence : licence :
homepage : homepage :
package_uuid : 2789f187-7e8b-4185-93f1-fd89b629ec18 package_uuid :
valid_from : valid_from :
valid_until : valid_until :
forced_install_on : forced_install_on :
signer : wapt-private signer :
signer_fingerprint: f92cc2c37728a7041fdc444a610944e93e722bc118d6e3c1d27de71fea99afdf signer_fingerprint:
signature : bBoIf/otqAK4qUlbJAsJV4hnZkduqL/dj3RnuTFJQ+2XRvRcMgQgaa50JS7/0ODgxcuV76+p/cFzGIdIaboat5TrSr4JB0tvohCsG6Zan1PikJgDLwRGAHbi/Jtho9g6OM4lCLvGz+wej55rjXTs+oiTaNte0/aUOzxcPoyZhCETdeub25yCc1nGAWuyJwvsmxQpZTYsI16eR91RG6vPAHoQQdlE/swJPG12ogUtLmAtyhETsEb+l/a5SU8GK5TjfPKkpz9SLeyUnhn/+g7Nfk3c8LQBDHWRZa5XxdXoHaKO2Hqeow65bgyuH+TiqUGA7C3CLXpdUGKigjD7DCBE2Q== signature :
signature_date : 2019-06-01T14:13:20.499000 signature_date :
signed_attributes : package,version,architecture,section,priority,name,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,signer,signer_fingerprint,signature_date,signed_attributes signed_attributes :
+2 -16
View File
@@ -7,29 +7,15 @@ def install():
print('installing %s' % control.asrequirement()) print('installing %s' % control.asrequirement())
registry_set(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone','Value','Deny') registry_set(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone','Value','Deny')
def uninstall(): def uninstall():
print('uninstalling %s' % control.asrequirement()) print('uninstalling %s' % control.asrequirement())
registry_set(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone','Value','Allow') registry_set(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone','Value','Allow')
def session_setup():
print('Session setup for %s' % control.asrequirement())
# put here what to do when package is configured inside a user session
# implicit context variables are WAPT, control, user, params
def update_package():
print('Update package content from upstream binary sources')
# put here what to do to update package content with newer installers.
# launched with command wapt-get update-package-sources <path-to-wapt-directory>
# implicit context variables are WAPT, basedir, control, user, params, run
# if attributes in control are changed, they should be explicitly saved to package file with control.save_control_to_wapt()
def audit(): def audit():
print('Auditing %s' % control.asrequirement()) print('Auditing %s' % control.asrequirement())
if registry_readstring(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone','Value').lower() == 'deny': if registry_readstring(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone','Value').lower() == 'deny':
return 'OK' return 'OK'
else: else:
return 'Error' return 'Error'
if __name__ == '__main__':
update_package()