Am 29.03.16 um 07:20 schrieb sharad1...@gmail.com:
We've a test automation framework written in TCL (including the
automated test cases). We are evaluating shifting to Python and have
a test framework in Python (including the automated test cases).
Python provides a lot more 3rd party libraries that we'd like to make
use of.
We use a pretty old version of TCL (8.4.5, 32 bit). It's on FreeBSD
and we've compiled it in-house. Compiling it to 64 bit or moving to a
newer version is a massive task (since we've a lot of libraries -
written in C and compiled as well as pure tcl).
Tcl's API (and ABI) is highly stable. I suspect that you could recompile
most of the libraries, unless they depend on 3rd party code which is not
portable. But of course it might be easier to call it from Python.
I've explored Python's Tkinter but it won't suit our case as it
points to system installed TCL. I've also explored Python's
subprocess (launch an interactive TCL shell remotely) and pexpect but
none of them worked well for me to allow me to use TCL code
interactively from Python.
I'd like to gather any ideas/experience around this. If anyone has
tried a similar stuff before and can share his/her experience, I'd
appreciate it.
You can set up a server in Tcl which will run arbitrary code from the
network. The simplest possible server looks like this:
http://wiki.tcl.tk/15539
A more complete package (which will correctly handle scripts which span
multiple lines etc.) is the comm package in tcllib:
https://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/comm/comm.html
Beware that this is of course a security hole, you should only do it in
a network restricted by your firewall or by employing a safe interpreter
on the Tcl side which is sufficiently restricted.
https://www.tcl.tk/man/tcl8.4/TclCmd/interp.htm#M10
Probably the easiest way is using Tkinter from Python to send commands
via the comm package to the remote site, i.e. tk.eval('package require
comm') and then sending your commands by tk.eval('comm:comm send ...')
The comm protocol is very simplistic
http://docs.activestate.com/activetcl/8.4/tcllib/comm/comm_wire.html
you could also reproduce it from Python in order to reduce this jumping
through hoops.
In the end it will always be a messy solution. As an interim solution it
might work, but you should seriously consider recompiling the code as 64
bit, migrating all code to Python or watch out for the libraries you
need in modern Tcl.
Christian
--
https://mail.python.org/mailman/listinfo/python-list