Hello Denis,
Unfortunately, there are a large number of machines that are impacted by this phantom inventory.
That's why I was looking for a way to automate it, given the impossibility of easily cleaning the inventory of a machine after a server migration.
So I came up with this very simple code:
It is possible to forget a package known only to the client since it is not registered in the packages assigned to the machine on the console, therefore no reinstallation.
Code: Select all
# -----------------------------------------------------------------------
# This script was made in an effort to manage previous WAPT registred packages.
# Made by Renaud Counhaye for Ymagis.
# -----------------------------------------------------------------------
from setuphelpers import *
list_replaces=["chrome-fr","firefox-esr-fr","adobereader-mui"] #liste de vieux paquet aillant un remplacant
list_replaced=["chrome","firefox","adobereader"] #liste des paquets remaplcants les anciens! attention doit être dans le meme ordre!
#list de paquets à oublier tout simplement.
list_forgets=["check-viscosity","fr-standard-applications","apple-software-update","ie11","fr04-fr-Office365-and-Standard-applications","fr-web-browsers","deploy-ymagis-nxt","trend-micro-security-agent"]
uninstallkey = []
#def main():
def install():
#check si le fichier précédent existe, si oui, kill
if(isfile(makepath('C:','sys','logs','waptgetlist.txt'))):
print('previous file is present')
remove_file(makepath('C:','sys','logs','waptgetlist.txt'))
print('start...')
run('cmd /c wapt-get list > C:\sys\logs\waptgetlist.txt') #creation d'un fichier contenant la lsite des packets actif sur la machine
if(isfile(makepath('C:','sys','logs','waptgetlist.txt'))):
print('file is present')
f=open(makepath('C:','sys','logs','waptgetlist.txt'), "r")
if f.mode == 'r':
f1 = f.readlines() #lecture ligne par ligne du fichier
for line in f1:
data = line.split(" ")
package = data[0]
if package in list_replaces:
print '--in replaces' #si le paquet lu est dans la liste des pack a remplacer, on forget puis wapt.install
point=list_replaces.index(package)
if(point != -1):
cmd = "cmd /c wapt-get forget "+package+" --force"
run(cmd)
WAPT.install(list_replaced[point],force=WAPT.options.force)
else:
if package in list_forgets:
print '--in forgets' #si le paquet lu est dans la liste des pack a oublier, on forget
point = list_forgets.index(package)
if(point != -1):
print str(point)+' found forgets'
cmd = "cmd /c wapt-get forget "+package+" --force"
run(cmd)
else:
print '++not found'
print 'end.'
if __name__ == '__main__': #run debug
install()
PS: It would be interesting to allow a WAPT package with a special key to force a package to be unassigned from the machine on which it is running.
Good day,