Forums

External process

Hello,

I am tempting to launch a node script with os.popen (also i know it is deprecate) On my desktop this works fine

Here is the command : ... os.popen('/Applications/RapydScript-master/bin/rapydscript %s -o %s'%(fpy,fpjs)) ...

'rapydscript' is the node script

On PythonAnywhere ... os.popen('/home/.../RapydScript-master/bin/rapydscript %s -o %s'%(fpy,fpjs)) ...

But I can't make it work on PythonAnywhere. Does anybody have a clue ?

Regards

Salvatore

Are you running this script from the command-line or as part of a web application? What behaviour do you see? If you see an exception being raised, which exception is it and what's the error message?

Thanks for your interest.

For your information "RapydScript" translate "quasi python source to javascript"

Here is the code wich works without problem when I run it from web2py on my desktop

When I deploy it on pythonanywhere, "rapydscript" returns nothing Of course I modified the paths

@service.xmlrpc

@service.jsonrpc

def f(source):

  os.popen("rm %s" % fpy)

  os.popen("rm %s" % fpjs)

  f= open(fpy,"w")

  f.write(source)

  f.close()

  os.popen("/Applications/RapydScript-master/bin/rapydscript %s -o %s"%(fpy,fpjs))

  fjs = os.popen("cat %s"%fpjs)

  return str(fjs.read())

@Salvatore -- would you mind if I used my admin privileges to take a look at your code? It might be easier for me to work out what's going on that way.

Hi Gilles,

Of course you can :-) Here is the working 'python' version: http://salvatore.pythonanywhere.com/RapydJCanvas/default/index

The corresponding method in the controller is 'compile'

Here the controller https://salvatore.pythonanywhere.com/admin/default/edit/RapydJCanvas/controllers/default.py

Cool demo :-)

Hmm, OK. There's nothing obviously wrong in the code. So, just to make sure I understand the problem -- you're running the rapydscript binary that you've got on PythonAnywhere using the node binary that we have by default, and the os.popen is writing out a zero-byte file to the place specified by fpjs in your controller. Is that right?

Perhaps it would help to try running the exact command your popen does in a bash console and see if it's printing anything to the standard error? I think os.popen only captures standard out by default.

I definitely recommend you switch to using the subprocess module, BTW... I doubt it will fix this, but as you say, os.popen has been deprecated.

Thanks Giles :-)

Effectively there is no output produced to the place of fpjs...very strange. I will investigate a little more.

In any case thank you very much for the time you dedicate to help us. If I find a solution I will post it

Regards