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


Groups > comp.lang.python > #105958

Re: Re-using TCL code from python over network

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Karim <kliateni@gmail.com>
Newsgroups comp.lang.python
Subject Re: Re-using TCL code from python over network
Date Tue, 29 Mar 2016 09:40:41 +0200
Lines 83
Message-ID <mailman.133.1459237246.28225.python-list@python.org> (permalink)
References <172d629d-3dc8-4e47-b163-05b4f32a027c@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de B5StcCeMSiSUmfyMtJHk7A2n6k8fBV0oAQ2ZzFuJE+zQ==
Return-Path <kliateni@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:code': 0.07; 'anymore.': 0.09; 'modules.': 0.09; 'namespace': 0.09; 'none"': 0.09; 'subject:using': 0.09; 'python': 0.10; 'python.': 0.11; 'subject:python': 0.14; 'interpreter': 0.15; '"set': 0.16; 'eval': 0.16; 'evaluating': 0.16; 'in-house.': 0.16; 'ops': 0.16; 'proc': 0.16; 'received:192.168.43': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'wrote:': 0.16; 'of.': 0.18; 'shell': 0.18; 'variable': 0.18; "we'd": 0.21; 'to:2**1': 0.21; 'correctly.': 0.22; 'exec': 0.22; 'gather': 0.22; 'libraries': 0.22; 'shifting': 0.22; 'skip:$ 20': 0.22; 'tkinter': 0.22; 'bit': 0.23; "python's": 0.23; 'tried': 0.24; 'import': 0.24; 'written': 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; 'example': 0.26; 'installed': 0.26; 'linux': 0.26; 'points': 0.27; 'skip:# 10': 0.27; 'to:no real name:2**1': 0.27; 'this.': 0.28; "skip:' 10": 0.28; 'interface': 0.29; 'tcl': 0.29; 'launch': 0.29; '(including': 0.30; 'code': 0.30; 'task': 0.30; 'skip:[ 10': 0.31; "i'd": 0.31; 'anyone': 0.32; 'compiled': 0.32; 'useful': 0.33; 'his/her': 0.33; 'suit': 0.33; 'similar': 0.33; 'message-id:@gmail.com': 0.34; 'worked': 0.34; 'received:google.com': 0.35; 'newer': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'needed': 0.36; 'framework': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'experience,': 0.38; "won't": 0.38; 'version': 0.38; 'delete': 0.38; 'stuff': 0.38; 'skip:o 20': 0.38; 'skip:- 20': 0.39; 'test': 0.39; 'data': 0.39; 'subject:from': 0.39; 'received:192': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'your': 0.60; 'close': 0.61; 'share': 0.61; 'email addr:gmail.com': 0.62; 'charset:windows-1252': 0.62; 'export': 0.63; 'more': 0.63; 'our': 0.64; '.....': 0.76; 'bridging': 0.84; 'subject:over': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=L62R190zh1uHr1e6XjG8GPJAwI9e8ZBazZzX2D8YRuY=; b=Qh9g1OA3KkQMCzw45IuQTQ1FM0EVhTJl/kY3gj3Dm2h6xbjPozeXZkhQacJ9Dzlgsv aJ8Q3jMOT6ZOLJbpQMW19FG5FJ2Clj/dbA5J8mZQnkRpwtd4vvY5LpdQOxh4e+qA3a/w tuTxLctm7zorOZ5F1busNP/peW5XW0JqXTNxUpNNpQx7X3/YKCCV7+vGztHYcCdPvDgL Y4lVsJfc4zHOYsUmRm3Z/IUPMCgY+HumkrSrIAUxYpegSwXv3ph3toj8lpV1KtmyIT6w 8S9EL6Eae/LmgKmC64ty071cHIxw7MN7dOpTmUZ4H1W1+hZRDD5rsmhWQS7xNnRhCPGe XhTg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=L62R190zh1uHr1e6XjG8GPJAwI9e8ZBazZzX2D8YRuY=; b=j74Y7EXf3LPb9f0EKt6PP0MtNw++uimtTLlfqR0Zd0QkQ2rNWZO14+GOdfhdQe+8Ei kRl96rsddjSnbwVlnevVfc1CPAprVSQOBTCuTovAaLamxH2n4pByj4JJ/9YzAnhdUEuh sEIsChE4Soib4ilOhqiu96bL84R7kvETIjZMKq4gvK7ikNySy4AD6gRUR/xrJHdbfBHs WlkJ2Zpalnf4VuhcmBtdI7n39GMA1byV2GiwDcbBFr47I9ZsU8M2m5trSGUstEWDozO5 Sr0jXH9CdmLmnnW3saHEm6v6FSY+znf4ts+bdJ+KDT1PfbdJCNZM/i0hcKZ+cUTMtNT1 oYaQ==
X-Gm-Message-State AD7BkJLmXqHtQdn5NclEMw6tjZJYGRwgD0LeUemFLJla8hOWi3rv4HlB5D4q3vEDJCKoEg==
X-Received by 10.194.63.242 with SMTP id j18mr1082834wjs.114.1459237243071; Tue, 29 Mar 2016 00:40:43 -0700 (PDT)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
In-Reply-To <172d629d-3dc8-4e47-b163-05b4f32a027c@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105958

Show key headers only | View raw



On 29/03/2016 07:20, sharad1087@gmail.com wrote:
> Hi
>
> 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).
>
> Also, we are evaluating having this Python infrastructure on Linux (CentOS).
>
> 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.
>
> Regards
> Sharad

You can find below a partial example where I launch a python process 
from a tcl program to get data from python
which reads a database. You just have to get and compile tclpython 
(google is your best friend) which is a C interface
bridging python and tcl and allow to launch at most 5 python interpreter 
processes if I remember correctly. I used it during 4
years but I now I migrated all the TCL code to python one indeed I don't 
need it anymore. But it is useful to do the transition.

#!/usr/bin/env tclsh8.4

lappend auto_path $env(TCLPYTHON_PKG_PATH)
package require tclpython 4.1

namespace eval ops {
   namespace export initPython
   namespace export exitPython
...
   namespace export getDeviceDescription

....
}

proc ops::initPython {} {
# ----------------------------
# @goal: Create the interpreter process and import python needed modules.
# @arg:  <none>
# @return: <none>
# ----------------------------
   variable interpreter
   set interpreter [python::interp new]
   $interpreter exec {from ops.tcl.pythontcl         import to_string, 
to_list, to_dict, to_bool}
   ....
   $interpreter exec "opsdb = None"
   $interpreter exec "input_structure = dict()"
}

proc ops::exitPython {} {
# ----------------------------
# @goal: Close the interpreter process.
# @arg:  <none>
# @return: <none>
# ----------------------------
   variable interpreter
   python::interp delete $interpreter
}

proc ops::getDeviceDescription { libName deviceName } {
# ----------------------------
# @goal: get
# @arg:  <none>
# @return:
# ----------------------------
   variable interpreter
   $interpreter exec "d_s = to_string(getDeviceDescription(opsdb, 
'$libName', '$deviceName'))"

   eval "set value [$interpreter eval {d_s}]"
   return $value
}

Karim

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