Page 1 sur 1

[RESOLU] run(cmd) renvoie une erreur

Posté : 28 janv. 2020 - 19:09
par empbilly
Bonjour,

code:

Code : Tout sélectionner

for soft in installed_softwares("NetBeans"):
        try:
            cmd = WAPT.uninstall_cmd(soft['key'])
            if len(cmd) == 2:
                cmd = cmd[0]
            if not '--silent' in cmd:
                cmd = cmd + ' --silent --state {}state.xml'.format(path)
                print(cmd)
                run(cmd)
        except ValueError:
            print('An error occured!')
j'exécute un test d'installation de pyscripter, mais l'exécution (cmd) renvoie l'erreur suivante:

Code : Tout sélectionner

CalledProcessErrorOutput: Command 'C:\\Program Files\\NetBeans-11.2\\uninstall.exe --silent --state C:\\ProgramData\\state.xml' returned non-zero exit status 1.
Je crois que cela est dû au fait qu'il met "\\" deux barres arrière.

Comment puis-je le résoudre?

Re: run(cmd) renvoie une erreur

Posté : 28 janv. 2020 - 20:22
par sfonteneau

Code : Tout sélectionner

for soft in installed_softwares("NetBeans"):
        try:
            cmd = WAPT.uninstall_cmd(soft['key'])
            if len(cmd) == 2:
                cmd = cmd[0]
            if not '--silent' in cmd:
                cmd = '"%s" --silent --state "%s"' % (cmd,makepath(path,'state.xml'))
                print(cmd)
                run(cmd)
        except ValueError:
            print('An error occured!')
Vous pouvez essayer avec ça ?

Re: run(cmd) renvoie une erreur

Posté : 29 janv. 2020 - 12:26
par empbilly
Vous pouvez essayer avec ça ?
Désolé, je n'ai pas compris votre question! :D
...
cmd = '"%s" --silent --state "%s"' % (cmd,makepath(path,'state.xml'))
...
Dans les tests d'exécution locaux avec le psy, cela a fonctionné.
Image

En production, il insère à nouveau les barres arrière "\\" dans le chemin du logiciel et génère une erreur.

Code : Tout sélectionner

CalledProcessErrorOutput: Command '"C:\\Program Files\\NetBeans-11.2\\uninstall.exe" --silent  returned non-zero exit status 1. 
Des idées?

Re: run(cmd) renvoie une erreur

Posté : 31 janv. 2020 - 14:50
par empbilly
Toute aide?

Re: run(cmd) renvoie une erreur

Posté : 07 févr. 2020 - 12:28
par empbilly
Les gars de reddit m'aident!! Maintenant, il est ok!!

Code : Tout sélectionner

for soft in installed_softwares("NetBeans"):
        try:
            cmd = "{} --silent\
                -J-Dremove.netbeans.installdir=true \
                -J-Dremove.netbeans.userdir=true".format(soft['uninstall_string'])
            print("Uninstall string: {}".format(cmd))
            run(cmd)
        except ValueError:
            print('[ERROR] An error occured!\n')

Re: run(cmd) renvoie une erreur

Posté : 11 févr. 2020 - 17:20
par dcardon
Hi empbilly,
empbilly a écrit : 07 févr. 2020 - 12:28 Les gars de reddit m'aident!! Maintenant, il est ok!!

Code : Tout sélectionner

for soft in installed_softwares("NetBeans"):
        try:
            cmd = "{} --silent\
                -J-Dremove.netbeans.installdir=true \
                -J-Dremove.netbeans.userdir=true".format(soft['uninstall_string'])
            print("Uninstall string: {}".format(cmd))
            run(cmd)
        except ValueError:
            print('[ERROR] An error occured!\n')
Actually it is the same nice people from Tranquil IT keeping an eye on both reddit (for English speaking people) and on this forum (for French speaking people) ;-)

Denis