Python+Expect+Win32 = Not Possible?

2007-09-12 Thread gamename
Hi,

Is it still the case there is no practical Expect-like module for
win32? I know that cygwin can support pexpect, but that isn't an
option here --- I have to use a native win32 Python version.

Are there alternatives, or is it simply not an option to replicate
Expect on win32 with python?

All I'm trying to do is start a couple processes, wait for each to say
"done" on stdout and then quit (or timeout if something went wrong).

TIA,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python+Expect+Win32 = Not Possible?

2007-09-13 Thread gamename
On Sep 13, 1:42 am, [EMAIL PROTECTED] wrote:
> On Sep 12, 9:27 pm, gamename <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Is it still the case there is no practical Expect-like module for
> > win32? I know that cygwin can support pexpect, but that isn't an
> > option here --- I have to use a native win32 Python version.
>
> > Are there alternatives, or is it simply not an option to replicate
> > Expect on win32 with python?
>
> > All I'm trying to do is start a couple processes, wait for each to say
> > "done" on stdout and then quit (or timeout if something went wrong).
>
> > TIA,
> > -T
>
> I had planned on using telnet to do the same thing on windows.  I
> don't think I ever proved it, but I'm pretty sure it will work.

Thanks, Sean.  The problem is that telnet is generally disabled on
most hosts nowadays.

>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52228
>
> ~Sean


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python+Expect+Win32 = Not Possible?

2007-09-13 Thread gamename
On Sep 13, 4:18 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> gamename wrote:
> > On Sep 13, 1:42 am, [EMAIL PROTECTED] wrote:
> >> On Sep 12, 9:27 pm, gamename <[EMAIL PROTECTED]> wrote:
>
> >>> Hi,
> >>> Is it still the case there is no practical Expect-like module for
> >>> win32? I know that cygwin can support pexpect, but that isn't an
> >>> option here --- I have to use a native win32 Python version.
> >>> Are there alternatives, or is it simply not an option to replicate
> >>> Expect on win32 with python?
> >>> All I'm trying to do is start a couple processes, wait for each to say
> >>> "done" on stdout and then quit (or timeout if something went wrong).
> >>> TIA,
> >>> -T
> >> I had planned on using telnet to do the same thing on windows.  I
> >> don't think I ever proved it, but I'm pretty sure it will work.
>
> > Thanks, Sean.  The problem is that telnet is generally disabled on
> > most hosts nowadays.
>
> I'm not sure whether the need you describe above "start a
> couple [of] processes, wait for each to say 'done' and
> then quit (or timeout...)" is *all* of your requirements
> or just an example. And are these processes running on
> remote machines? Or just locally?
>
Good question.  That's part of the requirements.  The rest are:  The
processes need to be async (i.e. the script doesn't stop while waiting
for the process to complete). They also need some kind of timeout
mechanism so that the processes don't run forever. All processes are
local.

> Depending on those things, maybe there are other ways
> to do what you want under Windows?
>
> (I've checked back through the archives and I can't find
> any earlier posts describing the requirement more clearly).
>
> TJG


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python+Expect+Win32 = Not Possible?

2007-09-13 Thread gamename
On Sep 13, 4:51 am, Philem <[EMAIL PROTECTED]> wrote:
> On Sep 13, 12:27 am, gamename <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Is it still the case there is no practical Expect-like module for
> > win32? I know that cygwin can support pexpect, but that isn't an
> > option here --- I have to use a native win32 Python version.
>
> > Are there alternatives, or is it simply not an option to replicate
> > Expect on win32 with python?
>
> > All I'm trying to do is start a couple processes, wait for each to say
> > "done" on stdout and then quit (or timeout if something went wrong).
>
> > TIA,
> > -T
>
> You could try this 
> link:http://www.activestate.com/Products/activetcl/features.plex
> and see if that gives you what you need.

It absolutely gives me what I need.  But the requirement is to use
Python specifically. :)  Tcl is a great language, but not an option in
this case.
>
> Luck!
> -J


-- 
http://mail.python.org/mailman/listinfo/python-list


Renaming or Overloading In Python

