title: How to get the output of python script executed from a ruby method
body: <p>I am trying to run a python script from ruby method. I am running this method as a rake task within a Rails app. I am using the solution mentioned <a href="https://stackoverflow.com/questions/690151/getting-output-of-system-calls-in-ruby/690174#690174">here</a>:</p>
  
  <pre><code>def create
      path = File.expand_path('../../../../GetOrders', __FILE__)
      output = `"python2 " + path + "/parse.py"`
      print output
      str = JSON.parse(output)
      print str
  end
  </code></pre>
  
  <p><strong>EDIT</strong>: This works:</p>
  
  <pre><code>    output = `python2 #{path}/parse.py`
  </code></pre>
  
  <p><strong>EDIT2</strong>:
  Using the python script i am trying to pass a list of dictionaries to the ruby function. The python script looks something like:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  import json
  
  def parse():
      tree = ET.parse('response.xml')
      root = tree.getroot()
      namespaces = {'resp': 'urn:ebay:apis:eBLBaseComponents'}
      order_array = root.find("resp:OrderArray", namespaces=namespaces)
      detailsList = []
      for condition:
          details["key1"] = value1
          details["key2"] = value2
      detailsList.append(details)
      output = json.dumps(detailsList)
      return output
  
  print parse()
  </code></pre>
  
  <p>Could someone explain what i am doing wrong and how can I fix this. Thanks</p>