Subprocess statement works in python console but not work in Serverdensity plugin?

Posted by maxigs on Stack Overflow See other posts from Stack Overflow or by maxigs
Published on 2010-04-01T13:44:17Z Indexed on 2010/04/01 14:53 UTC
Read the original article Hit count: 148

Filed under:
|
|

in the python console the following statement works perfectly fine (i guess using eval that way is not really good, but its just for testing purpose in this case and will be replaced with proper parsing)

$ python
>>> import subprocess
>>> r = subprocess.Popen(['/home/kupferwerk/sd-agent-plugins/plugin1.rb'], stdout=subprocess.PIPE, close_fds=True).communicate()[0]
>>> data = eval(r)
>>> data
{'test': 1}

when i convert this into a Serverdensity plugin however it keeps crashing the agent.py daemon everytime it executes the plugin. i was able to narrow it down to the subprocess line but could not find out why. exception catching did not seem to work also.

here how the plugin looks like:

class plugin1:
  def run(self):
    r = subprocess.Popen(['/pathto/plugin1.rb'], stdout=subprocess.PIPE, close_fds=True).communicate()[0]
    data = eval(r)
    return data

I'm quite new to work with python and cant really figure out why this wont work. Thanks a lot for ideas :)

© Stack Overflow or respective owner

Related posts about python

Related posts about subprocess