Ask Your Question
1

run external command in its own console from a plugin ?

asked 2022-08-04 05:26:22 -0500

steve1964's avatar

updated 2022-08-04 07:50:39 -0500

How can I run an external command in its own Windows console from a Wing plugin ? Let assume, as example, the command:

make -C output -f build.mak

I tried something like:

app = wingapi.gApplication app.CreateChildProcess(['make', '-C', 'output', '-f', 'build.mak'], dirname=prj_dir)

but I do not see any effect.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-08-04 08:10:12 -0500

The following works for me to create a new Windows console and run 'dir' in it so I think should work as a basis for what you're trying to do:

def test_cmd():
  def terminated(*args):
    print('terminated', args)
  wingapi.gApplication.CreateChildProcess(['cmd.exe', '/c', 'start', 'dir'], terminated)

Note that your command line was missing the required terminated_cb arg so should have thrown an exception visible in the Messages tool, under the Scripts channel.

edit flag offensive delete link more

Comments

Thanks, now with this code I'm able to run a custom batch script in the directory I want:

app.CreateChildProcess(['cmd.exe', '/c', 'start', 'build.bat'], terminated, dirname=prj_dir)

Just a minor issue, I defined the callback as:

def terminated(timeout, exc, exit_code): print(f'terminated: {exc}, {exit_code}')

but it seems not called on termination.

steve1964's avatar steve1964  ( 2022-08-04 09:50:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-08-04 05:26:22 -0500

Seen: 10 times

Last updated: Aug 04