From sophia_han@hp.com Fri Aug 3 23:20:30 2001 From: sophia_han@hp.com (HAN,SOPHIA (HP-Roseville,ex1)) Date: Fri, 3 Aug 2001 18:20:30 -0400 Subject: [python-win32] MAC Address Message-ID: <028FE7141C79D511B65100D0B74FE87501087FBB@xrose01.rose.hp.com> Is there a way to find the computer's MAC address on a Win2k machine? From jens.jorgensen@tallan.com Sat Aug 4 00:51:36 2001 From: jens.jorgensen@tallan.com (Jorgensen, Jens) Date: Fri, 03 Aug 2001 18:51:36 -0500 Subject: [python-win32] MAC Address References: <028FE7141C79D511B65100D0B74FE87501087FBB@xrose01.rose.hp.com> Message-ID: <3B6B3908.4080207@tallan.com> I don't believe so, not through the Winsock api anyway. Windows XP is supposed to support raw sockets so I imagine you could use a WSAIoctl for that. I did it on another project in NT4 by digging through the registry under HKLM\SYSTEM\CurrentControlSet\Services for the adapter information but I think our solution wasn't going to work for any adapter--in our case the computers were identical more or less and all had the same network adapter in them. HAN,SOPHIA (HP-Roseville,ex1) wrote: >Is there a way to find the computer's MAC address on a Win2k machine? > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com From ueck@net-labs.de Tue Aug 7 19:48:12 2001 From: ueck@net-labs.de (Ulrich Eck) Date: Tue, 7 Aug 2001 20:48:12 +0200 Subject: [python-win32] Bug or Feature ??? working with floats under win32 Message-ID: <005801c11f71$82d1af30$3300000a@work01> This is a multi-part message in MIME format. ------=_NextPart_000_0055_01C11F82.464E4A30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi out there, I have this problem: >>> f =3D 4.23452345 >>> round(f,1) 4.2000000000000002 under win32 using: PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on = win32. Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see = 'Help/About PythonWin' for further copyright information. this version .. has anyone had this as well ..=20 same works fine using python2.1 under linux: >>> f =3D 4.112345234 >>> round(f,1) 4.1 thanks for your comments Ulrich Eck net-labs ------=_NextPart_000_0055_01C11F82.464E4A30 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi out there,
 
I have this problem:
 
>>> f =3D = 4.23452345
>>>=20 round(f,1)
4.2000000000000002
 
under win32 using:
 
