PDA

View Full Version : Write to datbase in a spawn python call



hmischel@diligentsystems.com
2018-04-29, 07:23
Hi,

I am using spawn to execute many python background processes. How do I include the Lianja modules in the python script so that it can write back to the tables?

Thanks

Herb

ps - my environment variable is set to c:\lianja\scriptinglanguages\ptyhon. So it is using the Lianja install of Python.

barrymavin
2018-04-29, 08:47
Hi Herb,

You can run.

lianjaruntime filename.ext

where ext can be .dbo, .py, .php or .js.

So you should spawn the runtime which has python embedded.

hmischel@diligentsystems.com
2018-04-29, 09:26
Hi Barry,

This works for me when spawning just the python call.

python.exe c:\lianja\apps\matchbackmain\generate_file.py D:\\buffys2ep20\\test36\\jpg\

But I am not sure how to call the runtime properly to get it to work. I am calling it like this

lianjaruntime.exe c:\lianja\apps\matchbackmain\generate_file.py D:\\buffys2ep20\\test36\\jpg\

I have also tried like this.


lianjaruntime.exe --kiosk c:\lianja\apps\matchbackmain\generate_file.py --args D:\\buffys2ep20\\test36\\jpg\

I think I am missing something.

Thanks

Herb

barrymavin
2018-04-29, 09:44
Hi Herb

https://www.lianja.com/doc/index.php/Command_Line_Switches

You may need to use

lianjaruntime —file filename.ext

barrymavin
2018-04-29, 22:28
Hi Herb,

When you spawn the python interpreter how are you referencing the args?

barrymavin
2018-05-01, 00:20
In Lianja 4.1.2 this now all works as expected.

lianja --file c:\lianja\apps\matchbackmain\generate_file.py --args "'D:\\buffys2ep20\\test36\\jpg\'"
or
lianjaruntime --file c:\lianja\apps\matchbackmain\generate_file.py --args "'D:\\buffys2ep20\\test36\\jpg\'"

Here is an example:

lianja --file barry.py --args "'hello\sthere',1234,'bye'"

and the file barry.py:


if __name__ == "__main__":
print sys.argv

The output is:

['barry.py', 'hello there', 1234, 'bye']

Note that spaces in the --args list need to be escaped as \s or  

hmischel@diligentsystems.com
2018-05-01, 19:54
Thanks Barry!