Page 1 of 1

[SOLVED] run(cmd) returns an error

Published: January 28, 2020 - 7:09 PM
by empbilly
Good morning,

code:

Code: Select all

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!')
I'm running a test installation of PyScripter, but the command prompt (cmd) returns the following error:

Code: Select all

CalledProcessErrorOutput: Command 'C:\\Program Files\\NetBeans-11.2\\uninstall.exe --silent --state C:\\ProgramData\\state.xml' returned non-zero exit status 1.
I believe this is due to the fact that he puts "\\" two back bars.

How can I solve it?

Re: run(cmd) returns an error

Published: January 28, 2020 - 8:22 PM
by sfonteneau

Code: Select all

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!')
Can you try this?

Re: run(cmd) returns an error

Published: January 29, 2020 - 12:26 PM
by empbilly
Can you try this?
Sorry, I didn't understand your question! :D
...
cmd = '"%s" --silent --state "%s"' % (cmd,makepath(path,'state.xml'))
...
In local execution tests with the psychiatrist, it worked.
Picture

In production, it reinserts the backslashes "\\" into the software path and generates an error.

Code: Select all

CalledProcessErrorOutput: Command '"C:\\Program Files\\NetBeans-11.2\\uninstall.exe" --silent  returned non-zero exit status 1. 
Any ideas?

Re: run(cmd) returns an error

Published: January 31, 2020 - 2:50 PM
by empbilly
Any help?

Re: run(cmd) returns an error

Published: February 7, 2020 - 12:28 PM
by empbilly
The guys on Reddit are helping me!! Now it's okay!!

Code: Select all

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) returns an error

Published: February 11, 2020 - 5:20 PM
by dcardon
Hi Empbilly,
empbilly wrote: Feb 7, 2020 - 12:28 The guys on Reddit are helping me!! Now it's okay!!

Code: Select all

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