[python-win32] Re: os.system problem

Larry Bates lbates at syscononline.com
Fri May 9 12:38:40 EDT 2003


Just thought I'd jump in here with another suggestion.
Since you are working on W2K you might want to try
using win32process.CreateProcess instead.  I just
finished a project and this seemed to work best for
me.  I gave me much finer control over execution
of external programs.  Below is a code fragment:

import win32process
STARTUPINFO=win32process.STARTUPINFO()
STARTUPINFO.dwX=0  # X window offset
STARTUPINFO.dwY=0  # Y window offset
STARTUPINFO.dwXSize=800  # X size in pixels
STARTUPINFO.dwYSize=600  # Y size in pixels
win32process.CreateProcess(executestring, None, None, None, 0, 0, None,
None, STARTUPINFO)

where executestring is the full UNC path to what you wish to run.
I refer you to the win32 documentation for additional information
on CreateProcess.

Regards,
Larry


-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of
python-win32-request at python.org
Sent: Friday, May 09, 2003 11:03 AM
To: python-win32 at python.org
Subject: Python-win32 Digest, Vol 2, Issue 8


Send Python-win32 mailing list submissions to
	python-win32 at python.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mail.python.org/mailman/listinfo/python-win32
or, via email, send a message with subject or body 'help' to
	python-win32-request at python.org

You can reach the person managing the list at
	python-win32-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-win32 digest..."


Today's Topics:

   1. python and COM - in particular Visual SourceSafe	Automation
      and python (Andreas Maurer)
   2. Re: os.system problem (Magnus Lyck?)
   3. Re: python and COM - in particular Visual SourceSafe
      (amapy at snafu.de)
   4. RE: Conflicts with Python (ET Planet)
   5. Re: Conflicts with Python (Scott Prive)


----------------------------------------------------------------------

Message: 1
Date: Thu, 08 May 2003 22:04:13 +0200
From: Andreas Maurer <amapy at snafu.de>
Subject: [python-win32] python and COM - in particular Visual
	SourceSafe	Automation and python
To: python win32 <python-win32 at python.org>
Message-ID: <3EBAB83D.2000504 at snafu.de>
Content-Type: text/plain; charset=us-ascii; format=flowed

Hi everybody,

I've a question about a strange behavior about comparing Visual Basic
and python. Don't worry ;-)

I used Visual SourceSafe under python with teh SourceSafe COM-Server

   --> oVSS = win32com.client.Dispatch('SourceSafe').

Everything works fine. I accomplished the makepy-utility and
for the VSSItem-object the GetVersion method was available.


When I try the same in Visual Basic I cant't see the
VSSItem.GetVersion(...) method.

Why does python and win32com find this method in the
right way and how does makepy work, that this
important method is available under python and not under VB?

I will be very appreciated for any hints to solve this mystery

Andi



------------------------------

Message: 2
Date: Thu, 08 May 2003 23:43:50 +0200
From: Magnus Lyck? <magnus at thinkware.se>
Subject: Re: [python-win32] os.system problem
To: "Lawrence W. Leung" <larryl at imail.CS.Berkeley.EDU>,
	python-win32 at python.org
Message-ID: <5.2.1.1.0.20030508233300.0260d120 at www.thinkware.se>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 10:53 2003-05-07 -0700, Lawrence W. Leung wrote:
>Hi,
>
>I'm trying to use os.system to execute a command in win2k with python
>2.2.2 and it's not behaving as expected.  Basically, the idea is I pass it
>a command line that begins with a quoted path to an executable (to avoid
>the problem of the space in the path) and also a quoted argument and it
>fails to find the executable.  But oddly enough when I unquote the
>argument it seems to find the executable just fine.

Doesn't the same thing happen if you run these things directly
from the command line?

It's my experience in Windows that I have to remove quotes that
I would be using if I was in Unix. In Unix, the shell will remove
the quotes before calling commands. The quotes will determine if
a parameter is just one parameter, despite containing spaces etc,
and single quotes will stop expansion of $ etc, but Windows don't
have these things. Whatever you type at the command line will be
thrown at your program, quotes and all. Unix utilities won't expect
that.

Another thing you might try is to replace os.system with popen2.popen3
like this:

 >>> import popen2
 >>> out, inp, err = popen2.popen3('my command')
 >>> inp.close()
 >>> out.read()
[output from my command]
 >>> err.read()
[error from command]

That might provide more hints than the exit codes...


