Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105952

Re: Re-using TCL code from python over network

From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: Re-using TCL code from python over network
Date 2016-03-29 08:35 +0200
Organization A noiseless patient Spider
Message-ID <ndd7h7$fhn$1@dont-email.me> (permalink)
References <172d629d-3dc8-4e47-b163-05b4f32a027c@googlegroups.com>

Show all headers | View raw


Am 29.03.16 um 07:20 schrieb sharad1087@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re-using TCL code from python over network sharad1087@gmail.com - 2016-03-28 22:20 -0700
  Re: Re-using TCL code from python over network Christian Gollwitzer <auriocus@gmx.de> - 2016-03-29 08:35 +0200
  Re: Re-using TCL code from python over network Karim <kliateni@gmail.com> - 2016-03-29 09:40 +0200
    Re: Re-using TCL code from python over network Christian Gollwitzer <auriocus@gmx.de> - 2016-03-29 13:18 +0200
      Re: Re-using TCL code from python over network sharad1087@gmail.com - 2016-03-29 08:02 -0700
  Re: Re-using TCL code from python over network sharad1087@gmail.com - 2016-03-29 01:37 -0700
  Re: Re-using TCL code from python over network Sharad Singla <sharad1087@gmail.com> - 2016-03-29 04:29 -0400
  Re: Re-using TCL code from python over network Karim <kliateni@gmail.com> - 2016-03-29 12:24 +0200
    Re: Re-using TCL code from python over network blacksqr@gmail.com - 2016-03-29 13:26 -0700

csiph-web