PythonWin 2.1 (#15, Apr 16 2001, = 18:25:49) [MSC 32=20 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see = 'Help/About=20 PythonWin' for further copyright information.
this version ..
 
has anyone had this as well .. =
 
same works fine using python2.1 = under=20 linux:
>>> f =3D = 4.112345234
>>>=20 round(f,1)
4.1
 
thanks for your comments
 
Ulrich Eck
net-labs
------=_NextPart_000_0055_01C11F82.464E4A30-- From Jim.Vickroy@noaa.gov Tue Aug 7 20:03:53 2001 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Tue, 07 Aug 2001 13:03:53 -0600 Subject: [python-win32] Bug or Feature ??? working with floats under win32 References: <005801c11f71$82d1af30$3300000a@work01> Message-ID: <3B703B98.3EC1DE5D@noaa.gov> --------------1D2BE02AF6E2CCB57A38CB28 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I'm unable to duplicate this behavior under Python 2.0 on a Win 2k platform. >>> f = 1.2345 >>> round(f,1) 1.2 >>> round(f,2) 1.23 >>> Ulrich Eck wrote: > Hi out there, I have this problem: >>> f = 4.23452345 > >>> round(f,1) > 4.2000000000000002 under win32 using: PythonWin 2.1 (#15, Apr 16 2001, > 18:25:49) [MSC 32 bit (Intel)] on win32. > Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - > see 'Help/About PythonWin' for further copyright information.this > version .. has anyone had this as well .. same works fine using > python2.1 under linux:>>> f = 4.112345234 > >>> round(f,1) > 4.1 thanks for your comments Ulrich Ecknet-labs --------------1D2BE02AF6E2CCB57A38CB28 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi,

I'm unable to duplicate this behavior under Python 2.0 on a Win 2k platform.

>>> f = 1.2345
>>> round(f,1)
1.2
>>> round(f,2)
1.23
>>>
 

Ulrich Eck wrote:

Hi out there, I have this problem: >>> f = 4.23452345
>>> round(f,1)
4.2000000000000002 under win32 using: PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 'Help/About PythonWin' for further copyright information.this version .. has anyone had this as well .. same works fine using python2.1 under linux:>>> f = 4.112345234
>>> round(f,1)
4.1 thanks for your comments Ulrich Ecknet-labs
--------------1D2BE02AF6E2CCB57A38CB28-- From ueck@net-labs.de Tue Aug 7 20:36:51 2001 From: ueck@net-labs.de (Ulrich Eck) Date: Tue, 7 Aug 2001 21:36:51 +0200 Subject: [python-win32] Bug or Feature ??? working with floats under win32 References: <005801c11f71$82d1af30$3300000a@work01> <3B703B98.3EC1DE5D@noaa.gov> Message-ID: <008c01c11f78$4ea41fc0$3300000a@work01> thanks for you reply: mine is a win2k-ws too .. the date of the installer is 01.06.2001 (Python-2.1.exe and win32all-139) thats probably the date of download .. don't know if this helps .. cheers Ulrich Eck Hi, I'm unable to duplicate this behavior under Python 2.0 on a Win 2k platform. >>> f = 1.2345 >>> round(f,1) 1.2 >>> round(f,2) 1.23 >>> From jens.jorgensen@tallan.com Tue Aug 7 21:06:02 2001 From: jens.jorgensen@tallan.com (Jorgensen, Jens) Date: Tue, 07 Aug 2001 15:06:02 -0500 Subject: [python-win32] Bug or Feature ??? working with floats under win32 References: <005801c11f71$82d1af30$3300000a@work01> Message-ID: <3B704A2A.4060408@tallan.com> I get the same result in Windows 2000 Pro with ActiveState Python 2.1: >>> sys.version '2.1 (#15, Jun 18 2001, 21:42:28) [MSC 32 bit (Intel)]' I tend to think this is not a bug though. Remember that in the floating point representation the decimal part is represented in base 2 so 2/10 is not actually possible. This is as close as it can get. The difference will be due to how str() is implemented on the two systems which is probably just done using printf("%f", ld) or similar. I'll bet that if you try: import struct struct.pack('f', (round(4,23452345, 1))) on both boxes you'll get the same thing on each. I don' t think that the docs for str() explicitly say exactly how double precision floats will be formatted so this is really neither bug nor feature just ambiguity. Ulrich Eck wrote: > Hi out there, > > > > I have this problem: > > > > >>> f = 4.23452345 > >>> round(f,1) > 4.2000000000000002 > > > > under win32 using: > > > > PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32. > Portions Copyright 1994-2001 Mark Hammond ( MarkH@ActiveState.com > ) - see 'Help/About PythonWin' for > further copyright information. > > this version .. > > > > has anyone had this as well .. > > > > same works fine using python2.1 under linux: > > >>> f = 4.112345234 > >>> round(f,1) > 4.1 > > > > thanks for your comments > > > > Ulrich Eck > > net-labs > -- Jens B. Jorgensen jens.jorgensen@tallan.com From ueck@net-labs.de Tue Aug 7 21:41:13 2001 From: ueck@net-labs.de (Ulrich Eck) Date: Tue, 7 Aug 2001 22:41:13 +0200 Subject: [python-win32] working with floats References: <005801c11f71$82d1af30$3300000a@work01> <3B704A2A.4060408@tallan.com> Message-ID: <000701c11f81$4cc05580$6600000a@netlabs.local> > > import struct > struct.pack('f', (round(4,23452345, 1))) > > on both boxes you'll get the same thing on each. I don' t think that the > docs for str() explicitly say exactly how double precision floats will > be formatted so this is really neither bug nor feature just ambiguity. > ok the problem is not the platform but the actual float (see below) how can i mathematically correct get a float with 2 decimals without going through a "%.2f" with all my numbers ?? thanks for your answer Ulrich Eck see the difference in my examples .. WIN: > > >>> f = 4.23452345 > > >>> round(f,1) > > 4.2000000000000002 LINUX: > > >>> f = 4.112345234 > > >>> round(f,1) > > 4.1 I used different random floats to test .. I know have tried it on both with the same and there is the same result actually. WIN: PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> f = 4.2345234534 >>> round(f,2) 4.2300000000000004 >>> import struct >>> struct.pack('f',(round(f,1))) 'ff\x86@' LINUX: Python 2.1.1 (#1, Aug 5 2001, 18:08:07) [GCC 2.95.3 20010315 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> f = 4.2345234534 >>> round(f,2) 4.2300000000000004 >>> import struct >>> struct.pack('f',(round(f,1))) 'ff\x86@' From kochmar@psc.edu Tue Aug 7 21:54:57 2001 From: kochmar@psc.edu (John Kochmar) Date: Tue, 07 Aug 2001 16:54:57 -0400 Subject: [python-win32] working with floats In-Reply-To: Your message of "Tue, 07 Aug 2001 22:41:13 +0200." <000701c11f81$4cc05580$6600000a@netlabs.local> Message-ID: <200108072054.f77KsvF06230@imp.psc.edu> |> |> import struct |> struct.pack('f', (round(4,23452345, 1))) |> |> on both boxes you'll get the same thing on each. I don' t think that the |> docs for str() explicitly say exactly how double precision floats will |> be formatted so this is really neither bug nor feature just ambiguity. |> | |ok the problem is not the platform but the actual float (see below) ... The problem might not be the platform as much as the version of Python... imp:~ python Python 1.5.2 (#1, Mar 3 2001, 01:35:43) [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> f = 4.112345234 >>> round(f,1) 4.1 >>> imp:~ python2 Python 2.1 (#1, Apr 21 2001, 18:56:55) [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 Type "copyright", "credits" or "license" for more information. >>> f = 4.112345234 >>> round(f,1) 4.0999999999999996 >>> Both were done on my Linux box moments ago. John -- John Kochmar kochmar@psc.edu PSC Advanced Systems MI 409F, x8-6509 http://www.psc.edu/~kochmar From jens.jorgensen@tallan.com Tue Aug 7 22:16:39 2001 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Tue, 07 Aug 2001 16:16:39 -0500 Subject: [python-win32] Re: working with floats References: <005801c11f71$82d1af30$3300000a@work01> <3B704A2A.4060408@tallan.com> <000701c11f81$4cc05580$6600000a@netlabs.local> Message-ID: <3B705AB7.8050903@tallan.com> Ulrich Eck wrote: >>import struct >>struct.pack('f', (round(4,23452345, 1))) >> >>on both boxes you'll get the same thing on each. I don' t think that the >>docs for str() explicitly say exactly how double precision floats will >>be formatted so this is really neither bug nor feature just ambiguity. >> > >ok the problem is not the platform but the actual float (see below) > >how can i mathematically correct get a float with 2 decimals >without going through a "%.2f" with all my numbers ?? > Unfortunately I think the answer is: you can't. Note that strictly speaking 4.2000000000000002 is the more correct answer. This may be counterintuitive since you would expect the round() function to return you a number such that the resulting number from found(4.23452345, 1) should in any case never be more than 4.2. However, if you consider that ieee 64-bit float is only capable of representing a finite set of numbers in the space of rational numbers then you would probably try to establish a rule regarding operations upon these numbers such that the result of any operation should be as accurate as possible, ie. abs(the_real_number - what number_we_can_represent) should be as small as possible. I haven't looked at any of the formal rules but I'm guessing this is one of them. (You can probably buy a giant book that describes all such rules from IEEE.) The more pertinent observation is that even when linux is printing '4.2' from round(f, 1) the answer you're getting *is* the same the only difference is the implementation of str() on each platform. This is what I was trying to point out by demonstrating that is you use struct.pack on both results you then see the same output since struct will give you the binary representation of the number. So: the answer is that if you have a float and you want to print no more then 2 decimal places you must always use %.2f. I know this is kind of a bogus answer but there you have it. You may be interested to note that if you're dealing with currencies or some such thing where fractional values beyond a certain decimal place don't make sense then you may want to use a fixed-decimal package. There's one at the Vaults of Parnassus that does this that I've used. >thanks for your answer > You're most welcome. >Ulrich Eck > >see the difference in my examples .. >WIN: > >>>>>>f = 4.23452345 >>>>>>round(f,1) >>>>>> >>>4.2000000000000002 >>> >LINUX: > >>>>>>f = 4.112345234 >>>>>>round(f,1) >>>>>> >>>4.1 >>> > >I used different random floats to test .. I know have tried it on >both with the same and there is the same result actually. > >WIN: >PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32. >Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 'Help/About PythonWin' for >further copyright information. > >>>>f = 4.2345234534 >>>>round(f,2) >>>> >4.2300000000000004 > >>>>import struct >>>>struct.pack('f',(round(f,1))) >>>> >'ff\x86@' > >LINUX: >Python 2.1.1 (#1, Aug 5 2001, 18:08:07) >[GCC 2.95.3 20010315 (release)] on linux2 >Type "copyright", "credits" or "license" for more information. > >>>>f = 4.2345234534 >>>>round(f,2) >>>> >4.2300000000000004 > >>>>import struct >>>>struct.pack('f',(round(f,1))) >>>> >'ff\x86@' > > > -- Jens B. Jorgensen jens.jorgensen@tallan.com From john@hopkinsit.com Sun Aug 12 03:38:02 2001 From: john@hopkinsit.com (John Hopkins) Date: Sat, 11 Aug 2001 19:38:02 -0700 Subject: [python-win32] ini File Management with win32ui Message-ID: <006601c122d7$cf4a2360$01000059@hopkinsmain> This is a multi-part message in MIME format. ------=_NextPart_000_0063_01C1229D.222C4120 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I need to manage an ini file on Win2k and NT4. After reading in the = archives and the documentation I tried to use ConfigParser with the = followinfg results: >>> import ConfigParser >>> p =3D ConfigParser.ConfigParser() Traceback (most recent call last): File "", line 1, in ? TypeError: object is not callable: According to PythonWin's About box, I'm using ActivePython build = 2.1.211. Any help will be greatly appreciated. Thanks in advance, John ------=_NextPart_000_0063_01C1229D.222C4120 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I need to manage an ini file on Win2k = and=20 NT4.  After reading in the archives and the documentation I tried = to=20 use ConfigParser with the followinfg results:
 
>>> import = ConfigParser
>>> p=20 =3D ConfigParser.ConfigParser()
Traceback (most recent call = last):
 =20 File "<interactive input>", line 1, in ?
TypeError: object is = not=20 callable: <module 'ConfigParser' from = 'ConfigParser.py'>
According to PythonWin's About box, I'm = using=20 ActivePython build 2.1.211.
 
Any help will be greatly = appreciated.
 
Thanks in advance,
 
John
 
------=_NextPart_000_0063_01C1229D.222C4120-- From robinjim@earthlink.net Sun Aug 12 12:48:34 2001 From: robinjim@earthlink.net (robin and jim) Date: Sun, 12 Aug 2001 05:48:34 -0600 Subject: [python-win32] ini File Management with win32ui References: <006601c122d7$cf4a2360$01000059@hopkinsmain> Message-ID: <000b01c12324$bbd0c260$f2acbfa8@robinjim> This is a multi-part message in MIME format. ------=_NextPart_000_0008_01C122F2.6CB1B4A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello John, I suppose this does not help much, but here is the result on my Win 98 = system with Python 2.0: PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see = 'Help/About PythonWin' for further copyright information. >>> import ConfigParser >>> p =3D ConfigParser.ConfigParser() >>> dir (p) ['_ConfigParser__defaults', '_ConfigParser__sections'] >>>=20 If you do not get any responses before then, I will try this tomorrow = when I have access to a Win 2k system. ----- Original Message -----=20 From: John Hopkins=20 To: python-win32@python.org ; activepython@listserv.ActiveState.com=20 Sent: Saturday, August 11, 2001 8:38 PM Subject: [python-win32] ini File Management with win32ui I need to manage an ini file on Win2k and NT4. After reading in the = archives and the documentation I tried to use ConfigParser with the = followinfg results: >>> import ConfigParser >>> p =3D ConfigParser.ConfigParser() Traceback (most recent call last): File "", line 1, in ? TypeError: object is not callable: According to PythonWin's About box, I'm using ActivePython build = 2.1.211. Any help will be greatly appreciated. Thanks in advance, John ------=_NextPart_000_0008_01C122F2.6CB1B4A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello John,
 
I suppose this does not help = much, but=20 here is the result on my Win 98 system with Python 2.0:
 
PythonWin 2.0 (#8, Oct 16 = 2000, 17:27:58)=20 [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark = Hammond (MarkH@ActiveState.com) - see = 'Help/About=20 PythonWin' for further copyright information.
>>> import=20 ConfigParser
>>> p =3D = ConfigParser.ConfigParser()
>>> dir=20 (p)
['_ConfigParser__defaults', = '_ConfigParser__sections']
>>>=20
 
If you do not get any = responses before=20 then, I will try this tomorrow when I have access to a Win 2k=20 system.
----- Original Message -----
From:=20 John = Hopkins=20
To: python-win32@python.org ; = activepython@listse= rv.ActiveState.com=20
Sent: Saturday, August 11, 2001 = 8:38=20 PM
Subject: [python-win32] ini = File=20 Management with win32ui

I need to manage an ini file on Win2k = and=20 NT4.  After reading in the archives and the documentation I tried = to=20 use ConfigParser with the followinfg results:
 
>>> import = ConfigParser
>>>=20 p =3D ConfigParser.ConfigParser()
Traceback (most recent call=20 last):
  File "<interactive input>", line 1, in = ?
TypeError:=20 object is not callable: <module 'ConfigParser' from=20 'ConfigParser.py'>
According to PythonWin's About box, = I'm using=20 ActivePython build 2.1.211.
 
Any help will be greatly=20 appreciated.
 
Thanks in advance,
 
John
 
------=_NextPart_000_0008_01C122F2.6CB1B4A0-- From myself@robballen.com Mon Aug 13 20:04:43 2001 From: myself@robballen.com (Robb Allen) Date: Mon, 13 Aug 2001 15:04:43 -0400 Subject: [python-win32] New python user - first question Message-ID: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> I'm new to Python. Been running with it for a whopping 4 days. I come from a background using VBScript and Java and have found Python to potentially solve some problems I've encountered. Just trying to get a basic web page up through IIS and am having a what I am sure to be a newbie issue, but it's the one thing I can't seem to fix. I have a page on a web site called "test.py". test.py looks like this def foo(a): return a Then, the asp page looks like this <%@ LANGUAGE = Python %> <% import test test.foo('hello') %> When I run it, I get "AttributeError: 'test' module has no attribute 'foo'" Reeeeal simple, but I'm missing something. Anyone care to poke fun at the newbie? R From Jim Abrams Mon Aug 13 20:08:45 2001 From: Jim Abrams (Jim Abrams) Date: Mon, 13 Aug 2001 15:08:45 -0400 Subject: [python-win32] New python user - first question In-Reply-To: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> References: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> Message-ID: <1068505550.20010813150845@publishingresources.com> No poking fun here, one time I spent 2 days trying to uncover very strange bugs in my test.py module. Then someone let me onto the hint that python has a built in module named test. As soon as I renamed my module to something else all worked fine. -- Jim Abrams RA> I'm new to Python. Been running with it for a whopping 4 days. I come from a RA> background using VBScript and Java and have found Python to potentially RA> solve some problems I've encountered. RA> Just trying to get a basic web page up through IIS and am having a what I am RA> sure to be a newbie issue, but it's the one thing I can't seem to fix. I RA> have a page on a web site called "test.py". test.py looks like this RA> def foo(a): RA> return a RA> Then, the asp page looks like this RA> <%@ LANGUAGE = Python %> RA> <% RA> import test RA> test.foo('hello') %>> RA> When I run it, I get "AttributeError: 'test' module has no attribute 'foo'" RA> Reeeeal simple, but I'm missing something. Anyone care to poke fun at the RA> newbie? RA> R RA> _______________________________________________ RA> Python-win32 mailing list RA> Python-win32@python.org RA> http://mail.python.org/mailman/listinfo/python-win32 From myself@robballen.com Mon Aug 13 20:43:03 2001 From: myself@robballen.com (Robb Allen) Date: Mon, 13 Aug 2001 15:43:03 -0400 Subject: [python-win32] New python user - first question References: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> <1068505550.20010813150845@publishingresources.com> Message-ID: <000401c12430$2ba924e0$0301a8c0@hitchhiker.robballen.com> Yup. That was the problem. I knew it was relatively easy. Now, the problem I'm having is that I changed foo.py, but ASP doesn't recognize the change. It still assumes that the file has the same functions in it. How do I 'flush the cache' so to speak? R ----- Original Message ----- From: "Jim Abrams" To: "Robb Allen" Cc: Sent: Monday, August 13, 2001 3:08 PM Subject: Re: [python-win32] New python user - first question > > > No poking fun here, one time I spent 2 days trying to uncover very > strange bugs in my test.py module. > > Then someone let me onto the hint that python has a built in module named test. > As soon as I renamed my module to something else all worked fine. > > -- > Jim Abrams > > RA> I'm new to Python. Been running with it for a whopping 4 days. I come from a > RA> background using VBScript and Java and have found Python to potentially > RA> solve some problems I've encountered. > > RA> Just trying to get a basic web page up through IIS and am having a what I am > RA> sure to be a newbie issue, but it's the one thing I can't seem to fix. I > RA> have a page on a web site called "test.py". test.py looks like this > > RA> def foo(a): > RA> return a > > RA> Then, the asp page looks like this > > RA> <%@ LANGUAGE = Python %> > > RA> <% > RA> import test > > RA> test.foo('hello') > > %>> > > RA> When I run it, I get "AttributeError: 'test' module has no attribute 'foo'" > > RA> Reeeeal simple, but I'm missing something. Anyone care to poke fun at the > RA> newbie? > > RA> R > > > RA> _______________________________________________ > RA> Python-win32 mailing list > RA> Python-win32@python.org > RA> http://mail.python.org/mailman/listinfo/python-win32 From Jim Abrams Mon Aug 13 21:02:44 2001 From: Jim Abrams (Jim Abrams) Date: Mon, 13 Aug 2001 16:02:44 -0400 Subject: Re[2]: [python-win32] New python user - first question In-Reply-To: <000401c12430$2ba924e0$0301a8c0@hitchhiker.robballen.com> References: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> <1068505550.20010813150845@publishingresources.com> <000401c12430$2ba924e0$0301a8c0@hitchhiker.robballen.com> Message-ID: <16811744147.20010813160244@publishingresources.com> You'll need to explicitly reload the module. reload(module) What seems to be a popular way of doing it is to put all the reload statements into 1 file and run that file when you want to refresh all your custom modules. Restarting your web service will do it as well. -- Jim Abrams RA> Yup. That was the problem. I knew it was relatively easy. RA> Now, the problem I'm having is that I changed foo.py, but ASP doesn't RA> recognize the change. It still assumes that the file has the same functions RA> in it. How do I 'flush the cache' so to speak? RA> R RA> ----- Original Message ----- RA> From: "Jim Abrams" RA> To: "Robb Allen" RA> Cc: RA> Sent: Monday, August 13, 2001 3:08 PM RA> Subject: Re: [python-win32] New python user - first question >> >> >> No poking fun here, one time I spent 2 days trying to uncover very >> strange bugs in my test.py module. >> >> Then someone let me onto the hint that python has a built in module named RA> test. >> As soon as I renamed my module to something else all worked fine. >> >> -- >> Jim Abrams >> >> RA> I'm new to Python. Been running with it for a whopping 4 days. I come RA> from a >> RA> background using VBScript and Java and have found Python to RA> potentially >> RA> solve some problems I've encountered. >> >> RA> Just trying to get a basic web page up through IIS and am having a RA> what I am >> RA> sure to be a newbie issue, but it's the one thing I can't seem to fix. RA> I >> RA> have a page on a web site called "test.py". test.py looks like this >> >> RA> def foo(a): >> RA> return a >> >> RA> Then, the asp page looks like this >> >> RA> <%@ LANGUAGE = Python %> >> >> RA> <% >> RA> import test >> >> RA> test.foo('hello') >> >> %>> >> >> RA> When I run it, I get "AttributeError: 'test' module has no attribute RA> 'foo'" >> >> RA> Reeeeal simple, but I'm missing something. Anyone care to poke fun at RA> the >> RA> newbie? >> >> RA> R >> >> >> RA> _______________________________________________ >> RA> Python-win32 mailing list >> RA> Python-win32@python.org >> RA> http://mail.python.org/mailman/listinfo/python-win32 RA> _______________________________________________ RA> Python-win32 mailing list RA> Python-win32@python.org RA> http://mail.python.org/mailman/listinfo/python-win32 From john@hopkinsit.com Tue Aug 14 05:55:58 2001 From: john@hopkinsit.com (John Hopkins) Date: Mon, 13 Aug 2001 21:55:58 -0700 Subject: [python-win32] Didja Know (was ini File Management with win32ui ) References: <006601c122d7$cf4a2360$01000059@hopkinsmain> <000b01c12324$bbd0c260$f2acbfa8@robinjim> Message-ID: <003401c1247d$69671600$01000059@hopkinsmain> This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C12442.BC19E660 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks to all for the help; I finally stumbled into the solution. Didja know that it's a bad idea to name a python script file which = imports ConfigParser, "ConfigParser.py"? Yeah, I did too, but I wasn't = thinking clearly. Oh, well, I guess I'll remember for a while now. John ----- Original Message -----=20 From: robin and jim=20 To: John Hopkins ; python-win32@python.org ; = activepython@listserv.ActiveState.com=20 Sent: Sunday, August 12, 2001 4:48 AM Subject: Re: [python-win32] ini File Management with win32ui Hello John, =20 I suppose this does not help much, but here is the result on my Win 98 = system with Python 2.0: =20 PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on = win32. Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - = see 'Help/About PythonWin' for further copyright information. >>> import ConfigParser >>> p =3D ConfigParser.ConfigParser() >>> dir (p) ['_ConfigParser__defaults', '_ConfigParser__sections'] >>>=20 =20 If you do not get any responses before then, I will try this tomorrow = when I have access to a Win 2k system. ----- Original Message -----=20 From: John Hopkins=20 To: python-win32@python.org ; activepython@listserv.ActiveState.com=20 Sent: Saturday, August 11, 2001 8:38 PM Subject: [python-win32] ini File Management with win32ui I need to manage an ini file on Win2k and NT4. After reading in the = archives and the documentation I tried to use ConfigParser with the = followinfg results: >>> import ConfigParser >>> p =3D ConfigParser.ConfigParser() Traceback (most recent call last): File "", line 1, in ? TypeError: object is not callable: According to PythonWin's About box, I'm using ActivePython build = 2.1.211. =20 Any help will be greatly appreciated. Thanks in advance, John ------=_NextPart_000_0031_01C12442.BC19E660 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thanks to all for the help; I finally = stumbled into=20 the solution.
 
Didja know that it's a bad idea to name = a python=20 script file which imports ConfigParser, "ConfigParser.py"?  Yeah, I = did=20 too, but I wasn't thinking clearly.
 
Oh, well, I guess I'll remember for a = while=20 now.
 
John
 
----- Original Message -----
From:=20 robin and=20 jim
To: John Hopkins ; python-win32@python.org ; activepython@listserv.Activ= eState.com=20
Sent: Sunday, August 12, 2001 = 4:48=20 AM
Subject: Re: [python-win32] ini = File=20 Management with win32ui

Hello John,
 
I suppose this does not = help much, but=20 here is the result on my Win 98 system with Python 2.0:
 
PythonWin 2.0 (#8, Oct 16 = 2000,=20 17:27:58) [MSC 32 bit (Intel)] on win32.
Portions Copyright = 1994-2001 Mark=20 Hammond (MarkH@ActiveState.com) -=20 see 'Help/About PythonWin' for further copyright = information.
>>>=20 import ConfigParser
>>> p =3D=20 ConfigParser.ConfigParser()
>>> dir=20 (p)
['_ConfigParser__defaults', = '_ConfigParser__sections']
>>>=20
 
If you do not get any = responses before=20 then, I will try this tomorrow when I have access to a Win 2k=20 system.
----- Original Message -----
From:=20 John=20 Hopkins
To: python-win32@python.org ; activepython@listserv.Activ= eState.com=20
Sent: Saturday, August 11, = 2001 8:38=20 PM
Subject: [python-win32] ini = File=20 Management with win32ui

I need to manage an ini file on = Win2k and=20 NT4.  After reading in the archives and the documentation I = tried to=20 use ConfigParser with the followinfg results:
 
>>> import=20 ConfigParser
>>> p =3D = ConfigParser.ConfigParser()
Traceback=20 (most recent call last):
  File "<interactive input>", = line 1,=20 in ?
TypeError: object is not callable: <module 'ConfigParser' = from=20 'ConfigParser.py'>
According to PythonWin's About box, = I'm using=20 ActivePython build 2.1.211.
 
Any help will be greatly=20 appreciated.
 
Thanks in advance,
 
John
 
------=_NextPart_000_0031_01C12442.BC19E660-- From myself@robballen.com Tue Aug 14 17:50:08 2001 From: myself@robballen.com (Robb Allen) Date: Tue, 14 Aug 2001 12:50:08 -0400 Subject: [python-win32] Response.Write / Print Message-ID: <006701c124e1$2ec57aa0$0301a8c0@hitchhiker.robballen.com> This is a multi-part message in MIME format. ------=_NextPart_000_0064_01C124BF.A64B49F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How can I override the print method to work as Response.Write in ASP? I = really want to be able to use my scripts in multiple places,not just on = the web server. If this can't be done, what variable can I examine to determine where = the script is being run so I know what to call? Thanks R ------=_NextPart_000_0064_01C124BF.A64B49F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
How can I override the print method to = work as=20 Response.Write in ASP? I really want to be able to use my scripts in = multiple=20 places,not just on the web server.
 
If this can't be done, what variable = can I examine=20 to determine where the script is being run so I know what to call?=20 Thanks
 
R
------=_NextPart_000_0064_01C124BF.A64B49F0-- From Jim Abrams Tue Aug 14 18:03:17 2001 From: Jim Abrams (Jim Abrams) Date: Tue, 14 Aug 2001 13:03:17 -0400 Subject: [python-win32] Response.Write / Print In-Reply-To: <006701c124e1$2ec57aa0$0301a8c0@hitchhiker.robballen.com> References: <006701c124e1$2ec57aa0$0301a8c0@hitchhiker.robballen.com> Message-ID: <5187376370.20010814130317@publishingresources.com> RA> How can I override the print method to work as Response.Write in RA> ASP? Two different things here. First, getting the Print state to work in ASP is tricky, here are some hints. First, you can't use the regular print statement, and here's why. I'm not %100 sure of myself here so if anyone seems me err, please correct. The print statement sends data to sys.stdout by default. However, python in ASP caches all modules, on an application level scope, so sys.stdout is shared by every script on your website. However, in order for the webserver to know where to send data back to the client, it must have a unique filehandle (or some similar object) for each page request. Trying to set something to sys.stdout might appear to work, but actually will break as soon as you start to get simultaneous requests. (I actually had data from page 1 appears on page 2 when I requested both at the same time.) What you need to do is get some page level scope variable, stick an object in it that maps print to Response.Write, and use the augmented print. Here's what I do. from win32com.axscript.client.framework import SafeOutput _out = SafeOutput(Response) Then I use print >> _out, stuff I stuck the code in an include file that gets included on every page. Tiresome but after set up works very nicely. RA> I really want to be able to use my scripts in multiple RA> places,not just on the web server. After that you can always assign sys.stdout to _out to get the right behavior if you're not running the script from ASP. Actually I faintly remember that if _out is None, it will go to stdout too. But don't quote me. RA> If this can't be done, what variable can I examine to determine RA> where the script is being run so I know what to call? Thanks Not sure here, I suppose you could look for the existence of Response, Request, etc, ASP's built in objects to see if they are defined, but that feels icky to me. Someone must know a better way. And whoever that is, might you know how to tell the difference between IIS's main thread of execution and other worker threads? -- Jim Abrams From jens.jorgensen@tallan.com Tue Aug 14 19:03:36 2001 From: jens.jorgensen@tallan.com (Jorgensen, Jens) Date: Tue, 14 Aug 2001 13:03:36 -0500 Subject: [python-win32] New python user - first question References: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> <1068505550.20010813150845@publishingresources.com> <000401c12430$2ba924e0$0301a8c0@hitchhiker.robballen.com> Message-ID: <3B7967F8.2070109@tallan.com> As Jim mentioned the reload will of course work. I would add though that the canonical method would be to get IIS to unload the application. This way you can administratively get the same affect without paying for it each time your ASP is hit. Go to the Inet. Admin MMC snap-in, select the Properties for the virtual directory where your script is installed, select the Virtual Directory (or Home Directory, depending) tab, find the button that says Unload and hit it. This will unload the interpreter out of memory causing it to naturally reload the module the next time your asp runs. Robb Allen wrote: >Yup. That was the problem. I knew it was relatively easy. > >Now, the problem I'm having is that I changed foo.py, but ASP doesn't >recognize the change. It still assumes that the file has the same functions >in it. How do I 'flush the cache' so to speak? > >R > >----- Original Message ----- >From: "Jim Abrams" >To: "Robb Allen" >Cc: >Sent: Monday, August 13, 2001 3:08 PM >Subject: Re: [python-win32] New python user - first question > > >> >>No poking fun here, one time I spent 2 days trying to uncover very >>strange bugs in my test.py module. >> >>Then someone let me onto the hint that python has a built in module named >> >test. > >>As soon as I renamed my module to something else all worked fine. >> >>-- >>Jim Abrams >> >>RA> I'm new to Python. Been running with it for a whopping 4 days. I come >> >from a > >>RA> background using VBScript and Java and have found Python to >> >potentially > >>RA> solve some problems I've encountered. >> >>RA> Just trying to get a basic web page up through IIS and am having a >> >what I am > >>RA> sure to be a newbie issue, but it's the one thing I can't seem to fix. >> >I > >>RA> have a page on a web site called "test.py". test.py looks like this >> >>RA> def foo(a): >>RA> return a >> >>RA> Then, the asp page looks like this >> >>RA> <%@ LANGUAGE = Python %> >> >>RA> <% >>RA> import test >> >>RA> test.foo('hello') >> >>%>> >> >>RA> When I run it, I get "AttributeError: 'test' module has no attribute >> >'foo'" > >>RA> Reeeeal simple, but I'm missing something. Anyone care to poke fun at >> >the > >>RA> newbie? >> >>RA> R >> >> >>RA> _______________________________________________ >>RA> Python-win32 mailing list >>RA> Python-win32@python.org >>RA> http://mail.python.org/mailman/listinfo/python-win32 >> > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com From Jim Abrams Tue Aug 14 19:10:04 2001 From: Jim Abrams (Jim Abrams) Date: Tue, 14 Aug 2001 14:10:04 -0400 Subject: Re[2]: [python-win32] New python user - first question In-Reply-To: <3B7967F8.2070109@tallan.com> References: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> <1068505550.20010813150845@publishingresources.com> <000401c12430$2ba924e0$0301a8c0@hitchhiker.robballen.com> <3B7967F8.2070109@tallan.com> Message-ID: <8391382951.20010814141004@publishingresources.com> This is good info too, Jens do you know if there is a way to script this? Or write a batch file that would cause the application to Unload? Maybe some net service command? -- Jim Abrams JJ> As Jim mentioned the reload will of course work. I would add though that JJ> the canonical method would be to get IIS to unload the application. This JJ> way you can administratively get the same affect without paying for it JJ> each time your ASP is hit. Go to the Inet. Admin MMC snap-in, select the JJ> Properties for the virtual directory where your script is installed, JJ> select the Virtual Directory (or Home Directory, depending) tab, find JJ> the button that says Unload and hit it. This will unload the interpreter JJ> out of memory causing it to naturally reload the module the next time JJ> your asp runs. From jens.jorgensen@tallan.com Tue Aug 14 23:58:02 2001 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Tue, 14 Aug 2001 17:58:02 -0500 Subject: [python-win32] New python user - first question References: <000e01c1242a$d08136c0$0301a8c0@hitchhiker.robballen.com> <1068505550.20010813150845@publishingresources.com> <000401c12430$2ba924e0$0301a8c0@hitchhiker.robballen.com> <3B7967F8.2070109@tallan.com> <8391382951.20010814141004@publishingresources.com> Message-ID: <3B79ACFA.7060903@tallan.com> This is a multi-part message in MIME format. --------------090306060006080601090008 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Jim Abrams wrote: >This is good info too, Jens do you know if there is a way to script >this? Or write a batch file that would cause the application to >Unload? Maybe some net service command? > I'm glad you asked! In fact there is a way to script this. IIS can be administered completely through the ADSI interface. That is to say: anything you can do with the MMC snap-in you can do through a COM interface. In fact I think there are a few things you can do only through the ADSI interface. ADSI itself is something bigger than IIS. It let's you do things to the active directory, let's you find out things about your system, and all kinds of interesting stuff. See the MSDN library for more details. More to your question at hand, I'm sure what you're looking for is a quick way to have your application unloaded since during development this is frequently necessary. The snap-in isn't that fast since the Unload button greys out after you click it so you have to cancel the property page and then re right-click on the virtual directory and select Properties. So, I wrote myself a little script. Then I decided I wanted a little gui so I could just push a button so I wrote a GUI using wxWindows. I've attached both versions. You'll see that doing this is *very* simple. Note that in my moniker 'IIS://tallan2/w3svc/1/Root/iPaymentBackend' tallan2 is my machine name, and the w3svc represents the www service and 1 is the instance. Root is just the base root for all documents and my virtual directory lives just under that. Note: I stripped out some stuff that wouldn't apply here from my GUI script and I don't have wxWindows installed at the moment because I upgraded my Python so the GUI script might not work as is. You get the idea though. -- Jens B. Jorgensen jens.jorgensen@tallan.com --------------090306060006080601090008 Content-Type: text/plain; name="appunload.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="appunload.py" import win32com.client vdir = win32com.client.GetObject('IIS://tallan2/w3svc/1/Root/iPaymentBackend') vdir.AppUnload() --------------090306060006080601090008 Content-Type: text/plain; name="appunloadwin-min.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="appunloadwin-min.py" from wxPython.wx import * import win32com.client #--------------------------------------------------------------------------- class MyFrame(wxFrame): def __init__(self, parent, ID, title, pos, size): wxFrame.__init__(self, parent, ID, title, pos, size) panel = wxPanel(self, -1) box = wxBoxSizer(wxVERTICAL) button = wxButton(panel, 1003, "App Unload") button.SetPosition(wxPoint(5, 5)) EVT_BUTTON(self, 1003, self.OnAppUnload) box.Add(button, 0, wxALL, 4) EVT_CLOSE(self, self.OnCloseWindow) panel.SetAutoLayout(1) panel.SetSizer(box) box.Fit(self) box.SetSizeHints(self) def OnAppUnload(self, event): vdir = win32com.client.GetObject('IIS://tallan2/w3svc/1/Root/iPaymentBackend') vdir.AppUnload() def OnCloseWindow(self, event): self.Destroy() #--------------------------------------------------------------------------- class MyApp(wxApp) : def OnInit(self) : self.frm = MyFrame(None, -1, "App Unload", wxDefaultPosition, wxSize(350, 200)) self.frm.Show(true) self.SetTopWindow(self.frm) return 1 app = MyApp(0) app.MainLoop() --------------090306060006080601090008-- From Richard.Cooper@youmeus.com Sun Aug 19 11:21:10 2001 From: Richard.Cooper@youmeus.com (Richard Cooper) Date: Sun, 19 Aug 2001 11:21:10 +0100 Subject: [python-win32] FW: COM server and compilation Message-ID: <49CCE87D4A3BD511B1C500D0B7B69C061D2FE1@EXCHANGE> Hi, Apoligies for sending this to two lists but they both seem relevant. I'm writing a COM service and am evaluating python as a language for doing so. I have no probems with COM itself so far, my problem is that the final code needs to be obfuscated. I've been experimenting with various methods of "compiling" python code (py2exe, squeeze, sqfreeze) but all of them seem to have problems with COM. The py2exe webpage (http://starship.python.net/crew/theller/py2exe/) says "py2exe has been used to create a standalone COM server exe-file, although this is currently in a very early stage" and "Allow local (dll) and inproc (exe) COM servers to be built" is a "future plan". Does anyone have any more information about this. More generally, can anyone help me to compile a COM server using one of the three packages I've mentioned or one I haven't yet come across. Thanks, Rich. From myself@robballen.com Tue Aug 21 12:48:13 2001 From: myself@robballen.com (Robb Allen) Date: Tue, 21 Aug 2001 07:48:13 -0400 Subject: [python-win32] Python and MS Index Server Message-ID: <001301c12a37$2950e5e0$0301a8c0@hitchhiker.robballen.com> This is a multi-part message in MIME format. ------=_NextPart_000_0010_01C12A15.A17406A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Anyone attempt connecting Python to Index Server? I'm trying to rework = my search pages for our corporate Intranet and thought maybe this is = where I could showcase Python and its ability to tie into COM. R ------=_NextPart_000_0010_01C12A15.A17406A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Anyone attempt connecting Python to = Index Server?=20 I'm trying to rework my search pages for our corporate Intranet and = thought=20 maybe this is where I could showcase Python and its ability to tie into=20 COM.
 
R
------=_NextPart_000_0010_01C12A15.A17406A0-- From itamarst@yahoo.com Wed Aug 22 21:49:26 2001 From: itamarst@yahoo.com (Itamar S.-T.) Date: Wed, 22 Aug 2001 13:49:26 -0700 (PDT) Subject: [python-win32] Sllllllllow ADSI Message-ID: <20010822204927.89155.qmail@web13004.mail.yahoo.com> Hi, I'm using ADSI to authenticate and get roles for users in Zope. I have 3 functions, 1 to authenticate the user, 1 to get the groups the user is in, and 1 to check if the user exists, e.g.: def userExists(username=""): """ Check if user exists """ try: ensure_init() # make sure this thread has CoInitialize() called. o = adsi.ADsGetObject("WinNT://Mainnt/%s" % username) if str(o.Class) == 'User': return 1 except: pass return 0 The problem is that this is very slow. It takes 30 seconds the first time it is called, (and the second time 0.01 seconds). The ensure_init() function is not responsible for this, I checked. Any suggestions what I should do? ===== Itamar Shtull-Trauring, itamar(at)shtull-trauring.org __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ From lists@net-labs.de Wed Aug 22 23:16:11 2001 From: lists@net-labs.de (ML) Date: Thu, 23 Aug 2001 00:16:11 +0200 Subject: [python-win32] Sllllllllow ADSI References: <20010822204927.89155.qmail@web13004.mail.yahoo.com> Message-ID: <004701c12b58$0cc77840$6600000a@netlabs.local> Hi Itamar, (know you from #zope:) .. I've read a message in some mail-archive, that if you use the Full-name e.g. "WinNT:///Mainnt/%s" this could solve your problem .. i haven't tried this .. hope this helps Ulrich Eck aka jack-e ----- Original Message ----- From: "Itamar S.-T." To: Sent: Wednesday, August 22, 2001 10:49 PM Subject: [python-win32] Sllllllllow ADSI > Hi, > > I'm using ADSI to authenticate and get roles for users > in Zope. I have 3 functions, 1 to authenticate the > user, 1 to get the groups the user is in, and 1 to > check if the user exists, e.g.: > > def userExists(username=""): > """ Check if user exists """ > try: > ensure_init() # make sure this thread has > CoInitialize() called. > o = adsi.ADsGetObject("WinNT://Mainnt/%s" % > username) > if str(o.Class) == 'User': return 1 > except: > pass > return 0 > > The problem is that this is very slow. It takes 30 > seconds the first time it is called, (and the second > time 0.01 seconds). The ensure_init() function is not > responsible for this, I checked. > > Any suggestions what I should do? > > > ===== > Itamar Shtull-Trauring, itamar(at)shtull-trauring.org > > __________________________________________________ > Do You Yahoo!? > Make international calls for as low as $.04/minute with Yahoo! Messenger > http://phonecard.yahoo.com/ > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Jim.Vickroy@noaa.gov Fri Aug 24 20:25:50 2001 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Fri, 24 Aug 2001 13:25:50 -0600 Subject: [python-win32] Access is denied on COM object Message-ID: <3B86AA3E.5581B095@noaa.gov> Hello, I'm trying to create a Windows *service* that exposes a COM object. I appear to be registering the COM object, installing the service that exposes it, and then starting that service. When I attempt to access the COM object from another process via a statement of the form: handle = win32com.client.Dispatch ( entry.COM_server._reg_progid_ ) the following exception is raised: (-2147024891, 'Access is denied.', None, None) Any ideas what I'm doing wrong? Thanks From sheila@thinkspot.net Sat Aug 25 22:57:33 2001 From: sheila@thinkspot.net (Sheila King) Date: Sat, 25 Aug 2001 14:57:33 -0700 Subject: [python-win32] Help: using msvcrt to lock files on Windows Message-ID: <31EBBA253DA@kserver.org> Below is a message that I posted to comp.lang.python earlier today. I later decided that I should maybe seek out a group of more Windows-inclined people. I'm trying to implement a cross platform Windows/Unix file locking object, and right now I'm having trouble with the windows part. I was hoping to just use the msvcrt module and avoid specific use of ActiveState's win32 libraries, since I didn't want to require people to have that installed. The description of the problem follows. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ I'm trying to do some file locking on Windows. I'm running Win98, but I hope that the methods in the msvcrt module will work OK on any win32? I thought I understood what I was doing. I had tested a bit of file locking stuff. I opened up two separate MSDOS console windows, and tried acquiring locks and releasing locks, etc... In one window: E:\Apache\cgi-bin\pylinks>python Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import msvcrt, os, sys >>> f = open('lock.txt') >>> fd = f.fileno() >>> size = os.path.getsize('lock.txt') >>> from time import localtime >>> msvcrt.locking(fd, msvcrt.LK_RLCK, size) >>> msvcrt.locking(fd, msvcrt.LK_UNLCK, size) >>> localtime() (2001, 8, 25, 12, 14, 19, 5, 237, 1) >>> msvcrt.locking(fd, msvcrt.LK_RLCK, size) >>> In the other window: E:\Apache\cgi-bin\pylinks>python Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import msvcrt, os, sys >>> f = open('lock.txt') >>> fd = f.fileno() >>> size = os.path.getsize('lock.txt') >>> from time import localtime >>> msvcrt.locking(fd, msvcrt.LK_RLCK, size) Traceback (most recent call last): File "", line 1, in ? IOError: [Errno 36] Resource deadlock avoided >>> localtime() (2001, 8, 25, 12, 13, 24, 5, 237, 1) >>> msvcrt.locking(fd, msvcrt.LK_RLCK, size) >>> msvcrt.locking(fd, msvcrt.LK_UNLCK, size) >>> When one process had the lock on the file first, the other process would either time out and given an IOError, or else wait until the first process unlocked the file, and then it appeared to acquire the lock. Even very simply, in a single window, I can do this and at least get no error messages: >>> f = open(r'e:\apache\cgi-bin\pylinks\lock.txt') >>> fd = f.fileno() >>> size = os.path.getsize(r'e:\apache\cgi-bin\pylinks\lock.txt') >>> msvcrt.locking(fd, msvcrt.LK_RLCK, size) >>> msvcrt.locking(fd, msvcrt.LK_UNLCK, size) >>> I realize that this doesn't prove I had a lock on anything, but I've tested that out separately, and I believe I am acquiring a lock and releasing it without error. NOW, why doesn't this class that I've written work without error? Here is the class: ---------------(begin winLock module)-------------------- ''' winLock.py class lockobject supports the same function calls as posixLock.lockobject export to lockobject.py: a wrapper module around the win and posix lockobjects ''' import os, msvcrt modes = {'write':msvcrt.LK_RLCK, 'read':msvcrt.LK_NBLCK,\ 'unlock':msvcrt.LK_UNLCK} class lockobject: def _lockoperation(self, lockfilename, mode): size = os.path.getsize(lockfilename) f = open(lockfilename, 'r') f.seek(0) msvcrt.locking(f.fileno(), modes[mode], size) def getReadLock(self, lockfilename): self._lockoperation(lockfilename, 'read') def getWriteLock(self, lockfilename): self._lockoperation(lockfilename, 'write') def unlock(self, lockfilename): self._lockoperation(lockfilename, 'unlock') --------------(end of winLock module)------------------------- Here is an interactive session with the module: >>> import winLock >>> from winLock import lockobject >>> one = lockobject() >>> one.getWriteLock(r'e:\apache\cgi-bin\pylinks\lock.txt') >>> one.unlock(r'e:\apache\cgi-bin\pylinks\lock.txt') Traceback (most recent call last): File "", line 1, in ? File "e:\apache\cgi-bin\pylinks\winLock.py", line 28, in unlock self._lockoperation(lockfilename, 'unlock') File "e:\apache\cgi-bin\pylinks\winLock.py", line 19, in _lockoperation msvcrt.locking(f.fileno(), modes[mode], size) IOError: [Errno 13] Permission denied >>> Now, why am I getting this Permission denied error? I'm only doing the same things I did before without the class? (OK, I did put a seek(0) command in there. It didn't used to be there and I was getting the same error, so I though maybe I should set the file pointer to the beginning of the file each time? Anyhow, doesn't work either way.) If someone can give me some tips here, I'd really appreciate it. From sheila@thinkspot.net Sun Aug 26 17:36:55 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 26 Aug 2001 09:36:55 -0700 Subject: [python-win32] File Locking: HELP Message-ID: <6031876BE4@kserver.org> OK, after a discussion with Tim Peters and others in comp.lang.python about file locking and msvcrt, I've decided that I really won't be able to use msvcrt for successful file locking. So, I'm going to try to use the win32 extensions. I have a book on order, but it will be a while until it gets here. In the meantime, I was trying to run the portalocker.py code that is here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203 And I get this error, when running it as __main__: Traceback (most recent call last): File "E:\programs\LearningPython\fileIO\portalocker.py", line 107, in ? portalocker.lock(log, portalocker.LOCK_EX) File "E:\programs\LearningPython\fileIO\portalocker.py", line 88, in lock win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped) pywintypes.api_error: (120, 'LockFileEx', 'This function is only valid in Win32 mode.') Any ideas what might be causing this? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From MarkH@ActiveState.com Sun Aug 26 23:09:01 2001 From: MarkH@ActiveState.com (Mark Hammond) Date: Mon, 27 Aug 2001 08:09:01 +1000 Subject: [python-win32] Re: Help: using msvcrt for file locking References: <7f6hot47j69t1lggtr86bhvc6i2l5q1kn2@4ax.com> <71jiotg3cbdpb6maid4fpa4ql3tjik8euh@4ax.com> Message-ID: <3B89737D.8060901@ActiveState.com> Sheila King wrote: > On Sun, 26 Aug 2001 16:19:36 GMT, Sheila King wrote > in comp.lang.python in article > : > > : > :I really don't see any way around file locking for the type of > :application I'm trying to write. However, I guess after seeing all the > :trouble with the msvcrt module, and how it doesn't even seem to allow > :shared locking access to a file, that I will go ahead and use the > :win32all extensions. I'm supposing that will allow better control? > > It appears, after a bit more research, that this will not work for all > win32 platforms, anyway. Apparently unsupported on Win95/98/Me: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/hh/winbase/filesio_39h4.asp > > (scroll down to just below where it says "requirements") It appears that LockFileEx is designed specifically for files that use "overlapped IO". Indeed, the "portalocker" recipe explicitly uses overlapped IO structures. Try using LockFile - the MSDN documentation implies that it is supported on all Win32 platforms, and the error you get: pywintypes.api_error: (120, 'LockFileEx', 'This function is only valid in Win32 mode.') implies you are running on Win9x. A quick look at portalocker implies you will also want to drop all references to "_overlapped" - replace them with "None". Mark. From sheila@thinkspot.net Sun Aug 26 23:31:00 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 26 Aug 2001 15:31:00 -0700 Subject: [python-win32] Re: Help: using msvcrt for file locking In-Reply-To: <3B89737D.8060901@ActiveState.com> References: <7f6hot47j69t1lggtr86bhvc6i2l5q1kn2@4ax.com> <71jiotg3cbdpb6maid4fpa4ql3tjik8euh@4ax.com> <3B89737D.8060901@ActiveState.com> Message-ID: <1A4660734F1@kserver.org> On Mon, 27 Aug 2001 08:09:01 +1000, Mark Hammond wrote about [python-win32] Re: Help: using msvcrt for file locking: :Sheila King wrote: :It appears that LockFileEx is designed specifically for files that use :"overlapped IO". Indeed, the "portalocker" recipe explicitly uses :overlapped IO structures. : :Try using LockFile - the MSDN documentation implies that it is supported :on all Win32 platforms, and the error you get: : :pywintypes.api_error: (120, 'LockFileEx', 'This function is only valid :in Win32 mode.') : :implies you are running on Win9x. : :A quick look at portalocker implies you will also want to drop all :references to "_overlapped" - replace them with "None". Thanks, Mark. I will try that and see what happens. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sheila@thinkspot.net Mon Aug 27 02:43:52 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 26 Aug 2001 18:43:52 -0700 Subject: [python-win32] Re: Help: using msvcrt for file locking In-Reply-To: <3B89737D.8060901@ActiveState.com> References: <7f6hot47j69t1lggtr86bhvc6i2l5q1kn2@4ax.com> <71jiotg3cbdpb6maid4fpa4ql3tjik8euh@4ax.com> <3B89737D.8060901@ActiveState.com> Message-ID: <254FBFE1278@kserver.org> On Mon, 27 Aug 2001 08:09:01 +1000, Mark Hammond wrote about [python-win32] Re: Help: using msvcrt for file locking: :Try using LockFile - the MSDN documentation implies that it is supported :on all Win32 platforms, and the error you get: : :pywintypes.api_error: (120, 'LockFileEx', 'This function is only valid :in Win32 mode.') : :implies you are running on Win9x. Yes, I am running on Win98. :A quick look at portalocker implies you will also want to drop all :references to "_overlapped" - replace them with "None". I tried that. Unfortunately, "None" didn't work. It gave me an error message asking for an integer. I spent a bit of time trying a few different things, and looking at the msdn site (here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/hh/winbase/filesio_8l6b.asp and eventually I came up with this code: filename = r'e:\apache\cgi-bin\pylinks\datalog.txt' import win32con import win32file import pywintypes from time import strftime, localtime, time f = open(filename, 'a+') fd = win32file._get_osfhandle(f.fileno()) win32file.LockFile(fd, win32con.LOCKFILE_EXCLUSIVE_LOCK, 0, 0xffff0000,0) timestamp = strftime("%m/%d/%Y %H:%M:%S\n", localtime(time())) f.write(timestamp) win32file.UnlockFile(fd, 0, 0, 0xffff0000,0) f.close() And the only error I'm getting now is: Traceback (most recent call last): File "E:\programs\LearningPython\fileIO\win32LockFile.py", line 13, in ? win32file.UnlockFile(fd, 0, 0, 0xffff0000,0) pywintypes.api_error: (33, 'UnlockFile', 'The process cannot access the file because\r\nanother process has locked a portion of the file.') Which is a big improvement over what I was getting before. Unfortunately, I'm just taking blind stabs in the dark. I'm in over my head, and I don't really know what I'm doing. Would getting the Programming Python on Win32 help me learn this Windows API stuff. Or would I have to get a separate book on Windows API and then get the Programming Python on Win32 to help me translate that knowledge into Python? (I have to say, that the msdn documentation is sketchy at best, and I have to do a lot of guesswork. I looked at some of the source files in the win32 directories, but it didn't help a whole lot.) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From MarkH@ActiveState.com Mon Aug 27 03:11:10 2001 From: MarkH@ActiveState.com (Mark Hammond) Date: Mon, 27 Aug 2001 12:11:10 +1000 Subject: [python-win32] Re: Help: using msvcrt for file locking In-Reply-To: <254FBFE1278@kserver.org> Message-ID: > :A quick look at portalocker implies you will also want to drop all > :references to "_overlapped" - replace them with "None". > > I tried that. Unfortunately, "None" didn't work. It gave me an error > message asking for an integer. Hrm - that is strange. A quick check over the C++ extension code certainly implies it should work. > win32file.LockFile(fd, win32con.LOCKFILE_EXCLUSIVE_LOCK, 0, 0xffff0000,0) The LockFile documentation states that the first integer "Specifies the low-order word of the starting byte offset in the file where the lock should begin." - ie, it is *not* the flag that LockFileEx supports. Set this to zero. The documentation for UnlockFile states that the unlocked region must be _exactly_ as specified in the LockFile call - hence your error when unlocking - the start offset is not identical. >Would getting the Programming Python on Win32 help me learn this Windows >API stuff. Or would I have to get a separate book on Windows API and then >get the Programming Python on Win32 to help me translate that knowledge into Python? It would not help with this specific corner of the API - file locking is not covered. In general, your best approach is to find documentation or examples in any language, and then use PPW32 to help translate to Python code. I would suggest buying a copy of the MSDN "library" on CD - I don't think it is too expensive, and is a very useful resource, including lots of sample code. I have not purchased a Win32 API book in over 5 years (and even the one I got then was pretty useles :) Mark. From sheila@thinkspot.net Mon Aug 27 04:23:33 2001 From: sheila@thinkspot.net (Sheila King) Date: Sun, 26 Aug 2001 20:23:33 -0700 Subject: [python-win32] Re: Help: using msvcrt for file locking In-Reply-To: References: <254FBFE1278@kserver.org> Message-ID: <2B0455F5F9C@kserver.org> On Mon, 27 Aug 2001 12:11:10 +1000, "Mark Hammond" wrote about RE: [python-win32] Re: Help: using msvcrt for file locking: :Hrm - that is strange. A quick check over the C++ extension code certainly :implies it should work. : :> win32file.LockFile(fd, win32con.LOCKFILE_EXCLUSIVE_LOCK, 0, 0xffff0000,0) : :The LockFile documentation states that the first integer "Specifies the :low-order word of the starting byte offset in the file where the lock should :begin." - ie, it is *not* the flag that LockFileEx supports. Set this to :zero. Heh. Yah, I noticed that, but, like I said, I'm not really sure what "low word order" is, and since you didn't mention to change that part in the previous message, I shrugged and figured I'd leave it as is. :The documentation for UnlockFile states that the unlocked region must be :_exactly_ as specified in the LockFile call - hence your error when :unlocking - the start offset is not identical. Cool. This code ran without error: filename = r'e:\apache\cgi-bin\pylinks\datalog.txt' import win32con import win32file import pywintypes from time import strftime, localtime, time f = open(filename, 'a+') fd = win32file._get_osfhandle(f.fileno()) win32file.LockFile(fd, 0, 0, 0xffff0000,0) timestamp = strftime("%m/%d/%Y %H:%M:%S\n", localtime(time())) f.write(timestamp) win32file.UnlockFile(fd, 0, 0, 0xffff0000,0) f.close() I'm not 100% sure what I did. It seems to me, that if Win9x/Me don't take flags, then I'm simply getting an exclusive lock. There are no shared locks for Win9x/Me, right? It seems to me that I will probably be able to accomplish the same thing with the msvcrt module. I finally realized, that I can have blocking or non-blocking, but there is only exclusive locks and no shared locks. :I would suggest buying a copy of the MSDN "library" on CD - I don't think it :is too expensive, and is a very useful resource, including lots of sample :code. I have not purchased a Win32 API book in over 5 years (and even the :one I got then was pretty useles :) Thanks for the tip. I will look for that CD. Does it have stuff on it that is not available on the msdn.microsoft.com website? I know that MS books are not so hot. My husband bought one that was supposed to be the official support for the Win95 OS, many years back, and many an expletive I've heard about the lack of any useful information in that tome. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From cgaston@moonqzie.com Mon Aug 27 12:03:09 2001 From: cgaston@moonqzie.com (Carlos Alvarez) Date: Mon, 27 Aug 2001 13:03:09 +0200 Subject: [python-win32] rts - services Message-ID: <007001c12ee7$dbe251d0$1b00a8c0@domain.moonqzieserver> This is a multi-part message in MIME format. ------=_NextPart_000_006D_01C12EF8.9F0B0070 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi there, I am avaluating using Python for a commertial aplication. I really = dont know Python but it seems to be the right language for what we want = to do. I am facing a big problem. We want to do a program that should stay = recident on win32 machines (95,98,me,nt). I should not show any dos = window (or so). I should neither have to ask the user to install Python = on their machine (but installing python dlls is aceptable). We dont know = how to do it in Python. It should work as a service but i think it = should be not a service because it should be able to be started by = another program and it should run at win 95 etc. Any help will be apreciated. We are new to Python and despite we = have found 'compilers' and installers we havent seen any place where it = says that what we want to do can be done in Python. What about using Python as an embbed language? Thanks in advance, Carlos Alvarez ------=_NextPart_000_006D_01C12EF8.9F0B0070 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi there,
 
    I am avaluating = using Python for=20 a commertial aplication. I really dont know Python but it seems to be = the right=20 language for what we want to do.
    I am facing a big = problem. We=20 want to do a program that should stay recident on win32 machines = (95,98,me,nt).=20 I should not show any dos window (or so). I should neither have to ask = the user=20 to install Python on their machine (but installing python dlls is = aceptable). We=20 dont know how to do it in Python. It should work as a service but i = think it=20 should be not a service because it should be able to be started by = another=20 program and it should run at win 95 etc.
    Any help will be = apreciated. We=20 are new to Python and despite we have found 'compilers' and installers = we havent=20 seen any place where it says that what we want to do can be done in=20 Python.
   What about using Python as = an embbed=20 language?
 
Thanks in advance,
 
Carlos = Alvarez
------=_NextPart_000_006D_01C12EF8.9F0B0070-- From greg@electricrain.com Mon Aug 27 19:25:20 2001 From: greg@electricrain.com (Gregory P. Smith) Date: Mon, 27 Aug 2001 11:25:20 -0700 Subject: [python-win32] rts - services In-Reply-To: <007001c12ee7$dbe251d0$1b00a8c0@domain.moonqzieserver>; from cgaston@moonqzie.com on Mon, Aug 27, 2001 at 01:03:09PM +0200 References: <007001c12ee7$dbe251d0$1b00a8c0@domain.moonqzieserver> Message-ID: <20010827112520.A28279@zot.electricrain.com> On Mon, Aug 27, 2001 at 01:03:09PM +0200, Carlos Alvarez wrote: > > I am avaluating using Python for a commertial aplication. I really dont know Python but it seems to be the right language for what we want to do. > I am facing a big problem. We want to do a program that should stay recident on win32 machines (95,98,me,nt). I should not show any dos window (or so). I should neither have to ask the user to install Python on their machine (but installing python dlls is aceptable). We dont know how to do it in Python. It should work as a service but i think it should be not a service because it should be able to be started by another program and it should run at win 95 etc. > Any help will be apreciated. We are new to Python and despite we have found 'compilers' and installers we havent seen any place where it says that what we want to do can be done in Python. > What about using Python as an embbed language? You can do all of the above. Look for py2exe (use google to find it) to byte-compile and package up your python program into a single executable plus a small number of .dlls that can simple all be installed in a single directory. The one thing I have not personally done is make a python program run as a win32 service. Other people have. Greg From jens.jorgensen@tallan.com Mon Aug 27 20:37:06 2001 From: jens.jorgensen@tallan.com (Jorgensen, Jens) Date: Mon, 27 Aug 2001 14:37:06 -0500 Subject: [python-win32] Access is denied on COM object References: <3B86AA3E.5581B095@noaa.gov> Message-ID: <3B8AA162.4040300@tallan.com> This would seem to be a COM security problem rather than a Python-related one. There's a lot to COM security so I'm not even going to attempt to delve into this. Take a read through this little article about COM security though, it might help: http://support.microsoft.com/support/kb/articles/Q158/5/08.asp Jim Vickroy wrote: >Hello, > >I'm trying to create a Windows *service* that exposes a COM object. > >I appear to be registering the COM object, installing the service that >exposes it, and then starting that service. > >When I attempt to access the COM object from another process via a >statement of the form: > >handle = win32com.client.Dispatch ( entry.COM_server._reg_progid_ ) > >the following exception is raised: > >(-2147024891, 'Access is denied.', None, None) > >Any ideas what I'm doing wrong? > >Thanks > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com From Jim.Vickroy@noaa.gov Mon Aug 27 20:38:59 2001 From: Jim.Vickroy@noaa.gov (Jim Vickroy) Date: Mon, 27 Aug 2001 13:38:59 -0600 Subject: [python-win32] Access is denied on COM object References: <3B86AA3E.5581B095@noaa.gov> <3B8AA162.4040300@tallan.com> Message-ID: <3B8AA1D2.26E918A7@noaa.gov> Thanks very much for your response. I was beginning to suspect that. I'll read the article right now. "Jorgensen, Jens" wrote: > This would seem to be a COM security problem rather than a > Python-related one. There's a lot to COM security so I'm not even going > to attempt to delve into this. Take a read through this little article > about COM security though, it might help: > > http://support.microsoft.com/support/kb/articles/Q158/5/08.asp > > Jim Vickroy wrote: > > >Hello, > > > >I'm trying to create a Windows *service* that exposes a COM object. > > > >I appear to be registering the COM object, installing the service that > >exposes it, and then starting that service. > > > >When I attempt to access the COM object from another process via a > >statement of the form: > > > >handle = win32com.client.Dispatch ( entry.COM_server._reg_progid_ ) > > > >the following exception is raised: > > > >(-2147024891, 'Access is denied.', None, None) > > > >Any ideas what I'm doing wrong? > > > >Thanks > > > > > >_______________________________________________ > >Python-win32 mailing list > >Python-win32@python.org > >http://mail.python.org/mailman/listinfo/python-win32 > > > > -- > Jens B. Jorgensen > jens.jorgensen@tallan.com From jens.jorgensen@tallan.com Mon Aug 27 21:02:30 2001 From: jens.jorgensen@tallan.com (Jorgensen, Jens) Date: Mon, 27 Aug 2001 15:02:30 -0500 Subject: [python-win32] File Locking: HELP References: <6031876BE4@kserver.org> Message-ID: <3B8AA756.5090308@tallan.com> You're not trying this in Win98 are you? Here's a little excerpt from the MSDN library: Windows NT/2000: Requires Windows NT 3.1 or later. Windows 95/98: Unsupported. Windows CE: Unsupported. Header: Declared in winbase.h; include windows.h. Library: Use kernel32.lib. Sheila King wrote: >OK, after a discussion with Tim Peters and others in comp.lang.python >about file locking and msvcrt, I've decided that I really won't be able >to use msvcrt for successful file locking. > >So, I'm going to try to use the win32 extensions. I have a book on >order, but it will be a while until it gets here. > >In the meantime, I was trying to run the portalocker.py code that is >here: >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203 > >And I get this error, when running it as __main__: > >Traceback (most recent call last): > File "E:\programs\LearningPython\fileIO\portalocker.py", line 107, in >? > portalocker.lock(log, portalocker.LOCK_EX) > File "E:\programs\LearningPython\fileIO\portalocker.py", line 88, in >lock > win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped) >pywintypes.api_error: (120, 'LockFileEx', 'This function is only valid >in Win32 mode.') > >Any ideas what might be causing this? > >-- >Sheila King >http://www.thinkspot.net/sheila/ >http://www.k12groups.org/ > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > -- Jens B. Jorgensen jens.jorgensen@tallan.com From sheila@thinkspot.net Tue Aug 28 00:49:48 2001 From: sheila@thinkspot.net (Sheila King) Date: Mon, 27 Aug 2001 16:49:48 -0700 Subject: [python-win32] win32 file locking methods Message-ID: <712D7555E2A@kserver.org> OK, after a suggestion from David Bolen in the comp.lang.python newsgroup, I tried this: PythonWin 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> import win32file >>> from win32con import * >>> fd = win32file.CreateFile(r'e:\temp\gpl.txt', GENERIC_READ, 0, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) >>> GD = win32file.CreateFile(r'e:\temp\gpl.txt', GENERIC_READ, 0, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) Traceback (most recent call last): File "", line 1, in ? api_error: (32, 'CreateFile', 'The process cannot access the file because\r\nit is being used by another process.') >>> win32file.CloseHandle(fd) >>> GD = win32file.CreateFile(r'e:\temp\gpl.txt', GENERIC_READ, 0, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) >>> win32file.CloseHandle(GD) >>> It seems to work quite well??? comments? I am excited about this, unless someone has some reason to caution me or point out why this won't work. To recap: I want to be able to have file locking (on an entire file; I don't require locks on only parts of the file), on win32, including win98 as well as NT/2000. This looks like it may be the way to go. Here is the exchange from comp.lang.python: David's suggestion: > After reading this thread, it appears that you probably want more fine > grained locking, but just in case you do end up falling back to some > sort of sentinel file or more global lock approach... > > An alternative to the msvcrt lock stuff for a full file lock that may > be more portable among Windows platforms would be to just open your > lock file using the native Win32 CreateFile call (wrapped in > win32file), and ask for exclusive access (no sharing mode). If you > need to do I/O to the lock file you'll probably need to use the Win32 > functions (although you could wrap that in a file-like object), but if > you're just using that file to restrict access to other files it can > be a convenient method. My response: > :After reading this thread, it appears that you probably want more fine > :grained locking, but just in case you do end up falling back to some > :sort of sentinel file or more global lock approach... > > No, I wasn't trying to do fine grained locking. I was going to use a > sentinel file. > > :An alternative to the msvcrt lock stuff for a full file lock that may > :be more portable among Windows platforms would be to just open your > :lock file using the native Win32 CreateFile call (wrapped in > :win32file), and ask for exclusive access (no sharing mode). > > Thanks. I'm looking at that, and it looks like it might be a very good > approach. > > :If you need to do I/O to the lock file you'll probably need to use the Win32 > :functions (although you could wrap that in a file-like object), > > Fortunately, I'm not planning any I/O on the locked file. > > :but if you're just using that file to restrict access to other files it can > :be a convenient method. > > This is exactly what I'm trying to do. Thanks, again, for the > suggestion. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From cgaston@moonqzie.com Thu Aug 30 16:52:07 2001 From: cgaston@moonqzie.com (Carlos Alvarez) Date: Thu, 30 Aug 2001 17:52:07 +0200 Subject: [python-win32] com crash Message-ID: <00d401c1316b$b93207d0$1b00a8c0@domain.moonqzieserver> This is a multi-part message in MIME format. ------=_NextPart_000_00D1_01C1317C.7C4CD3C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi there, Using the com clases with internet explorer (to control it) when = you call navigate of a window python crashes. If you call navigate of = explorer it works fine. It is a bug. C++ builder reports an error but = doesnt crash. I dont know if it was fixed in a more resent release (using = win32all built 140 on windows 2000 profesional witch python 2.1). Chau, Gaston ------=_NextPart_000_00D1_01C1317C.7C4CD3C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi there,
 
     Using the com clases with internet = explorer (to=20 control it) when you call navigate of a window python crashes. If = you call=20 navigate of explorer it works fine. It is a bug. C++ builder reports an = error=20 but doesnt crash.
     I dont know if it was fixed in a more = resent=20 release (using win32all built 140 on windows 2000 profesional witch = python=20 2.1).
 
Chau,
 
Gaston
------=_NextPart_000_00D1_01C1317C.7C4CD3C0-- From john@hopkinsit.com Sun Aug 12 03:38:02 2001 From: john@hopkinsit.com (John Hopkins) Date: Sat, 11 Aug 2001 19:38:02 -0700 Subject: [python-win32] ini File Management with win32ui Message-ID: <006601c122d7$cf4a2360$01000059@hopkinsmain> This is a multi-part message in MIME format. ------=_NextPart_000_0063_01C1229D.222C4120 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I need to manage an ini file on Win2k and NT4. After reading in the archiv= es and the documentation I tried to use ConfigParser with the followinfg re= sults:=0D =0D >>> import ConfigParser=0D >>> p =3D ConfigParser.ConfigParser()=0D Traceback (most recent call last):=0D File "", line 1, in ?=0D TypeError: object is not callable: =0D =0D According to PythonWin's About box, I'm using ActivePython build 2.1.211.= =0D =0D Any help will be greatly appreciated.=0D =0D Thanks in advance,=0D =0D John=0D =0D ------=_NextPart_000_0063_01C1229D.222C4120 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =0D =0D =0D =0D =0D =0D =0D
I need to manage an ini file on Win2k and = =0D NT4.  After reading in the archives and the documentation I tried to = =0D use ConfigParser with the followinfg results:
=0D
 
=0D
>>> import ConfigParser
>&g= t;> p =0D =3D ConfigParser.ConfigParser()
Traceback (most recent call last):
&n= bsp; =0D File "<interactive input>", line 1, in ?
TypeError: object is not = =0D callable: <module 'ConfigParser' from 'ConfigParser.py'>
=0D
According to PythonWin's About box, I'm us= ing =0D ActivePython build 2.1.211.
=0D
 
=0D
Any help will be greatly appreciated.
=0D
 
=0D
Thanks in advance,
=0D
 
=0D
John
=0D
 
=0D ------=_NextPart_000_0063_01C1229D.222C4120-- _______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com http://listserv.ActiveState.com/mailman/listinfo/activepython From john@hopkinsit.com Tue Aug 14 05:55:58 2001 From: john@hopkinsit.com (John Hopkins) Date: Mon, 13 Aug 2001 21:55:58 -0700 Subject: [python-win32] Didja Know (was ini File Management with win32ui ) References: <006601c122d7$cf4a2360$01000059@hopkinsmain> <000b01c12324$bbd0c260$f2acbfa8@robinjim> Message-ID: <003401c1247d$69671600$01000059@hopkinsmain> This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C12442.BC19E660 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks to all for the help; I finally stumbled into the solution.=0D =0D Didja know that it's a bad idea to name a python script file which imports = ConfigParser, "ConfigParser.py"? Yeah, I did too, but I wasn't thinking cl= early.=0D =0D Oh, well, I guess I'll remember for a while now.=0D =0D John=0D =0D ----- Original Message ----- =0D From: robin and jim =0D To: John Hopkins ; python-win32@python.org ; activepython@listserv.Active= State.com =0D Sent: Sunday, August 12, 2001 4:48 AM=0D Subject: Re: [python-win32] ini File Management with win32ui=0D =0D =0D Hello John,=0D =0D I suppose this does not help much, but here is the result on my Win 98 sy= stem with Python 2.0:=0D =0D PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32.= =0D Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see '= Help/About PythonWin' for further copyright information.=0D >>> import ConfigParser=0D >>> p =3D ConfigParser.ConfigParser()=0D >>> dir (p)=0D ['_ConfigParser__defaults', '_ConfigParser__sections']=0D >>> =0D =0D If you do not get any responses before then, I will try this tomorrow whe= n I have access to a Win 2k system.=0D ----- Original Message ----- =0D From: John Hopkins =0D To: python-win32@python.org ; activepython@listserv.ActiveState.com =0D Sent: Saturday, August 11, 2001 8:38 PM=0D Subject: [python-win32] ini File Management with win32ui=0D =0D =0D I need to manage an ini file on Win2k and NT4. After reading in the ar= chives and the documentation I tried to use ConfigParser with the followinf= g results:=0D =0D >>> import ConfigParser=0D >>> p =3D ConfigParser.ConfigParser()=0D Traceback (most recent call last):=0D File "", line 1, in ?=0D TypeError: object is not callable: =0D =0D According to PythonWin's About box, I'm using ActivePython build 2.1.21= 1.=0D =0D Any help will be greatly appreciated.=0D =0D Thanks in advance,=0D =0D John=0D =0D ------=_NextPart_000_0031_01C12442.BC19E660 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =0D =0D =0D =0D =0D =0D =0D
Thanks to all for the help; I finally stum= bled into =0D the solution.
=0D
 
=0D
Didja know that it's a bad idea to name a = python =0D script file which imports ConfigParser, "ConfigParser.py"?  Yeah, I di= d =0D too, but I wasn't thinking clearly.
=0D
 
=0D
Oh, well, I guess I'll remember for a whil= e =0D now.
=0D
 
=0D
John
=0D
 
=0D
----- Original Message -----
=0D
=0D
Fro= m: =0D = robin and =0D jim
=0D =0D
Sent: Sunday, August 12, 2001 4:48= =0D AM
=0D
Subject: Re: [python-win32] ini Fi= le =0D Management with win32ui
=0D

=0D
Hello John,
=0D
 
=0D
I suppose this does not help m= uch, but =0D here is the result on my Win 98 system with Python 2.0:
=0D
 
=0D =0D
 
=0D
If you do not get any response= s before =0D then, I will try this tomorrow when I have access to a Win 2k =0D system.
=0D
=0D
----- Original Message -----
=0D
=0D =0D
Sent: Saturday, August 11, 2001 = 8:38 =0D PM
=0D
Subject: [python-win32] ini File= =0D Management with win32ui
=0D

=0D
I need to manage an ini file on Win2k = and =0D NT4.  After reading in the archives and the documentation I tried = to =0D use ConfigParser with the followinfg results:
=0D
 
=0D
>>> import =0D ConfigParser
>>> p =3D ConfigParser.ConfigParser()
Trace= back =0D (most recent call last):
  File "<interactive input>", li= ne 1, =0D in ?
TypeError: object is not callable: <module 'ConfigParser' fr= om =0D 'ConfigParser.py'>
=0D
According to PythonWin's About box, I'= m using =0D ActivePython build 2.1.211.
=0D
 
=0D
Any help will be greatly =0D appreciated.
=0D
 
=0D
Thanks in advance,
=0D
 
=0D
John
=0D
 
=0D ------=_NextPart_000_0031_01C12442.BC19E660-- _______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com http://listserv.ActiveState.com/mailman/listinfo/activepython From robinjim@earthlink.net Sun Aug 12 12:48:34 2001 From: robinjim@earthlink.net (robin and jim) Date: Sun, 12 Aug 2001 05:48:34 -0600 Subject: [python-win32] ini File Management with win32ui References: <006601c122d7$cf4a2360$01000059@hopkinsmain> Message-ID: <000b01c12324$bbd0c260$f2acbfa8@robinjim> This is a multi-part message in MIME format. ------=_NextPart_000_0008_01C122F2.6CB1B4A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello John,=0D =0D I suppose this does not help much, but here is the result on my Win 98 syst= em with Python 2.0:=0D =0D PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32.=0D Portions Copyright 1994-2001 Mark Hammond (MarkH@ActiveState.com) - see 'He= lp/About PythonWin' for further copyright information.=0D >>> import ConfigParser=0D >>> p =3D ConfigParser.ConfigParser()=0D >>> dir (p)=0D ['_ConfigParser__defaults', '_ConfigParser__sections']=0D >>> =0D =0D If you do not get any responses before then, I will try this tomorrow when = I have access to a Win 2k system.=0D ----- Original Message ----- =0D From: John Hopkins =0D To: python-win32@python.org ; activepython@listserv.ActiveState.com =0D Sent: Saturday, August 11, 2001 8:38 PM=0D Subject: [python-win32] ini File Management with win32ui=0D =0D =0D I need to manage an ini file on Win2k and NT4. After reading in the arch= ives and the documentation I tried to use ConfigParser with the followinfg = results:=0D =0D >>> import ConfigParser=0D >>> p =3D ConfigParser.ConfigParser()=0D Traceback (most recent call last):=0D File "", line 1, in ?=0D TypeError: object is not callable: =0D =0D According to PythonWin's About box, I'm using ActivePython build 2.1.211.= =0D =0D Any help will be greatly appreciated.=0D =0D Thanks in advance,=0D =0D John=0D =0D ------=_NextPart_000_0008_01C122F2.6CB1B4A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =0D =0D =0D =0D =0D =0D =0D
Hello John,
=0D
 
=0D
I suppose this does not help muc= h, but =0D here is the result on my Win 98 system with Python 2.0:
=0D
 
=0D
PythonWin 2.0 (#8, Oct 16 2000, = 17:27:58) =0D [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond= (MarkH@ActiveState.com) - see 'Hel= p/About =0D PythonWin' for further copyright information.
>>> import =0D ConfigParser
>>> p =3D ConfigParser.ConfigParser()
>>&= gt; dir =0D (p)
['_ConfigParser__defaults', '_ConfigParser__sections']
>>&g= t; =0D
=0D
 
=0D
If you do not get any responses = before =0D then, I will try this tomorrow when I have access to a Win 2k =0D system.
=0D
=0D
----- Original Message -----
=0D
Fro= m: =0D John Hop= kins =0D
=0D =0D
Sent: Saturday, August 11, 2001 8:= 38 =0D PM
=0D
Subject: [python-win32] ini File = =0D Management with win32ui
=0D

=0D
I need to manage an ini file on Win2k an= d =0D NT4.  After reading in the archives and the documentation I tried to= =0D use ConfigParser with the followinfg results:
=0D
 
=0D
>>> import ConfigParser
>= >> =0D p =3D ConfigParser.ConfigParser()
Traceback (most recent call =0D last):
  File "<interactive input>", line 1, in ?
TypeEr= ror: =0D object is not callable: <module 'ConfigParser' from =0D 'ConfigParser.py'>
=0D
According to PythonWin's About box, I'm = using =0D ActivePython build 2.1.211.
=0D
 
=0D
Any help will be greatly =0D appreciated.
=0D
 
=0D
Thanks in advance,
=0D
 
=0D
John
=0D
 
=0D ------=_NextPart_000_0008_01C122F2.6CB1B4A0-- _______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com http://listserv.ActiveState.com/mailman/listinfo/activepython