Home Download Buy Blog Forum Support

Exit code of 'run_command'

Exit code of 'run_command'

Postby skorfmann on Sat Aug 25, 2012 11:51 am

Hey there,

I'm wondering if it's possible to get the exit code of a command started with 'run_command' like the following:

Code: Select all
self.view.window().run_command("exec", {
      "cmd": [command],
      "shell": True,
      "working_dir": working_dir
})


I'm running my tests with this command and trying to find a way to tell, if they ran successfully or not. I want to display the panel with the test output only if the tests were failing.

Cheers,

Sebastian
skorfmann
 
Posts: 4
Joined: Fri Dec 16, 2011 12:19 pm

Re: Exit code of 'run_command'

Postby skorfmann on Sun Aug 26, 2012 2:57 am

Ok, I've figured it out myself. The sad thing is, that all params are converted to JSON, which makes it impossible to pass a method / lambda as callback. Now I have just added a few lines to the 'on_finished' callback of 'ExecCommand' in 'Packages/Default/exec.py'. This works for me now, but it makes it impossible to publish such functionality as a plugin. I was trying to reopen the 'ExecCommand' class like in ruby, but this is apparently not possible :)

Any other ideas how I could inject my needed functionality into the 'ExecCommand' class?

Thanks,

Sebastian
skorfmann
 
Posts: 4
Joined: Fri Dec 16, 2011 12:19 pm

Re: Exit code of 'run_command'

Postby jps on Mon Aug 27, 2012 1:36 am

Current versions of the exec command do print the exit code if it's non-zero.

With respect to editing the default exec command, you'd need to make a new command, either by copying it or subclassing from it, and then make your build system use your my_exec command via the target property in the build system.
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm

Re: Exit code of 'run_command'

Postby skorfmann on Mon Aug 27, 2012 12:10 pm

jps wrote:Current versions of the exec command do print the exit code if it's non-zero.

I want to show the test panel automatically if the tests were failing. So I reckon, that this is not possible with the current implementation of 'exec'.

With respect to editing the default exec command, you'd need to make a new command, either by copying it or subclassing from it, and then make your build system use your my_exec command via the target property in the build system.

Of course, subclassing. Thought for some weird reason, that it wouldn't be possible, as it's some kind of default system functionality. Will try it.

Thanks for your Support!

Sebastian
skorfmann
 
Posts: 4
Joined: Fri Dec 16, 2011 12:19 pm

Re: Exit code of 'run_command'

Postby danpe on Tue Nov 06, 2012 6:42 am

How can you subclass from a class that is in the Default directory?
danpe
 
Posts: 1
Joined: Tue Nov 06, 2012 6:40 am


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests