Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105976
| 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 12:24:20 +0200 |
| Lines | 128 |
| Message-ID | <mailman.145.1459247064.28225.python-list@python.org> (permalink) |
| References | <172d629d-3dc8-4e47-b163-05b4f32a027c@googlegroups.com> <56FA3179.3080005@gmail.com> <CAHwJbX-u1D-y1yprCvkY=D4YaD8cLM1zbWdJNuKqoSDN77GvAg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de rinISA6SYWA9lLJFcAU/0Awbwh3wRSFz5YTqGBdas0+g== |
| Return-Path | <kliateni@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'rewrite': 0.07; 'subject:code': 0.07; 'cc:addr:python-list': 0.09; '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; '2016': 0.16; 'eval': 0.16; 'evaluating': 0.16; 'in-house.': 0.16; 'invoking': 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; 'email addr:gmail.com>': 0.18; 'python?': 0.18; 'shell': 0.18; 'variable': 0.18; 'thanks.': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; "we'd": 0.21; 'correctly.': 0.22; 'exec': 0.22; 'gather': 0.22; 'libraries': 0.22; 'shifting': 0.22; 'skip:$ 20': 0.22; 'tkinter': 0.22; 'cc:no real name:2**0': 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; 'developers': 0.26; 'installed': 0.26; 'linux': 0.26; 'points': 0.27; 'coding': 0.27; 'skip:# 10': 0.27; 'this.': 0.28; "skip:' 10": 0.28; 'interface': 0.29; 'equivalent.': 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; 'expected': 0.35; 'but': 0.36; 'project': 0.36; 'needed': 0.36; 'faster': 0.36; 'framework': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'thanks': 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; 'where': 0.40; 'your': 0.60; 'close': 0.61; 'share': 0.61; 'email addr:gmail.com': 0.62; 'export': 0.63; 'more': 0.63; 'our': 0.64; 'mar': 0.65; 'experience.': 0.66; 'pro': 0.70; 'bridging': 0.84; 'round.': 0.84; 'subject:over': 0.84; 'alone.': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=j6sw3fwvy55E4Tl2cpR6XlI9SMFqIt6q+G5j1UIUL1s=; b=SxZomMhXIoRRwae6hXuysFNGLyfUtciVg3PYN4RyJFBIQg5GNGS25idwR4Gj9E2/NP Nvqy0uJPqCY/C1Imq2QicQE1KgdkCFP8M/DV63h6WSdPB255pPF/szHGOXAZyLr7hBb8 bev0MgYnmnGHzK5GEqcDwnrrBkygcggovd56p/6l+WIwGyG7wtxgeoaTmaZmBhOX8Siu jC22fNgzI6f0pP4zXBuZWG6yrbHsv7TkhQxyHTvvXtAiQlUlB5+YoYkCzuMg/htCeLW+ f+fZpi04h0hp9dYH+e2ga37X9wcVDGh/kQ+RPNDEXFgKkjS5r1jWHSkihz3Wn8MIXfMp d3iA== |
| 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:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=j6sw3fwvy55E4Tl2cpR6XlI9SMFqIt6q+G5j1UIUL1s=; b=T3ojHNjqK/5WdM1qXoJ1XpVdBOoCXDWvdjLxq+ZGGxCGaYDiqj4midBsPDYM60lpuM /2GvtM92x+PSoFiIpS1ftUaEfNRowjJlrwYu/v1g4YB/767obcklcehcVwZOt24bMY92 6DxdbHLLBwOJFCYUVB50xrgPZZHBrJlmsekZQb6zJTGpB81bPyzgmpyF8VKpF7zYn+TX bHn08PLA+XfGu3ArZBmXgTZr1JWzQEQlthLYN2EpxkGN/UEXw5b3lGTOdteKm7IFNw7L ofFI8Kx4C5fk8CfyGBONyg31CDXHHzHrtca3cuHv9C8X4RzTLL43El+yyDbJsliwUl0+ QPFw== |
| X-Gm-Message-State | AD7BkJKVf6h4XzHCRctBVHcd8XYaiGBAXyT/IzCTi+fTq67o4TeUKqPOhrsdPMxCaPI2+A== |
| X-Received | by 10.194.78.129 with SMTP id b1mr1786724wjx.60.1459247062097; Tue, 29 Mar 2016 03:24:22 -0700 (PDT) |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
| In-Reply-To | <CAHwJbX-u1D-y1yprCvkY=D4YaD8cLM1zbWdJNuKqoSDN77GvAg@mail.gmail.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| 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:105976 |
Show key headers only | View raw
On 29/03/2016 10:29, Sharad Singla wrote:
>
> Thanks. This is more of invoking python code from TCL. I am looking
> for the other way round.
>
> Curious, did you rewrite all your TCL code in python?
>
> Regards
> Sharad
>
> On Mar 29, 2016 1:10 PM, "Karim" <kliateni@gmail.com
> <mailto:kliateni@gmail.com>> wrote:
>
>
>
> On 29/03/2016 07:20, sharad1087@gmail.com
> <mailto: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
>
>
Yes, part by part. In fact it was faster than expected thanks to python
syntax.
TCL coding is heavier than python equivalent. I say that by experience.
My project involved 2 developers one pro TCL and myself pro Python.
We found the best deal for both. Now I am alone. This is the reason
everything is now python.
But it was a good experience to learn TCL (weaknesses).
Karim
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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