473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

RE: python/ruby question..

hey guys...

i managed to solve what i was attempting.. my goal was rather simple, to be
able to have a python script, call a ruby app, and be able to return a
value from the ruby (child) app to the parent.. blocking/unblocking wasn't
on my radar for now.

ultimately, my goal is to have an app on a master server, with that app
calling the ruby app using the remote functions (rsh/rexec for now).

so, on the master python, i have:
#!/usr/bin/python

#test python script
import re
import os
import sys, string
import os.path
import subprocess

#print "foo"
pp="http://siteanalytics.compete.com/xxxx/?metrics=uv"

a = subprocess.Popen(["/test1/test.rb",pp], stdout=subprocess.PIPE)
aa=a.communicate()[0]
qq=aa.split("\n")
print "qq[8] = ",qq[8]
print "qq[9] = ",qq[9]
print "qq[10] = ",qq[10]
#exit()

and on the child/ruby app:
#! /usr/local/bin/ruby

require 'rubygems'
require '/usr/local/lib/ruby/gems/1.8/gems/firewatir-1.1.1/firewatir'
include FireWatir

a1=ARGV[0]

ff=Firefox.new
ff.goto(a1)
table = ff.table(:id, "dataTable").to_a
#puts table
#puts "blah...."
aa = table[1][1]
puts table[1][1]

#ff.text_field(:name, "q").set("ruby")
#ff.button(:value,"Google Search").click
#puts ff.element_by_xpath("//a[@class='l']").text
#ff.close
#puts "hi there"
#return (33)
this pretty much works as it needs to for now...

like i said.. rather simple, as it should be.

so thanks for the help/suggestions from everyone!

-----Original Message-----
From: py*****************************************@python .org
[mailto:py***************************************** @python.org]On Behalf
Of Paul McGuire
Sent: Thursday, June 19, 2008 6:27 PM
To: py*********@python.org
Subject: Re: python/ruby question..
On Jun 18, 10:33*pm, "bruce" <bedoug...@earthlink.netwrote:
hi...

can someone point me to where/how i would go about calling a ruby app from
a
python app, and having the python app being able to get a returned value
from the ruby script.
I'm betting that Ruby is similar to Python in that a Ruby interpreter
can be embedded within other applications. Why not implement
something like ruby_exec(), similar to Python's exec, which takes a
string containing Ruby code, and a dict of variables that can be
accessed and updated from the executed Ruby? Then no messing around
with subprocess, XMLRPC, firing up processes, etc. - just create the
string and call it.

(Implementation left as an exercise for the reader.)

-- Paul
--
http://mail.python.org/mailman/listinfo/python-list

Jun 27 '08 #1
0 1380

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
13
by: Wayne Folta | last post by:
I've been a long-time Perl programmer, though I've not used a boatload of packages nor much of the tacky OO. A couple of years ago, I decided to look into Python and Ruby. Python looked OK, but...
30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
0
by: Robert | last post by:
After failing on a yield/iterator-continuation problem in Python (see below) I tried the Ruby (1.8.2) language first time on that construct: The example tries to convert a block callback interface...
13
by: aum | last post by:
Hi, I'm a Python programmer, just starting to get into javascript. On reading some of the js guides, and not liking any of the OO usage patterns I saw, I've cooked up something which python...
22
by: lennart | last post by:
Hi, I'm planning to learn a language for 'client' software. Until now, i 'speak' only some web based languages, like php. As a kid i programmed in Basic (CP/M, good old days :'-) ) Now i want to...
10
by: bruce | last post by:
hi... can someone point me to where/how i would go about calling a ruby app from a python app, and having the python app being able to get a returned value from the ruby script. something...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.