From sirgnip at gmail.com Wed Sep 5 06:24:22 2012 From: sirgnip at gmail.com (Scott Nelson) Date: Tue, 4 Sep 2012 23:24:22 -0500 Subject: [python-win32] Example code for SHOpenFolderAndSelectItems? Message-ID: Greetings... Would anyone happen to have some sample code of how to use SHOpenFolderAndSelectItems? I've been tinkering with it and haven't got anything to work yet. This is the closest I've got: >>> from win32com.shell import shell >>> shell.SHOpenFolderAndSelectItems((r'c:\junk', ), 1) Traceback (most recent call last): File "", line 1, in TypeError: Must be an array of IDLs The errors I've seen in my experiments mention "IDLs" and "ITEMIDLIST" objects. I've dug a bit through the pywin32 docs and MDSN and didn't have much luck understanding what the Python wrapper required and how to construct these object. I must admit I don't have much Win32 API programming experience. I'm using Active State's Python 2.6.2.2 on Vista and I installed the 32 bit version of pywin32, build 217. For reverence, here's some links: I submitted the feature request for SHOpenFolderAndSelectItems: http://sourceforge.net/tracker/?func=detail&aid=3396444&group_id=78018&atid=551957 The changeset that implements this function is here: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/rev/1452829d69ec. And, here's the MSDN doc: http://msdn.microsoft.com/en-us/library/bb762232%28v=vs.85%29.aspx Any nudges in the right direction would be helpful. Thanks! -Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Wed Sep 5 08:02:17 2012 From: rupole at hotmail.com (Roger Upole) Date: Wed, 5 Sep 2012 02:02:17 -0400 Subject: [python-win32] Example code for SHOpenFolderAndSelectItems? References: Message-ID: Scott Nelson wrote: > Greetings... > > Would anyone happen to have some sample code of how to use > SHOpenFolderAndSelectItems? I've been tinkering with it and haven't got > anything to work yet. This is the closest I've got: > >>>> from win32com.shell import shell >>>> shell.SHOpenFolderAndSelectItems((r'c:\junk', ), 1) > Traceback (most recent call last): > File "", line 1, in > TypeError: Must be an array of IDLs > > The errors I've seen in my experiments mention "IDLs" and "ITEMIDLIST" > objects. I've dug a bit through the pywin32 docs and MDSN and didn't have > much luck understanding what the Python wrapper required and how to > construct these object. I must admit I don't have much Win32 API > programming experience. > > I'm using Active State's Python 2.6.2.2 on Vista and I installed the 32 bit > version of pywin32, build 217. > > For reverence, here's some links: > I submitted the feature request for SHOpenFolderAndSelectItems: > http://sourceforge.net/tracker/?func=detail&aid=3396444&group_id=78018&atid=551957 > > The changeset that implements this function is here: > http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/rev/1452829d69ec. > > And, here's the MSDN doc: > http://msdn.microsoft.com/en-us/library/bb762232%28v=vs.85%29.aspx > > Any nudges in the right direction would be helpful. > > Thanks! > > -Scott > from win32com.shell import shell, shellcon import win32api folder = win32api.GetTempPath() folder_pidl=shell.SHILCreateFromPath(folder,0)[0] desktop = shell.SHGetDesktopFolder() shell_folder = desktop.BindToObject(folder_pidl, None, shell.IID_IShellFolder) items = [item for item in shell_folder][:5] ## print (items) shell.SHOpenFolderAndSelectItems(folder_pidl, items, 0) From raf at raf.org Thu Sep 6 06:48:08 2012 From: raf at raf.org (raf) Date: Thu, 6 Sep 2012 14:48:08 +1000 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkey query Message-ID: <20120906044808.GA26814@raf.org> hi, windows-xp/7 python-2.6.2 pywin32-217 ages ago i wrote some code to get a user's home directory on windows (even if they'd gone into the registry and moved it). i remember it working when i wrote it but at some point it stopped working. when i looked into it, it turned out that the registry subkeys no longer looked like what the code was expecting. the code was something like: import win32api, win32net, win32netcon, win32security, _winreg, re, os def user(): try: dc = win32net.NetServerEnum(None, 100, win32netcon.SV_TYPE_DOMAIN_CTRL) dcname = r'\\' + dc[0][0]['name'] if dc[0] and isinstance(dc[0][0], dict) else None except Exception: dcname = None return win32net.NetUserGetInfo(dcname, win32api.GetUserName(), 1)['name'] def home(username=None): if username is None: username = user() sid = win32security.ConvertSidToStringSid(win32security.LookupAccountName(None, username)[0]) subkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\' + sid key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) val, typ = _winreg.QueryValueEx(key, 'ProfileImagePath') if typ == _winreg.REG_EXPAND_SZ: # Which it is while True: match = re.compile('%\w+%').search(val) if match is None: break varname = val[match.start()+1:match.end()-1] val = val[0:match.start()] + os.getenv(varname, '') + val[match.end():] return val given the account sid: S-1-5-5-21-725345543-1957994488-859522115 it expected to find this registry key: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115 inside which it expected to find: ProfileImagePath = %SystemDrive%\Documents and Settings\patricia (WindowsXP) ProfileImagePath = C:\Users\patricia (Windows7) however, instead of the above registry key, there are: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1003 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1004 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1005 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1006 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1008 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1009 each referring to a different user (patricia happens to be the one ending in 1009). sadly, i've resorted to poking around likely locations in the file system but that's not very satisfying. and i'd like to avoid enumerating through all of these keys and just assuming that the home directory contains the user's login name (even though that's very likely). so my questions are: did the sid for the account name ever uniquely identify the user? how do i obtain the "1009" that needs to be appended to the sid to complete it? i've attached the real code in case it's of any help. p.s. i know (as of a few minutes ago) that there is a win32profile module that looks like it should do all of this for me but according to its documentation, i can only use win32profile.GetUserProfileDirectory() if i have a token returned by win32security.LogonUser() but i don't want or need to log the user in (even if i knew their passwords!) so i have no such token and i can't use that function. cheers, raf -------------- next part -------------- A non-text attachment was scrubbed... Name: userhome.py Type: text/x-python Size: 5037 bytes Desc: not available URL: From sirgnip at gmail.com Thu Sep 6 14:05:48 2012 From: sirgnip at gmail.com (Scott Nelson) Date: Thu, 6 Sep 2012 07:05:48 -0500 Subject: [python-win32] Example code for SHOpenFolderAndSelectItems? In-Reply-To: References: Message-ID: Roger, Thanks much for the example code (and the implementation of the feature in the first place!). It got me running. For posterity, I copied in my function below that wraps up your sample code in a function. Thanks again! -Scott from win32com.shell import shell, shellcon def launch_file_explorer(path, files): '''Given a absolute base path and names of its children (no path), open up one File Explorer window with all the child files selected''' folder_pidl = shell.SHILCreateFromPath(path,0)[0] desktop = shell.SHGetDesktopFolder() shell_folder = desktop.BindToObject(folder_pidl, None, shell.IID_IShellFolder) name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 0), item) for item in shell_folder]) to_show = [] for file in files: if not name_to_item_mapping.has_key(file): raise Exception('File: "%s" not found in "%s"' % (file, path)) to_show.append(name_to_item_mapping[file]) shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0) -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Thu Sep 6 18:50:54 2012 From: rupole at hotmail.com (Roger Upole) Date: Thu, 6 Sep 2012 12:50:54 -0400 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkeyquery References: <20120906044808.GA26814@raf.org> Message-ID: raf wrote: > so my questions are: > did the sid for the account name ever uniquely identify the user? Yes. In fact it's the only way, since you can change the login name of an account. > how do i obtain the "1009" that needs to be appended to the sid > to complete it? win32security.LookupAccountName will give you the complete sid for a username. Roger From timr at probo.com Thu Sep 6 19:45:17 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 6 Sep 2012 10:45:17 -0700 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkey query In-Reply-To: <20120906044808.GA26814@raf.org> References: <20120906044808.GA26814@raf.org> Message-ID: <5048E12D.7090906@probo.com> raf wrote: > ages ago i wrote some code to get a user's home directory on windows > (even if they'd gone into the registry and moved it). i remember it > working when i wrote it but at some point it stopped working. when i > looked into it, it turned out that the registry subkeys no longer > looked like what the code was expecting. > ... > given the account sid: > > S-1-5-5-21-725345543-1957994488-859522115 That's not an account SID, that's a logon session (S-1-5-5). Did you perhaps copy-and-paste this by typing it by hand? If you eliminate the extra -5 (so, S-1-5-21-xxx), then it would be a domain SID. It's still not a user account SID -- that requires one more set of digits, as you found below. > however, instead of the above registry key, there are: > > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1003 > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1004 > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1005 > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1006 > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1008 > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-5-21-725345543-1957994488-859522115-1009 > > each referring to a different user (patricia happens to be the one ending in 1009). Right. Those are user accounts within the domain or local group S-1-5-21-...-859522115. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From raf at raf.org Fri Sep 7 15:30:26 2012 From: raf at raf.org (raf) Date: Fri, 7 Sep 2012 23:30:26 +1000 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkeyquery In-Reply-To: References: <20120906044808.GA26814@raf.org> Message-ID: <20120907133026.GA21098@raf.org> Roger Upole wrote: > raf wrote: > > > so my questions are: > > did the sid for the account name ever uniquely identify the user? > > Yes. In fact it's the only way, since you can change the login name of an account. > > > how do i obtain the "1009" that needs to be appended to the sid > > to complete it? > > win32security.LookupAccountName will give you the complete sid for a username. > > Roger if you look at the code i supplied, you'll see that that is precisely where i get the sid from: sid = win32security.ConvertSidToStringSid(win32security.LookupAccountName(None, username)[0]) so win32security.LookupAccountName is not giving me the complete sid for the username. any idea why it isn't doing so? any idea what i'm doing wrong? cheers, raf From timr at probo.com Fri Sep 7 18:51:49 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 7 Sep 2012 09:51:49 -0700 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkeyquery In-Reply-To: <20120907133026.GA21098@raf.org> References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> Message-ID: <504A2625.2030008@probo.com> raf wrote: > > if you look at the code i supplied, you'll see that that is precisely > where i get the sid from: > > sid = win32security.ConvertSidToStringSid(win32security.LookupAccountName(None, username)[0]) > > so win32security.LookupAccountName is not giving me the complete sid for the username. > any idea why it isn't doing so? any idea what i'm doing wrong? You are assuming that the user name you got is a local user on this machine, and never a domain user. That may be true for the computer you're using, but it's not safe in the general case. In my case, LookupAccountName('timr2-pc', 'timr') produces a very different result from LookupAccountName('probo','timr'). BTW, I've tried your code on XP and on Win 7 64, and in both cases I get the full string including the last set of digits. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rupole at hotmail.com Mon Sep 10 19:28:32 2012 From: rupole at hotmail.com (Roger Upole) Date: Mon, 10 Sep 2012 13:28:32 -0400 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkeyquery References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> Message-ID: raf wrote: > Roger Upole wrote: > >> raf wrote: >> >> > so my questions are: >> > did the sid for the account name ever uniquely identify the user? >> >> Yes. In fact it's the only way, since you can change the login name of an account. >> >> > how do i obtain the "1009" that needs to be appended to the sid >> > to complete it? >> >> win32security.LookupAccountName will give you the complete sid for a username. >> >> Roger > > if you look at the code i supplied, you'll see that that is precisely > where i get the sid from: > > sid = win32security.ConvertSidToStringSid(win32security.LookupAccountName(None, username)[0]) > > so win32security.LookupAccountName is not giving me the complete sid for the username. > any idea why it isn't doing so? any idea what i'm doing wrong? > > cheers, > raf Sorry, from a first glance I thought you were deliberately retrieving the machine's SID and then looking for the accounts under it. It appears you have a machine named the same as the user, and the call to LookupAccountName is finding the computer name first. Try passing \\machine\username instead of just the bare user name. Roger From matteo.boscolo at boscolini.eu Mon Sep 10 19:59:59 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Mon, 10 Sep 2012 19:59:59 +0200 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? In-Reply-To: References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> Message-ID: <504E2A9F.9060206@boscolini.eu> Hi All, I'm Working on a cad program using the it's com interface I have a python com object in witch I call a method as follows .. props=ent.Properties(True) #Ent is a IDocument this method is working well, and return a tuple of ITDProperty that are the property of the document. The problem is when I close the document from the Cad application, the Cad application is unable to close the document because there is some reference still active. I tried several way using the gc.collect(), to set to null each document pointer but with no result. I tried to do the some kind of operation with c# and using the Marshal.ReleaseComObject(doc);, where doc is the IDocument, and document is released and I'm free to close it from the interface. *now the question is how can I do the some staff as ReleaseComObject dose in python ?* its the Release method of the |IUnknown|interface the right way to do that ? any hint is really appreciated, thanks Regards, Matteo -------------- next part -------------- An HTML attachment was scrubbed... URL: From Andrew.MacIntyre at acma.gov.au Tue Sep 11 02:47:40 2012 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Tue, 11 Sep 2012 00:47:40 +0000 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] In-Reply-To: <504E2A9F.9060206@boscolini.eu> References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> <504E2A9F.9060206@boscolini.eu> Message-ID: [sorry for top-post] You probably need to release the Python object that is wrapping the COM object. Given a variable x holding a COM object reference, either: del x or x = None should force release of any COM object reference. Which to use depends on taste and context - the latter approach for example being perhaps more usual when dealing with object attributes. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Matteo Boscolo Sent: Tuesday, 11 September 2012 4:00 AM To: python-win32 at python.org Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? Hi All, I'm Working on a cad program using the it's com interface I have a python com object in witch I call a method as follows .. props=ent.Properties(True) #Ent is a IDocument this method is working well, and return a tuple of ITDProperty that are the property of the document. The problem is when I close the document from the Cad application, the Cad application is unable to close the document because there is some reference still active. I tried several way using the gc.collect(), to set to null each document pointer but with no result. I tried to do the some kind of operation with c# and using the Marshal.ReleaseComObject(doc);, where doc is the IDocument, and document is released and I'm free to close it from the interface. now the question is how can I do the some staff as ReleaseComObject dose in python ? its the Release method of the IUnknown interface the right way to do that ? any hint is really appreciated, thanks Regards, Matteo NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From raf at raf.org Tue Sep 11 05:23:13 2012 From: raf at raf.org (raf) Date: Tue, 11 Sep 2012 13:23:13 +1000 Subject: [python-win32] HKLM\SOFTWARE\...\ProfileList\... registry subkeyquery In-Reply-To: References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> Message-ID: <20120911032313.GA12407@raf.org> Roger Upole wrote: > raf wrote: > > Roger Upole wrote: > >> > >> win32security.LookupAccountName will give you the complete sid for a username. > > > > if you look at the code i supplied, you'll see that that is precisely > > where i get the sid from: > > > > sid = win32security.ConvertSidToStringSid(win32security.LookupAccountName(None, username)[0]) > > > > so win32security.LookupAccountName is not giving me the complete sid for the username. > > any idea why it isn't doing so? any idea what i'm doing wrong? > > Sorry, from a first glance I thought you were deliberately retrieving the machine's SID and then > looking for the accounts under it. It appears you have a machine named the same as the user, > and the call to LookupAccountName is finding the computer name first. that's correct. so it was probably working in the past when the hostnames didn't match the usernames but now that they do match, it no longer works. silly me. given its name i thought it was looking up the name of an account on the computer not the computer itself. :-) > Try passing \\machine\username instead of just the bare user name. > > Roger hi roger, i tried that and got the following error: error: (1332, 'LookupAccountName', 'No mapping between account names and security IDs was done.') according to microsoft's documentation (http://msdn.microsoft.com/en-us/library/windows/desktop/aa379159%28v=vs.85%29.aspx) the username should be domainname\username not \\hostname\username but it also says that a fqdn can be used instead of a windows domain name. if i use the unqualified hostname (as returned by win32api.GetComputerName()), it works. so the leading \\ needs to be absent. and it even works when the windows computer name isn't the same as the dns hostname. many thanks for your help. it's all good now. working code is below. cheers, raf #!/usr/bin/env python '''This module contains the user() and home() functions that return the current user's name on Windows, and the given or current user's home directory on Windows (even if it's been changed in the registry). 20120911 raf ''' import win32api, win32net, win32netcon, win32security, _winreg, pywintypes def user(has_domain_controller=True): '''Return the current user's name on Windows. If has_domain_controller is True when you have no domain controller there may (or may not) be an annoying delay so pass False unless you really have a domain controller.''' dcname = None if has_domain_controller: try: dctype = win32netcon.SV_TYPE_DOMAIN_CTRL dcinfo = win32net.NetServerEnum(None, 100, dctype) dcname = r'\\' + dcinfo[0][0]['name'] except (pywintypes.error, IndexError, KeyError): pass return win32net.NetUserGetInfo(dcname, win32api.GetUserName(), 1)['name'] def home(username=None, has_domain_controller=True): '''Return the given or current user's home directory on Windows even if it's been changed it in the registry. If has_domain_controller is True when you have no domain controller there may (or may not) be an annoying delay so pass False unless you really have a domain controller.''' if username is None: username = user(has_domain_controller) lookup_username = username hostname = win32api.GetComputerName() if '\\' not in lookup_username: lookup_username = hostname + '\\' + lookup_username sid = win32security.LookupAccountName(None, lookup_username)[0] sid = win32security.ConvertSidToStringSid(sid) key = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\' + sid key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key) val, typ = _winreg.QueryValueEx(key, 'ProfileImagePath') if typ == _winreg.REG_EXPAND_SZ: # Which it is val = win32api.ExpandEnvironmentStrings(val) # Doesn't return unicode return val if __name__ == '__main__': print('user = %r' % user()) print('home = %r' % home()) From matteo.boscolo at boscolini.eu Tue Sep 11 15:35:18 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Tue, 11 Sep 2012 15:35:18 +0200 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] In-Reply-To: References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> <504E2A9F.9060206@boscolini.eu> Message-ID: <504F3E16.80400@boscolini.eu> I try with both method but with no result: the code is this : def GerPropValue2(self,name): try: oiDoc,ent=self._getCurrentEnt if ent!=None: props=ent.Properties(True) return "aaa" # Go out here for testing pourpuse for i in range(0, len(props)): # check the len it could give some error logging.debug('_getProp : property found %s',str(props[i].Parent.Name)) if props[i].Parent.Name==name: return props[i].Value return None finally: del ent del props del oiDoc props=None tdProp=None oiDoc=None ent=None there is any way to debug how is the object deleted ? regards, Matteo Il 11/09/2012 02:47, Andrew MacIntyre ha scritto: > > [sorry for top-post] > > You probably need to release the Python object that is wrapping the > COM object. > > Given a variable x holding a COM object reference, either: > > del x > > or > > x = None > > should force release of any COM object reference. > > Which to use depends on taste and context -- the latter approach for > example being perhaps more usual when dealing with object attributes. > > -------------------------> "These thoughts are mine alone!" <--------- > > Andrew MacIntyre Operations Branch > > tel: +61 2 6219 5356 Communications Infrastructure Division > > fax: +61 2 6253 3277 Australian Communications & Media Authority > > email: andrew.macintyre at acma.gov.au > http://www.acma.gov.au/ > > *From:*python-win32 > [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] > *On Behalf Of *Matteo Boscolo > *Sent:* Tuesday, 11 September 2012 4:00 AM > *To:* python-win32 at python.org > *Subject:* [python-win32] how can I do marshall.ReleaseComObject in > python ?? > > Hi All, > > I'm Working on a cad program using the it's com interface > > I have a python com object in witch I call a method as follows .. > > props=ent.Properties(True) > #Ent is a IDocument > this method is working well, and return a tuple of ITDProperty > that are the property of the document. > > The problem is when I close the document from the Cad application, the > Cad application is unable to close the document because there is some > reference still active. > I tried several way using the gc.collect(), to set to null each > document pointer but with no result. > I tried to do the some kind of operation with c# and using the > Marshal.ReleaseComObject(doc);, where doc is the IDocument, and > document is released and I'm free to close it from the interface. > > *now the question is how can I do the some staff as ReleaseComObject > dose in python ?* > > its the Release method of the |IUnknown|interface the right way to do > that ? > > any hint is really appreciated, thanks > > Regards, > Matteo > > > > NOTICE: This email message is for the sole use of the intended > recipient(s) > and may contain confidential and privileged information. Any unauthorized > review, use, disclosure or distribution is prohibited. If you are not the > intended recipient, please contact the sender by reply email and > destroy all > copies of the original message. > > > > _______________________________________________ > 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: From rsyring at gmail.com Tue Sep 11 16:08:43 2012 From: rsyring at gmail.com (Randy Syring) Date: Tue, 11 Sep 2012 10:08:43 -0400 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] In-Reply-To: <504F3E16.80400@boscolini.eu> References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> <504E2A9F.9060206@boscolini.eu> <504F3E16.80400@boscolini.eu> Message-ID: <504F45EB.4080308@gmail.com> I'm not sure how this applies to COM and the python interface to it, but just setting a value to None doesn't usually force the object to go away in Python. That won't happen until it is garbage collected, which you can force if needed: http://docs.python.org/library/gc.html --------------------------------------------- Randy Syring Development & Executive Director Level 12 Technologies Direct: 502-276-0459 Office: 502-212-9913 Principled People, Technology that Works On 09/11/2012 09:35 AM, Matteo Boscolo wrote: > I try with both method but with no result: > the code is this : > def GerPropValue2(self,name): > try: > oiDoc,ent=self._getCurrentEnt > if ent!=None: > props=ent.Properties(True) > > return "aaa" # Go out here for testing pourpuse > > for i in range(0, len(props)): # check the len it > could give some error > logging.debug('_getProp : property found > %s',str(props[i].Parent.Name)) > if props[i].Parent.Name==name: > return props[i].Value > return None > finally: > del ent > del props > del oiDoc > props=None > tdProp=None > oiDoc=None > ent=None > > there is any way to debug how is the object deleted ? > > regards, > Matteo > > > Il 11/09/2012 02:47, Andrew MacIntyre ha scritto: >> >> [sorry for top-post] >> >> You probably need to release the Python object that is wrapping the >> COM object. >> >> Given a variable x holding a COM object reference, either: >> >> del x >> >> or >> >> x = None >> >> should force release of any COM object reference. >> >> Which to use depends on taste and context ? the latter approach for >> example being perhaps more usual when dealing with object attributes. >> >> -------------------------> "These thoughts are mine alone!" <--------- >> >> Andrew MacIntyre Operations Branch >> >> tel: +61 2 6219 5356 Communications Infrastructure Division >> >> fax: +61 2 6253 3277 Australian Communications & Media Authority >> >> email: andrew.macintyre at acma.gov.au >> http://www.acma.gov.au/ >> >> *From:*python-win32 >> [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] >> *On Behalf Of *Matteo Boscolo >> *Sent:* Tuesday, 11 September 2012 4:00 AM >> *To:* python-win32 at python.org >> *Subject:* [python-win32] how can I do marshall.ReleaseComObject in >> python ?? >> >> Hi All, >> >> I'm Working on a cad program using the it's com interface >> >> I have a python com object in witch I call a method as follows .. >> >> props=ent.Properties(True) >> #Ent is a IDocument >> this method is working well, and return a tuple of ITDProperty >> that are the property of the document. >> >> The problem is when I close the document from the Cad application, >> the Cad application is unable to close the document because there is >> some reference still active. >> I tried several way using the gc.collect(), to set to null each >> document pointer but with no result. >> I tried to do the some kind of operation with c# and using the >> Marshal.ReleaseComObject(doc);, where doc is the IDocument, and >> document is released and I'm free to close it from the interface. >> >> *now the question is how can I do the some staff as ReleaseComObject >> dose in python ?* >> >> its the Release method of the |IUnknown|interface the right way to do >> that ? >> >> any hint is really appreciated, thanks >> >> Regards, >> Matteo >> >> >> >> NOTICE: This email message is for the sole use of the intended >> recipient(s) >> and may contain confidential and privileged information. Any >> unauthorized >> review, use, disclosure or distribution is prohibited. If you are not >> the >> intended recipient, please contact the sender by reply email and >> destroy all >> copies of the original message. >> >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > > > > _______________________________________________ > 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: From Andrew.MacIntyre at acma.gov.au Wed Sep 12 02:39:39 2012 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Wed, 12 Sep 2012 00:39:39 +0000 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] In-Reply-To: <504F3E16.80400@boscolini.eu> References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> <504E2A9F.9060206@boscolini.eu> <504F3E16.80400@boscolini.eu> Message-ID: [sorry for top post] I suspect that your problem relates to what objects are being retained by self._getCurrentEnt. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Matteo Boscolo Sent: Tuesday, 11 September 2012 11:35 PM To: python-win32 at python.org Subject: Re: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] I try with both method but with no result: the code is this : def GerPropValue2(self,name): try: oiDoc,ent=self._getCurrentEnt if ent!=None: props=ent.Properties(True) return "aaa" # Go out here for testing pourpuse for i in range(0, len(props)): # check the len it could give some error logging.debug('_getProp : property found %s',str(props[i].Parent.Name)) if props[i].Parent.Name==name: return props[i].Value return None finally: del ent del props del oiDoc props=None tdProp=None oiDoc=None ent=None there is any way to debug how is the object deleted ? regards, Matteo Il 11/09/2012 02:47, Andrew MacIntyre ha scritto: [sorry for top-post] You probably need to release the Python object that is wrapping the COM object. Given a variable x holding a COM object reference, either: del x or x = None should force release of any COM object reference. Which to use depends on taste and context - the latter approach for example being perhaps more usual when dealing with object attributes. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Matteo Boscolo Sent: Tuesday, 11 September 2012 4:00 AM To: python-win32 at python.org Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? Hi All, I'm Working on a cad program using the it's com interface I have a python com object in witch I call a method as follows .. props=ent.Properties(True) #Ent is a IDocument this method is working well, and return a tuple of ITDProperty that are the property of the document. The problem is when I close the document from the Cad application, the Cad application is unable to close the document because there is some reference still active. I tried several way using the gc.collect(), to set to null each document pointer but with no result. I tried to do the some kind of operation with c# and using the Marshal.ReleaseComObject(doc);, where doc is the IDocument, and document is released and I'm free to close it from the interface. now the question is how can I do the some staff as ReleaseComObject dose in python ? its the Release method of the IUnknown interface the right way to do that ? any hint is really appreciated, thanks Regards, Matteo NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Andrew.MacIntyre at acma.gov.au Wed Sep 12 03:00:48 2012 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Wed, 12 Sep 2012 01:00:48 +0000 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNOFFICIAL] In-Reply-To: <504F45EB.4080308@gmail.com> References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> <504E2A9F.9060206@boscolini.eu> <504F3E16.80400@boscolini.eu> <504F45EB.4080308@gmail.com> Message-ID: [sorry for top post] CPython uses reference counting; when the reference count drops to 0, the object is deleted and its memory returned to the heap. CPython?s garbage collector is there to attempt to resolve situations where the reference count is not being allowed to drop to 0 (such as via circular references). CPython?s garbage collector isn?t the same as garbage collection in other languages (such as Java). Setting a variable to None in CPython will definitely force an object to be deleted if its reference count drops to zero. The garbage collector has an additional function (run as a side-effect) which may give the impression of delayed cleanup ? when it is run, it checks the state of Python?s private memory allocator, and if there are unused memory chunks in the private heap it will return them to the OS. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Randy Syring Sent: Wednesday, 12 September 2012 12:09 AM To: python-win32 at python.org Subject: Re: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNCLASSIFIED] I'm not sure how this applies to COM and the python interface to it, but just setting a value to None doesn't usually force the object to go away in Python. That won't happen until it is garbage collected, which you can force if needed: http://docs.python.org/library/gc.html --------------------------------------------- Randy Syring Development & Executive Director Level 12 Technologies Direct: 502-276-0459 Office: 502-212-9913 Principled People, Technology that Works On 09/11/2012 09:35 AM, Matteo Boscolo wrote: I try with both method but with no result: the code is this : def GerPropValue2(self,name): try: oiDoc,ent=self._getCurrentEnt if ent!=None: props=ent.Properties(True) return "aaa" # Go out here for testing pourpuse for i in range(0, len(props)): # check the len it could give some error logging.debug('_getProp : property found %s',str(props[i].Parent.Name)) if props[i].Parent.Name==name: return props[i].Value return None finally: del ent del props del oiDoc props=None tdProp=None oiDoc=None ent=None there is any way to debug how is the object deleted ? regards, Matteo Il 11/09/2012 02:47, Andrew MacIntyre ha scritto: [sorry for top-post] You probably need to release the Python object that is wrapping the COM object. Given a variable x holding a COM object reference, either: del x or x = None should force release of any COM object reference. Which to use depends on taste and context ? the latter approach for example being perhaps more usual when dealing with object attributes. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ From: python-win32 [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Matteo Boscolo Sent: Tuesday, 11 September 2012 4:00 AM To: python-win32 at python.org Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? Hi All, I'm Working on a cad program using the it's com interface I have a python com object in witch I call a method as follows .. props=ent.Properties(True) #Ent is a IDocument this method is working well, and return a tuple of ITDProperty that are the property of the document. The problem is when I close the document from the Cad application, the Cad application is unable to close the document because there is some reference still active. I tried several way using the gc.collect(), to set to null each document pointer but with no result. I tried to do the some kind of operation with c# and using the Marshal.ReleaseComObject(doc);, where doc is the IDocument, and document is released and I'm free to close it from the interface. now the question is how can I do the some staff as ReleaseComObject dose in python ? its the Release method of the IUnknown interface the right way to do that ? any hint is really appreciated, thanks Regards, Matteo NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matteo.boscolo at boscolini.eu Wed Sep 12 09:58:10 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Wed, 12 Sep 2012 09:58:10 +0200 Subject: [python-win32] how can I do marshall.ReleaseComObject in python ?? [SEC=UNOFFICIAL] In-Reply-To: References: <20120906044808.GA26814@raf.org> <20120907133026.GA21098@raf.org> <504E2A9F.9060206@boscolini.eu> <504F3E16.80400@boscolini.eu> <504F45EB.4080308@gmail.com> Message-ID: <50504092.9000304@boscolini.eu> Finally I solved the problem using the attached function to release the com object def ReleaseDocumentReference(self,doc): if not is_tracked( doc._oleobj_): x=doc._oleobj_ if is_tracked(x): print "Now x is traked" addr = int(repr(x).split()[-1][2:-1], 16) from ctypes import * from comtypes.automation import IDispatch from _ctypes import CopyComPointer p = POINTER(IDispatch)() cast(byref(p), POINTER(c_void_p))[0] = addr if is_tracked(p): print "Now is traked" p.Release() the problem was due to the doc._oleobj_ that contains the PyIDispatch object that was not tracked by the garbage collector .. regards, Matteo Il 12/09/2012 03:00, Andrew MacIntyre ha scritto: > > [sorry for top post] > > CPython uses reference counting; when the reference count drops to 0, > the object is deleted and its memory returned to the heap. > > CPython's garbage collector is there to attempt to resolve situations > where the reference count is not being allowed to drop to 0 (such as > via circular references). CPython's garbage collector isn't the same > as garbage collection in other languages (such as Java). > > Setting a variable to None in CPython will definitely force an object > to be deleted if its reference count drops to zero. > > The garbage collector has an additional function (run as a > side-effect) which may give the impression of delayed cleanup -- when > it is run, it checks the state of Python's private memory allocator, > and if there are unused memory chunks in the private heap it will > return them to the OS. > > -------------------------> "These thoughts are mine alone!" <--------- > > Andrew MacIntyre Operations Branch > > tel: +61 2 6219 5356 Communications Infrastructure Division > > fax: +61 2 6253 3277 Australian Communications & Media Authority > > email: andrew.macintyre at acma.gov.au > http://www.acma.gov.au/ > > *From:*python-win32 > [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] > *On Behalf Of *Randy Syring > *Sent:* Wednesday, 12 September 2012 12:09 AM > *To:* python-win32 at python.org > *Subject:* Re: [python-win32] how can I do marshall.ReleaseComObject > in python ?? [SEC=UNCLASSIFIED] > > I'm not sure how this applies to COM and the python interface to it, > but just setting a value to None doesn't usually force the object to > go away in Python. That won't happen until it is garbage collected, > which you can force if needed: > > http://docs.python.org/library/gc.html > > --------------------------------------------- > Randy Syring > Development & Executive Director > Level 12 Technologies > Direct: 502-276-0459 > Office: 502-212-9913 > > Principled People, Technology that Works > > On 09/11/2012 09:35 AM, Matteo Boscolo wrote: > > I try with both method but with no result: > the code is this : > def GerPropValue2(self,name): > try: > oiDoc,ent=self._getCurrentEnt > if ent!=None: > props=ent.Properties(True) > > return "aaa" # Go out here for testing pourpuse > > for i in range(0, len(props)): # check the len it > could give some error > logging.debug('_getProp : property found > %s',str(props[i].Parent.Name)) > if props[i].Parent.Name==name: > return props[i].Value > return None > finally: > del ent > del props > del oiDoc > props=None > tdProp=None > oiDoc=None > ent=None > > there is any way to debug how is the object deleted ? > > regards, > Matteo > > > Il 11/09/2012 02:47, Andrew MacIntyre ha scritto: > > [sorry for top-post] > > You probably need to release the Python object that is > wrapping the COM object. > > Given a variable x holding a COM object reference, either: > > del x > > or > > x = None > > should force release of any COM object reference. > > Which to use depends on taste and context -- the latter > approach for example being perhaps more usual when dealing > with object attributes. > > -------------------------> "These thoughts are mine alone!" > <--------- > > Andrew MacIntyre Operations Branch > > tel: +61 2 6219 5356 Communications Infrastructure Division > > fax: +61 2 6253 3277 Australian Communications & Media > Authority > > email: andrew.macintyre at acma.gov.au > http://www.acma.gov.au/ > > *From:*python-win32 > [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] > *On Behalf Of *Matteo Boscolo > *Sent:* Tuesday, 11 September 2012 4:00 AM > *To:* python-win32 at python.org > *Subject:* [python-win32] how can I do > marshall.ReleaseComObject in python ?? > > Hi All, > > I'm Working on a cad program using the it's com interface > > I have a python com object in witch I call a method as follows .. > > props=ent.Properties(True) > #Ent is a IDocument > this method is working well, and return a tuple of > ITDProperty that are the property of the document. > > The problem is when I close the document from the Cad > application, the Cad application is unable to close the > document because there is some reference still active. > I tried several way using the gc.collect(), to set to null > each document pointer but with no result. > I tried to do the some kind of operation with c# and using the > Marshal.ReleaseComObject(doc);, where doc is the IDocument, > and document is released and I'm free to close it from the > interface. > > *now the question is how can I do the some staff as > ReleaseComObject dose in python ?* > > its the Release method of the |IUnknown|interface the right > way to do that ? > > any hint is really appreciated, thanks > > Regards, > Matteo > > > > > NOTICE: This email message is for the sole use of the intended > recipient(s) > and may contain confidential and privileged information. Any > unauthorized > review, use, disclosure or distribution is prohibited. If you > are not the > intended recipient, please contact the sender by reply email > and destroy all > copies of the original message. > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > NOTICE: This email message is for the sole use of the intended > recipient(s) > and may contain confidential and privileged information. Any unauthorized > review, use, disclosure or distribution is prohibited. If you are not the > intended recipient, please contact the sender by reply email and > destroy all > copies of the original message. > > > > _______________________________________________ > 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: From hartmut.niemann at siemens.com Wed Sep 12 18:33:53 2012 From: hartmut.niemann at siemens.com (Niemann, Hartmut) Date: Wed, 12 Sep 2012 18:33:53 +0200 Subject: [python-win32] ValueError in relpath Message-ID: Hello! I am not subscribed to this mailing list (so CC me on all replies please), but I encountered something that looks like a Windows related bug to me and hope that somebody knows how to take care of it in the python way. I have a tool that traverses and compares large file trees. Occasionally it fails with: File "F:\doublettenweg.py", line 53, in removedups relfilename = os.path.relpath(oldfilename,oldroot) File "C:\Python27\lib\ntpath.py", line 512, in relpath % (path_prefix, start_prefix)) ValueError: path is on drive , start on drive F: I found out, that (in C:\Python27\lib\ntpath.py) path_prefix is empty because internally nt._getfullpathname(path) is used, which silently returns path on error (which is relative). So relpath(), which converts both paths to absolute paths and has them split into parts, will try to split a relative path into drive and path, which leads to the ValueError I see. This is Python 2.7.3 on Windows XP. My conclusions: (1) I wonder what limitation on windows was hit by the _getfullpathname(path) call. The file name is long but not so exceptionally long. Maybe this is a python problem that can be fixed? (2) The fact that abspath(path) swallows the windows error, returning something that is definitely wrong (a relative path where an absolute one is expected) makes it hard to use it safely. Could it simply not catch the WindowsError or raise an Error (which one?)? (3) why does relpath() need absolute paths at all? Could it work without this path normalisation if both paths are relative and path.startswith(start) is true? With best regards Hartmut Niemann Additional information: this part of my program ------8<------------ try: relfilename = os.path.relpath(oldfilename,oldroot) except ValueError as e: print ("os.path.relpath failed:") print ("path = ", repr(oldfilename)) print ("start = ", repr(oldroot)) print ("_abspath_split(path) returns ", ntpath._abspath_split(oldfilename)) print ("normpath(path) = ", ntpath.normpath(oldfilename)) print ("abspath(normpath(path)) = ", ntpath.abspath(ntpath.normpath(oldfilename))) try: print ("_getfullpathname(path) = ", _getfullpathname(oldfilename)) except: print ("_getfullpathname(path) failed.") raise e -----8<------- prints out: ----8<------ os.path.relpath failed: path = '2012-08-07_diffzu_2012-09-12\\PRJ\\I1SITRAC\\wrk\\130_Eclipse\\Workspace\\.metadata\\.plugins\\com.python.pydev.analysis\\python_v1_eo3pb4rfuku7u65tfbb ltnbp5\\v1_indexcache\\pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache' start = '2012-08-07_diffzu_2012-09-12' _abspath_split(path) returns (False, '', ['2012-08-07_diffzu_2012-09-12', 'PRJ', 'I1SITRAC', 'wrk', '130_Eclipse', 'Workspace', '.metadata', '.plugins', 'com.p ython.pydev.analysis', 'python_v1_eo3pb4rfuku7u65tfbbltnbp5', 'v1_indexcache', 'pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcac he']) normpath(path) = 2012-08-07_diffzu_2012-09-12\PRJ\I1SITRAC\wrk\130_Eclipse\Workspace\.metadata\.plugins\com.python.pydev.analysis\python_v1_eo3pb4rfuku7u65tfbb ltnbp5\v1_indexcache\pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache abspath(normpath(path)) = 2012-08-07_diffzu_2012-09-12\PRJ\I1SITRAC\wrk\130_Eclipse\Workspace\.metadata\.plugins\com.python.pydev.analysis\python_v1_eo3pb4rfuk u7u65tfbbltnbp5\v1_indexcache\pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache _getfullpathname(path) failed. Traceback (most recent call last): File "F:\doublettenweg.py", line 115, in removedups(args.oldroot, args.newroot, args.testrun) File "F:\doublettenweg.py", line 68, in removedups raise e ValueError: path is on drive , start on drive F: ----8<------- This is the relevant abspath implementation in C:\Python27\lib\ntpath.py: ----8<----- else: # use native Windows method on Windows def abspath(path): """Return the absolute version of a path.""" if path: # Empty path must return current working directory. try: path = _getfullpathname(path) except WindowsError: pass # Bad path - return unchanged. elif isinstance(path, unicode): path = os.getcwdu() else: path = os.getcwd() return normpath(path) ----8<----- Mit freundlichen Gr??en Dr. Hartmut Niemann Siemens AG Infrastructure & Cities Sector Rail Systems Division Locomotives and Components IC RL LOC EN LE 8 Werner-von-Siemens-Str. 67 91052 Erlangen, Deutschland Tel.: +49 9131 7-34264 Fax: +49 9131 7-26254 mailto:hartmut.niemann at siemens.com Siemens Aktiengesellschaft: Vorsitzender des Aufsichtsrats: Gerhard Cromme; Vorstand: Peter L?scher, Vorsitzender; Roland Busch, Brigitte Ederer, Klaus Helmrich, Joe Kaeser, Barbara Kux, Hermann Requardt, Siegfried Russwurm, Peter Y. Solmssen, Michael S??; Sitz der Gesellschaft: Berlin und M?nchen, Deutschland; Registergericht: Berlin Charlottenburg, HRB 12300, M?nchen, HRB 6684; WEEE-Reg.-Nr. DE 23691322 From timr at probo.com Thu Sep 13 19:28:40 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 13 Sep 2012 10:28:40 -0700 Subject: [python-win32] ValueError in relpath In-Reply-To: References: Message-ID: <505217C8.10808@probo.com> Niemann, Hartmut wrote: > I am not subscribed to this mailing list (so CC me on all replies please), How did you send this? The list only accepts postings from members. > This is Python 2.7.3 on Windows XP. > > My conclusions: > > (1) I wonder what limitation on windows was hit by the _getfullpathname(path) call. > The file name is long but not so exceptionally long. Maybe this is a python problem > that can be fixed? How long is the path? Your sample below is only about 150 characters. The GetFullPathName API is limited to 260 characters, unless one uses the Unicode version and uses the \\?\ prefix, which extends that to 32,768. I'll have to check the library source code to see which one they use. > (2) The fact that abspath(path) swallows the windows error, returning > something that is definitely wrong (a relative path where an absolute > one is expected) makes it hard to use it safely. Could it simply > not catch the WindowsError or raise an Error (which one?)? "Which one" is an excellent question. It's not clear what the behavior should be. Perhaps just allowing the WindowsError to leak through would be the safest. > (3) why does relpath() need absolute paths at all? Could it work without this > path normalisation if both paths are relative and path.startswith(start) is true? The relpath operation is tricky, because it's possible for paths to have things like a\b\..\..\c\d\..\other. You generally want to unravel all of that before you begin. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From hartmut.niemann at siemens.com Fri Sep 14 11:03:58 2012 From: hartmut.niemann at siemens.com (Niemann, Hartmut) Date: Fri, 14 Sep 2012 11:03:58 +0200 Subject: [python-win32] ValueError in relpath In-Reply-To: <505217C8.10808@probo.com> References: <505217C8.10808@probo.com> Message-ID: Hello Tim! Thank you for your reply. > -----Urspr?ngliche Nachricht----- > Niemann, Hartmut wrote: > > I am not subscribed to this mailing list (so CC me on all > replies please), > > How did you send this? The list only accepts postings from members. I did nothing special, it obviously accepted mine, or someone accepted it manually. > > > > My conclusions: > > > > (1) I wonder what limitation on windows was hit by the > _getfullpathname(path) call. > > The file name is long but not so exceptionally long. Maybe > this is a python problem > > that can be fixed? > > How long is the path? Your sample below is only about 150 > characters. > The GetFullPathName API is limited to 260 characters, unless one uses > the Unicode version and uses the \\?\ prefix, which extends that to > 32,768. I'll have to check the library source code to see which one > they use. > No, the relative path that crashed it has 245 characters: 2012-08-07_diffzu_2012-09-12\PRJ\I1SITRAC\wrk\130_Eclipse\Workspace\.metadata\.plugins\com.python.pydev.analysis\python_v1_eo3pb4rfuku7u65tfbbltnbp5\v1_indexcache\pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache so the absolute path exceeded 260. That makes sense. This was a real crash, i. e. this is the filename that crashed. I used to have problems with long and strange file names from saving web pages, but this time the problems came (on several places) with internal eclipse data which has quite long (but 'regular', i.e. no special characters) file names. I could do some more tests if you want me to, just tell me what you are interested in. > > > (2) The fact that abspath(path) swallows the windows error, > returning > > something that is definitely wrong (a relative path where > an absolute > > one is expected) makes it hard to use it safely. Could it simply > > not catch the WindowsError or raise an Error (which one?)? > > "Which one" is an excellent question. It's not clear what > the behavior > should be. Perhaps just allowing the WindowsError to leak > through would > be the safest. > > > > (3) why does relpath() need absolute paths at all? Could it > work without this > > path normalisation if both paths are relative and > path.startswith(start) is true? > > The relpath operation is tricky, because it's possible for > paths to have > things like a\b\..\..\c\d\..\other. You generally want to unravel all > of that before you begin. I understand. I used relpath with walk, so the path starts always with base, maybe I'll try to use that knowledge to circumvent the problem. Do you think what I saw is a bug? Can you enter it into the bug database? With best regards Hartmut. From mail at timgolden.me.uk Fri Sep 14 11:09:36 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 14 Sep 2012 10:09:36 +0100 Subject: [python-win32] ValueError in relpath In-Reply-To: References: <505217C8.10808@probo.com> Message-ID: <5052F450.4040805@timgolden.me.uk> On 14/09/2012 10:03, Niemann, Hartmut wrote: > Hello Tim! > > Thank you for your reply. > >> -----Urspr?ngliche Nachricht----- >> Niemann, Hartmut wrote: >>> I am not subscribed to this mailing list (so CC me on all >> replies please), >> >> How did you send this? The list only accepts postings from members. > > I did nothing special, it obviously accepted mine, or someone accepted it manually. I just released this one from the queue. Hartmut: would you mind subscribing to the list, please? Otherwise one of the moderators will have to release each & every one of your posts. You can always unsubscribe later if you wish (and the list is not particularly high-traffic in any case). Thanks TJG From timr at probo.com Fri Sep 14 20:33:42 2012 From: timr at probo.com (Tim Roberts) Date: Fri, 14 Sep 2012 11:33:42 -0700 Subject: [python-win32] ValueError in relpath In-Reply-To: References: <505217C8.10808@probo.com> Message-ID: <50537886.9070609@probo.com> Niemann, Hartmut wrote: > No, the relative path that crashed it has 245 characters: > > 2012-08-07_diffzu_2012-09-12\PRJ\I1SITRAC\wrk\130_Eclipse\Workspace\.metadata\.plugins\com.python.pydev.analysis\python_v1_eo3pb4rfuku7u65tfbbltnbp5\v1_indexcache\pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache > > so the absolute path exceeded 260. That makes sense. > > This was a real crash, i. e. this is the filename that crashed. This goes below wxPython down into wxWidgets. It may be that the best long-term solution is to have wxWidgets switch to the Unicode API with the \??\ prefix, but if you want my personal recommendation, I would just go implement it myself in Python. It's not rocket science. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From fredrik.kant at gmail.com Sun Sep 16 22:05:26 2012 From: fredrik.kant at gmail.com (Fredrik Kant) Date: Sun, 16 Sep 2012 13:05:26 -0700 (PDT) Subject: [python-win32] win32com installation problem X64 Message-ID: <1347825926559-4988902.post@n6.nabble.com> Hi! I have a problem when installing the pywin32-217.win-amd64-py2.6.exe (from Source Forge) when I installed python 2.6 using the python-2.6.amd64.msi. I got the problem on SQL Server 8 R2 and Windows 7 Ultimate. When I run the pywin installer it halts in the post installer section and in Swedish informs me that it can't find a module as: >>>> Traceback (most recent call last): File "", line 612, in File "", line 322, in install File "", line 160, in LoadSystemModule ImportError: DLL load failed: Det g?r inte att hitta den angivna modulen. <<<<<<<<<< I managed on the server installation to copy the pythoncom26.dll, pythoncomloader26.dll and pywintypes26.dll to the standard DLL's directory. Adding some path so that win32\lib\pywintypes.py is found I manage to import, for example Dispatch via: >>>import pywintypes >>>from win32com.client import Dispatch However the import will fail if I omitt the pywintypes import ??? On 32-bit system everything works perfect (atleast on a XP and SQL Server 2003). And I never had any problem with python 2.5. Any idea? PS! I have to use Python 2.6 because I support the SunGard FRONT ARENA system which have python built in since 1996 and now they switch from 2.5 -> 2.6. /Fredrik Kant -- View this message in context: http://python.6.n6.nabble.com/win32com-installation-problem-X64-tp4988902.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From hartmut.niemann at siemens.com Mon Sep 17 10:41:00 2012 From: hartmut.niemann at siemens.com (Niemann, Hartmut) Date: Mon, 17 Sep 2012 10:41:00 +0200 Subject: [python-win32] ValueError in relpath In-Reply-To: <50537886.9070609@probo.com> References: <505217C8.10808@probo.com> <50537886.9070609@probo.com> Message-ID: > Niemann, Hartmut wrote: > > No, the relative path that crashed it has 245 characters: > > > > > 2012-08-07_diffzu_2012-09-12\PRJ\I1SITRAC\wrk\130_Eclipse\Work space\.metadata\.plugins\com.python.pydev.analysis\python_v1> _eo3pb4rfuku7u65tfbbltnbp5\v1_indexcache\pylint.test.input.fun c_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache > > > > so the absolute path exceeded 260. That makes sense. > > > > This was a real crash, i. e. this is the filename that crashed. > > This goes below wxPython down into wxWidgets. It may be that the best > long-term solution is to have wxWidgets switch to the Unicode API with > the \??\ prefix, but if you want my personal recommendation, I would > just go implement it myself in Python. It's not rocket science. No, I am not using wxWidgets, I am using the os.path module. But anyway, I will try my own relpath implementation. Hartmut From etienne.labaume at free.fr Mon Sep 17 17:06:22 2012 From: etienne.labaume at free.fr (=?iso-8859-1?Q?=C9tienne?= Labaume) Date: Mon, 17 Sep 2012 17:06:22 +0200 Subject: [python-win32] win32com installation problem X64 In-Reply-To: <1347825926559-4988902.post@n6.nabble.com> References: <1347825926559-4988902.post@n6.nabble.com> Message-ID: <20120917150622.GA12156@hornet.magickarpet.org> On Sun, Sep 16, 2012 at 01:05:26PM -0700, Fredrik Kant wrote: > I have a problem when installing the pywin32-217.win-amd64-py2.6.exe (from > Source Forge) when I installed python 2.6 using the python-2.6.amd64.msi. [...] > I managed on the server installation to copy the pythoncom26.dll, > pythoncomloader26.dll and pywintypes26.dll to the standard DLL's directory. Not sure that's going to help sort out the problem, but I'll take the opportunity to mention that every time I tried to build and package pywin32 on Windows Server, the installation failed because the installer couldn't find some or all (can't remember precisely) of the DLLs you mentionned above, and I had to manually copy them. Once they were installed, pywin32 worked like expected. My 2 cents. -- ?tienne From mmanfre at gmail.com Mon Sep 17 19:16:01 2012 From: mmanfre at gmail.com (Michael Manfre) Date: Mon, 17 Sep 2012 13:16:01 -0400 Subject: [python-win32] PyPy support Message-ID: Does anyone know the status of pywin32 on PyPy? The only things I can find point toward a sourceforge ticket [1] that has sat untouched since early 2011. [1] http://sourceforge.net/tracker/?func=detail&aid=3244607&group_id=78018&atid=551957 Regards, Michael Manfre -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Sep 17 19:45:57 2012 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Sep 2012 10:45:57 -0700 Subject: [python-win32] ValueError in relpath In-Reply-To: References: <505217C8.10808@probo.com> <50537886.9070609@probo.com> Message-ID: <505761D5.6080005@probo.com> Niemann, Hartmut wrote: > Tim babbled: >> This goes below wxPython down into wxWidgets. It may be that the best >> long-term solution is to have wxWidgets switch to the Unicode API with >> the \??\ prefix, but if you want my personal recommendation, I would >> just go implement it myself in Python. It's not rocket science. > No, I am not using wxWidgets, I am using the os.path module. > But anyway, I will try my own relpath implementation. I apologize for the apparent idiocy of my remarks. I knew you dealing directly with Python's standard library. I was looking in the standard library code, not in the wxPython code. My conclusion still applies, even though the explanation was nonsense. My mailer happens to sort the [python-win32] list and the [wxPython] list into the same folder, and I sometimes have a context failure. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From amauryfa at gmail.com Mon Sep 17 20:13:49 2012 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Mon, 17 Sep 2012 20:13:49 +0200 Subject: [python-win32] PyPy support In-Reply-To: References: Message-ID: Hi, 2012/9/17 Michael Manfre : > Does anyone know the status of pywin32 on PyPy? The only things I can find > point toward a sourceforge ticket [1] that has sat untouched since early > 2011. > > [1] > http://sourceforge.net/tracker/?func=detail&aid=3244607&group_id=78018&atid=551957 pywin32 happens to have a few parts which rely too much on CPython internals, but they were easily fixed. The changes I did at the time are in this repository: https://bitbucket.org/amauryfa/pywin32-pypy and the full patch is available here: http://pastebin.com/YTGPSAYi I remember I could run some demos, but that controlling an Excel Instance for example crashed at some point. Unfortunately I don't have access to any Windows machine anymore, but I would be happy to help anyone who wants to push this development further. -- Amaury Forgeot d'Arc From knowledgealerts at gmail.com Tue Sep 25 05:53:47 2012 From: knowledgealerts at gmail.com (vamsi krishna) Date: Tue, 25 Sep 2012 09:23:47 +0530 Subject: [python-win32] Getting pure virtual function call "R6025" Error Message-ID: Hi, Running on Windows 2003 Server X64,Python 2.5 (32-bit) I am having problems using win32com.client with the HP QTP COM libraries. I'm trying to launch QTP from python by following code: import win32com.client qtp = win32com.client.Dispatch("QuickTest.Application") # starts up QTP qtp.Launch() qtp.Visible = False time.sleep(30) qtp.quit() At first it starts working without any glitches. but currently it is always raising windows c++ error saying "pure virtual function call R6025". Please provide information on how to tackle this issue. Regards, Vamsi. From knowledgealerts at gmail.com Tue Sep 25 06:14:19 2012 From: knowledgealerts at gmail.com (vamsi krishna) Date: Tue, 25 Sep 2012 09:44:19 +0530 Subject: [python-win32] Getting Error "Pure Virtual Function Call R6025" Error Message-ID: Hi, Running on Windows 2003 Server X64,Python 2.5 (32-bit) I am having problems using win32com.client with the HP QTP COM libraries. I'm trying to launch QTP from python by following code: import win32com.client qtp = win32com.client.Dispatch("QuickTest.Application") # starts up QTP qtp.Launch() qtp.Visible = False time.sleep(30) qtp.quit() At first it starts working without any glitches. but currently it is always raising windows c++ error saying "pure virtual function call R6025". Please provide information on how to tackle this issue. Regards, Vamsi. From skippy.hammond at gmail.com Fri Sep 28 02:22:16 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 28 Sep 2012 10:22:16 +1000 Subject: [python-win32] Getting Error "Pure Virtual Function Call R6025" Error In-Reply-To: References: Message-ID: <5064EDB8.90509@gmail.com> I'm afraid there isn't enough information provided here for us to help. At face value, it sounds like a problem in the HP QTP COM libraries. Mark On 25/09/2012 2:14 PM, vamsi krishna wrote: > Hi, > > Running on Windows 2003 Server X64,Python 2.5 (32-bit) > > I am having problems using win32com.client with the HP QTP COM > libraries. I'm trying to launch QTP from python by following code: > > import win32com.client > > qtp = win32com.client.Dispatch("QuickTest.Application") > # starts up QTP > qtp.Launch() > qtp.Visible = False > time.sleep(30) > qtp.quit() > > At first it starts working without any glitches. but currently it is > always raising windows c++ error saying "pure virtual function call > R6025". > > Please provide information on how to tackle this issue. > > > Regards, > Vamsi. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From matteo.boscolo at boscolini.eu Fri Sep 28 14:42:56 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Fri, 28 Sep 2012 14:42:56 +0200 Subject: [python-win32] info on _GetInterfaceCount In-Reply-To: <5064EDB8.90509@gmail.com> References: <5064EDB8.90509@gmail.com> Message-ID: <50659B50.7080801@boscolini.eu> this is the log of part of my application DEBUG:root:__DEL__ DEBUG:root:pythoncom._GetInterfaceCount(): 4 DEBUG:root:pythoncom._GetGatewayCount(): 0| DEBUG:Root:pythoncom.CoUninitialize()| DEBUG:root:pythoncom._GetInterfaceCount(): 4 DEBUG:root:pythoncom._GetGatewayCount(): 0 as you can see the GetInterfaceCount is still at 4 .. there is a way to know witch object are the 4 that came from the GetInterfaceCount ? regards, matteo -------------- next part -------------- An HTML attachment was scrubbed... URL: