How to integrate a standalone Python script into a Rails application?

后端 未结 5 2190
你的背包
你的背包 2020-12-24 06:05

I\'ve got a program that has a small file structure going on and is then ran using

python do_work.py foo bar

I want my Rails users to press

5条回答
  •  盖世英雄少女心
    2020-12-24 07:03

    The answer from utapyngo is cover almost all you need to know. I'll answer this part:

    incidentally, trying this in irb: %x(python) Brings up the python terminal INSIDE of irb. It will not take params for whatever reason however.

    To pass parameters to your python script, simply pass it. Example:

    [fotanus@thing ~]$ python a.py 
    args:
    ['a.py']
    [fotanus@thing ~]$ irb
    1.8.7 :001 > %x(python a.py foo bar)
     => "args:\n['a.py', 'foo', 'bar']\n" 
    

    This works on ruby 1.8, 1.9 and 2.0.

提交回复
热议问题