--
Magnus Lycka (It's really Lyck&aring;), magnus at thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program



------------------------------

Message: 3
Date: Fri, 9 May 2003 07:28:51 GMT
From: amapy at snafu.de
Subject: Re: [python-win32] python and COM - in particular Visual
	SourceSafe
To: Tony Cappellini <tony at tcapp.com>
Cc: python-win32 at python.org
Message-ID: <E19E2JH-0003tC-00 at smart.eusc.inter.net>

> Hello Andreas,

Hi Tony,

>
> I use VB at my work, and I'mjust starting to use Python.

That's a good idea.

>
> I haven't tried accessing VSS yet- but now that you've shown me how, I
> want t try it.
> What does the makepy- utility do-that you mention below ?
>
> thanks
> tony

I'm not a theoretical specialist for the COM-technology, but
makepy genearates the file 78CD4E0-9D54-11CF-B8EE-00608CC9A71Fx0x5x1.py
under Lib\site-packages\win32com\gen_py where all constants,
methods and properties of the SSAPI.DLL (the SourceSafe type library)
are listed. In the pythonwin-IDE (Many thanks to Mark Hammond) autocomplete
does work fine after generating this file like the MS-IDE.
The expected method I need will be listed in this way:

# Result is of type IVSSItem
# The method GetVersion is actually a property, but must be used as a method
to
correctly pass the arguments
def GetVersion(self, Version=defaultNamedOptArg):
    ret = self._oleobj_.InvokeTypes(0x18, LCID, 2, (9, 0),
((12,17),),Version)
    if ret is not None: ret = win32com.client.Dispatch
(ret, 'GetVersion', '{2A0DE0E7-2E9F-11D0-9236-00AA00A1EB95}',
UnicodeToString=0)
    return ret

(The mail-program will give the sequence maybe a wrong format)

Considere that oVSSItem is a object of type IVSSItem. I can get any
version of this item like this:

ThisVersion = oVSSItem.GetVersion(<SomeLabel>)

The problem I have is, that the method GetVersion will not appear in the
object catalog of VB.

Why I can see .GetVersion in the makepy-file ?

regards

Andi





------------------------------

Message: 4
Date: Fri, 9 May 2003 03:17:57 -0700 (PDT)
From: ET Planet <email2et at yahoo.com>
Subject: RE: [python-win32] Conflicts with Python
To: mcfadden at ford-consulting.com, Python-win32 at python.org
Message-ID: <20030509101757.49346.qmail at web20208.mail.yahoo.com>
Content-Type: text/plain; charset="us-ascii"

I wrote a GUI using Tkinter and was trying to open simple applications like
the Notepad program or Net Send in it.  However, whenever I run it, the
screen blacks out.  Upon installing it on another PC, it works. Hence, I
wonder if there was any conflicting file that I may have unknowingly on the
troubled PC.

Dudley McFadden <mcfadden at ford-consulting.com> wrote:
On occasion I have similar behavior when using DDE (Dynamic Data Exchange).
Either pythonwin or another application blocks until the other completes
some operation. Perhaps you are simultaneously running some other program
that is doing its DDE operations "impolitely." I have not taken the time to
identify the root cause of my problem, but it only comes up when I am
dealing with DDE. ET Planet, please post details of what exactly you are
doing when you say, "did an external .exe call." Okay?

--dudley
_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mail.python.org/pipermail/python-win32/attachments/20030509/10faa6e8/
attachment-0001.htm

------------------------------

Message: 5
Date: Fri, 9 May 2003 08:08:24 -0400
From: "Scott Prive" <scottprive at earthlink.net>
Subject: Re: [python-win32] Conflicts with Python
To: "ET Planet" <email2et at yahoo.com>, <mcfadden at ford-consulting.com>,
	<Python-win32 at python.org>
Message-ID: <027b01c31623$b334e340$0601a8c0 at scottprive.com>
Content-Type: text/plain; charset="iso-8859-1"

Works on one PC but not another, and it's the same code?

But the first thing I would do is examine the differences between the two
systems: same Python, same Tk version, same OS version of Windows?

On the computer that blacks out, any special background software like virus
scanner or system security? (You might not even know what's running, if it's
corporate software that hides itself from the Task Manager).

What if your example code was one of the example Tk or app-running examples
from the documentation? Did they work OK?

Obviously I'm doing some guessing here... I can't see what might cause this,
but my first suspicion based on your description is system-specific.

Lastly, it might help to trim your application to the fewest number of lines
to reproduce the problem. That may uncover detail, and give us something to
test with.

Hope this helps,

-Scott

  ----- Original Message -----
  From: ET Planet
  To: mcfadden at ford-consulting.com ; Python-win32 at python.org
  Sent: Friday, May 09, 2003 6:17 AM
  Subject: RE: [python-win32] Conflicts with Python


  I wrote a GUI using Tkinter and was trying to open simple applications
like the Notepad program or Net Send in it.  However, whenever I run it, the
screen blacks out.  Upon installing it on another PC, it works. Hence, I
wonder if there was any conflicting file that I may have unknowingly on the
troubled PC.

  Dudley McFadden <mcfadden at ford-consulting.com> wrote:
    On occasion I have similar behavior when using DDE (Dynamic Data
Exchange). Either pythonwin or another application blocks until the other
completes some operation. Perhaps you are simultaneously running some other
program that is doing its DDE operations "impolitely." I have not taken the
time to identify the root cause of my problem, but it only comes up when I
am dealing with DDE. ET Planet, please post details of what exactly you are
doing when you say, "did an external .exe call." Okay?

    --dudley

    _______________________________________________
    Python-win32 mailing list
    Python-win32 at python.org
    http://mail.python.org/mailman/listinfo/python-win32



----------------------------------------------------------------------------
--
  Do you Yahoo!?
  The New Yahoo! Search - Faster. Easier. Bingo.


----------------------------------------------------------------------------
--


  _______________________________________________
  Python-win32 mailing list
  Python-win32 at python.org
  http://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mail.python.org/pipermail/python-win32/attachments/20030509/85a8a9df/
attachment-0001.htm

------------------------------

_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


End of Python-win32 Digest, Vol 2, Issue 8
******************************************





More information about the Python-win32 mailing list