2007-03-18 Thread gamename
Hi,

I'm a recent convert from TCL.  One of the more powerful aspects of
TCL is the ability to rename a function at will (generally for testing
purposes).

Example from the tcl doc:

rename ::source ::theRealSource
set sourceCount 0
proc ::source args {
global sourceCount
puts "called source for the [incr sourceCount]'th time"
uplevel 1 ::theRealSource $args
}

So, is such a thing possible in Python?

Thanks,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Renaming or Overloading In Python

2007-03-19 Thread gamename
On Mar 18, 4:57 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> gamename <[EMAIL PROTECTED]> wrote:
> > Hi,
>
> > I'm a recent convert from TCL.  One of the more powerful aspects of
> > TCL is the ability to rename a function at will (generally for testing
> > purposes).
>
> > Example from the tcl doc:
>
> > rename ::source ::theRealSource
> > set sourceCount 0
> > proc ::source args {
> > global sourceCount
> > puts "called source for the [incr sourceCount]'th time"
> > uplevel 1 ::theRealSource $args
> > }
>
> > So, is such a thing possible in Python?
>
> Assuming that source is a function previously defined in this scope, the
> exactly equivalent Python snippet should be:
>
> theRealSource = source
> sourceCount = 0
> def source(*args):
>   global sourceCount
>   sourceCount += 1
>   print "called source for the %s'th time" % sourceCount
>   return theRealSource(*args)
>
> Others have already offered you other alternatives, but I thought you
> might also be interested in a more direct/immediate translation.
>
> Alex

Excellent! Thanks guys, that really gives me a place to start.

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


C Source Code Generator For Test Cases

2007-09-28 Thread gamename
Hi,

Can anyone recommend a good method of using python to generate c
source code?   I have tables of test cases to use as input to a
process which would generate the test's source code.  The Cheetah tool
looks interesting.  Has anyone used it? Any other suggestions?

TIA,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-09-28 Thread gamename
>
> How about using c-types to access your C-stuff to test, and use python + the
> testcase-tables to invoke that?
>

Sure, that's possible.  But the source code for tests (once all the
parms are read)
still needs to be generated.  Calling the lib from python or from C,
there still
needs to be a way to generate 100+ test routines. ;-)

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-09-29 Thread gamename

> Instead of reading the testcase tables and generating source for test
> routines you simply can do the tests right away.
>

Can't. :(  This is for an embedded system.  I need to create source
(in C) on one machine and then compile on others.  The only thing that
I can be certain of is an ANSI compiler on any machine I use.

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C Source Code Generator For Test Cases

2007-10-03 Thread gamename

> You might want to look at COG (http://www.nedbatchelder.com/code/
> cog/).  It might be helpful to you.  I really enjoy using it and keep
> finding things to use it with.

Thanks Mike.  I agree. COG looks really promising.

-T

-- 
http://mail.python.org/mailman/listinfo/python-list


ctypes & Wrapping Complex Datatypes

2007-10-16 Thread gamename
Hi,

I've just started using ctypes and so far, its great.  But I'm running
to some problems with complex datatypes.  I'm not sure how to wrap
something like this:

   /* This defines the Handle type in a header file.  I don't think
this needs wrapping, its just to show the handle definition for
context*/
typedef struct DFFTSHandle_s *DFFTSHANDLE;
...
  /* Then, the handle is used like this later on.  This *is* what I
want to wrap.*/
status = DFFTSCreateSession(&Handle);
status = DFFTSSetSessionOption(Handle, DFFTSOPT_ITERATIONS,
&iteration, sizeof(iteration));


Any ideas?

-- 
http://mail.python.org/mailman/listinfo/python-list


ctypes & Wrapping Complex Datatypes

2007-10-16 Thread gamename
Hi,

I've just started using ctypes and so far, its great.  But I'm running
to some problems with complex datatypes.  I'm not sure how to wrap
something like this:

   /* This defines the Handle type in a header file.  I don't think
this needs wrapping, its just to show the handle definition for
context*/
typedef struct DFFTSHandle_s *DFFTSHANDLE;
...
  /* Then, the handle is used like this later on.  This *is* what I
want to wrap.*/
status = DFFTSCreateSession(&Handle);
status = DFFTSSetSessionOption(Handle, DFFTSOPT_ITERATIONS,
&iteration, sizeof(iteration));


Any ideas?

TIA,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ctypes & Wrapping Complex Datatypes

2007-10-16 Thread gamename
On Oct 16, 6:52 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Tue, 16 Oct 2007 06:47:06 -0700, gamename wrote:
> > I've just started using ctypes and so far, its great.  But I'm running
> > to some problems with complex datatypes.  I'm not sure how to wrap
> > something like this:
>
> >/* This defines the Handle type in a header file.  I don't think
> > this needs wrapping, its just to show the handle definition for
> > context*/
> > typedef struct DFFTSHandle_s *DFFTSHANDLE;
> > ...
> >   /* Then, the handle is used like this later on.  This *is* what I
> > want to wrap.*/
> > status = DFFTSCreateSession(&Handle);
> > status = DFFTSSetSessionOption(Handle, DFFTSOPT_ITERATIONS,
> > &iteration, sizeof(iteration));
>
> If this "handle" is always just treated as a pointer to an opaque data
> structure you may just use a void pointer.
>
> Ciao,
> Marc 'BlackJack' Rintsch

OK.  Thanks.
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Equivalent of TCL's "subst" ?

2007-11-13 Thread gamename
Hi,

In TCL, you can do things like:
set foobar "HI!"
set x foo
set y bar
subst $$x$y
HI!

Is there a way to do this type of evaluation in python?

TIA,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Equivalent of TCL's "subst" ?

2007-11-17 Thread gamename
>  >>> foobar = "HI!"
>  >>> x = 'foo'
>  >>> y = 'bar'
>  >>> print eval(x+y)
> HI!

Great! Thanks.
-T
-- 
http://mail.python.org/mailman/listinfo/python-list


2.5.1 rpms?

2007-12-21 Thread gamename
Hi,

Where can I find python 2.5.1 rpm's for redhat9 and fedora6/7?

Thanks,
-T
-- 
http://mail.python.org/mailman/listinfo/python-list


Cloning Environments

2008-01-02 Thread gamename
Hi,

I have several machines running Linux (mostly fedora6) and Windows
(mostly XP).  I'm thinking of using easy_install to create as uniform
an environment as possible for all of them. Cloning the environment,
to put it another way.

Is there a good example somewhere showing how to do this? I'm new to
easy_install and relatively new to python.

TIA,
-T
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cloning Environments

2008-01-03 Thread gamename
>
> You might be interested in workingenv.py/virtualenv.py
>
Thanks! That looks promising.
-T
-- 
http://mail.python.org/mailman/listinfo/python-list


Win32+Cygwin+ActiveState Python+SCons

2008-01-10 Thread gamename
Hi,
 I just installed scons on win32 that has cygwin but uses ActiveState
python. If I do "import SCons", the lib isn't found.
The win32 installer seemed very complete, but the scons lib doesn't
seem to be in any dir python knows about.

Is there another install step I need to do?

TIA,
-T
-- 
http://mail.python.org/mailman/listinfo/python-list


Not Sure This Can Be Done...

2008-04-01 Thread gamename
Hi,

I generally have several copies of the same development environment
checked out from cvs at any one time.  Each development tree has a
'tools' dir containing python modules.  Scattered in different places
in the tree are various python scripts.

What I want to do is force my scripts to always look in the closest
'tools' dir for any custom modules to import. For example:

tree1/tools
tree1/my_scripts/foo.py

tree2/tools
tree2/my_scripts/foo.py

How can I make 'foo.py' always look in '../../tools' for custom
modules? My preference would be to avoid changing the 'foo.py' script
and have some way to resolve it via the environment (like PYTHONPATH,
or .pth files, etc.).

Anyone have any ideas?
TIA,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Not Sure This Can Be Done...

2008-04-01 Thread gamename

> Use virtualenv to create a local python, and activate that when
> developing for that branch.

Thanks for the suggestion, but that's the problem: having to activate
it.
Isn't there some way to simply have the local script look at a
specified
 dir rather than starting a virtual environment?

-T
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Not Sure This Can Be Done...

2008-04-05 Thread gamename
Thanks! Good suggestion(s) all.

Maybe I can get this done. :)

-T

On Apr 1, 4:49 pm, MrJean1 <[EMAIL PROTECTED]> wrote:
> In any script upon startup, sys.path[0] contains the full path of the
> directory where the script is located.  See <http://docs.python.org/
> lib/module-sys.html> under 'path'.
>
> it should be straightforward from here (untested though).  In each
> script, get the sys.path[0] string, split it using os.path, replace
> the last item with 'tools' and join again with os.path.  If the
> resulting string is not in sys.path, insert it after sys.path[0].
>
> /Jean Brouwers
>
> On Apr 1, 1:57 pm, gamename <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I generally have several copies of the same development environment
> > checked out from cvs at any one time.  Each development tree has a
> > 'tools' dir containing python modules.  Scattered in different places
> > in the tree are various python scripts.
>
> > What I want to do is force my scripts to always look in the closest
> > 'tools' dir for any custom modules to import. For example:
>
> > tree1/tools
> > tree1/my_scripts/foo.py
>
> > tree2/tools
> > tree2/my_scripts/foo.py
>
> > How can I make 'foo.py' always look in '../../tools' for custom
> > modules? My preference would be to avoid changing the 'foo.py' script
> > and have some way to resolve it via the environment (like PYTHONPATH,
> > or .pth files, etc.).
>
> > Anyone have any ideas?
> > TIA,
> > -T

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Not Sure This Can Be Done...

2008-04-09 Thread gamename
Hi,

In hopes it may help someone else, here's what I ended up doing:

1) Add this to to point to your local 'tools' directory:
   import site
   # the python tools dir is at "../../tools/python"
   site.addsitedir('..'+os.sep+'..'+os.sep+'tools'+os.sep
+'python')

2) In the 'tools' dir, there is a file called 'local.pth'.  Its
contents:
   # the individual modules are at "../../tools/python/modules/
"
  ./modules/pexpect

3) In the script you can now do:
  import pexpect

That's it.  This works fine, but there are still 2 outstanding issues:

A) How do make the same ".pth" file usable on a win32 environment?
   The path separators are different (i.e. "/" vs "\").

B) How to auto-include any subdirectory in 'python/modules' so that
each
   new module dir doesn't have to be added manually? That is, if
package
   'foo' is added, it would be in 'python/modules/foo'. Is there a
way
   to avoid manually putting that in the '.pth'?

FYI,
-T

-- 
http://mail.python.org/mailman/listinfo/python-list


Sending Cntrl-C ??

2008-04-29 Thread gamename
Hi,

I really like this recipe for controlling subprocesses:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

However, I can't figure out how I can send the equivalent of "Cntrl-C"
to the subprocess.  How can that be done?

TIA,
-T
--
http://mail.python.org/mailman/listinfo/python-list


Re: Sending Cntrl-C ??

2008-04-29 Thread gamename

> import os
> import signal
> import subprocess
>
> popen = subprocess(...)
> os.kill(popen.pid, signal.SIGINT)
>
> Or with Python 2.6+:
>
> popen.send_signal(signal.SIGINT)

Thanks, Christian.  Would that work on win32 as well?

-T
--
http://mail.python.org/mailman/listinfo/python-list


Re: Sending Cntrl-C ??

2008-04-30 Thread gamename
>
> > No, Windows doesn't support the same, rich set of signal as Unix OSes.
>
> True but irrelevant to the question.
> To the OP: you can download the pywin32 package from sourceforge, and use
> win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid)
> or call the same function using ctypes.
> Seehttp://msdn.microsoft.com/en-us/library/ms683155(VS.85).aspxfor some
> important remarks.

Thanks, guys.  Good info.
-T
--
http://mail.python.org/mailman/listinfo/python-list


Re: Sending Cntrl-C ??

2008-04-30 Thread gamename
> win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid)

How do you determine the value of 'pgid'?

--
http://mail.python.org/mailman/listinfo/python-list