First time here? Check out the FAQ!
1

run external command in its own console from a plugin ?

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.

steve1964's avatar
114
steve1964
asked 2022-08-04 05:26:22 -0600
Wingware Support's avatar
4k
Wingware Support
updated 2022-08-04 07:50:39 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

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.

Wingware Support's avatar
4k
Wingware Support
answered 2022-08-04 08:10:12 -0600
edit flag offensive 0 remove flag delete link

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 -0600) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer