From webguy at totalrewind.com Sat Mar 4 14:33:17 2017 From: webguy at totalrewind.com (Kurt Eilander) Date: Sat, 4 Mar 2017 12:33:17 -0700 Subject: [python-win32] Windows Tablet Accelerometers Message-ID: Anybody use python to access built-in accelerometers on windoze? I found this: https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Sensors.Accelerometer but it appears to be an (COM??) object, so I hate to do battle with that if somebody has already done the leg-work. -Kurt From webguy at totalrewind.com Sat Mar 4 19:16:09 2017 From: webguy at totalrewind.com (Kurt Eilander) Date: Sat, 4 Mar 2017 17:16:09 -0700 Subject: [python-win32] win32api handle incompatible with ctypes? Message-ID: <8ae5551c-6c4b-d7b0-a355-75c8c0906a6c@totalrewind.com> Hey all, I'm having another problem. I'm wanting to get the size of a dll resource, but... When I do: try: hLib=win32api.GetModuleHandle(fileName) except: hLib=win32api.LoadLibrary(fileName) if hLib==None: raise WindowsError('File not found, '+fileName) hResInfo=ctypes.windll.kernel32.FindResourceW(hLib,index,type) size=ctypes.windll.kernel32.SizeofResource(hLib,hResInfo) It throws: hResInfo=ctypes.windll.kernel32.FindResourceW(hLib,index,type) ctypes.ArgumentError: argument 1: : long int too long to convert Almost like ctypes doesn't like the win32api handle. My machine is 64 bit. Is that what ctypes is not liking? Is there a way around it? -Kurt From timr at probo.com Sat Mar 4 21:40:31 2017 From: timr at probo.com (Tim Roberts) Date: Sat, 4 Mar 2017 18:40:31 -0800 Subject: [python-win32] Windows Tablet Accelerometers In-Reply-To: References: Message-ID: On Mar 4, 2017, at 11:33 AM, Kurt Eilander wrote: > > Anybody use python to access built-in accelerometers on windoze? > > I found this: > https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Sensors.Accelerometer > > but it appears to be an (COM??) object, so I hate to do battle with that > if somebody has already done the leg-work. It's a WinRT class (Windows Runtime), which is even worse. It feels like COM, but it lives in a sandbox. I am not aware of anyone who has managed to integrate WinRT into Python, but I may not be on the cutting edge. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From eryksun at gmail.com Sat Mar 4 23:04:27 2017 From: eryksun at gmail.com (eryk sun) Date: Sun, 5 Mar 2017 04:04:27 +0000 Subject: [python-win32] win32api handle incompatible with ctypes? In-Reply-To: <8ae5551c-6c4b-d7b0-a355-75c8c0906a6c@totalrewind.com> References: <8ae5551c-6c4b-d7b0-a355-75c8c0906a6c@totalrewind.com> Message-ID: On Sun, Mar 5, 2017 at 12:16 AM, Kurt Eilander wrote: > > I'm having another problem. I'm wanting to get the size of a dll resource, > but... > > When I do: > try: > hLib=win32api.GetModuleHandle(fileName) > except: > hLib=win32api.LoadLibrary(fileName) > if hLib==None: > raise WindowsError('File not found, '+fileName) > hResInfo=ctypes.windll.kernel32.FindResourceW(hLib,index,type) > size=ctypes.windll.kernel32.SizeofResource(hLib,hResInfo) > > It throws: > hResInfo=ctypes.windll.kernel32.FindResourceW(hLib,index,type) > ctypes.ArgumentError: argument 1: : > long int too long to convert > > Almost like ctypes doesn't like the win32api handle. > > My machine is 64 bit. Is that what ctypes is not liking? Is there a way > around it? The default conversion for integer arguments is to a 32-bit C int. The implementation calls PyLong_AsLong, for which a 64-bit address can raise an overflow exception on Windows since a C long is always 32-bit on this platform. You're lucky to get an exception. The problem is worse on Unix systems that have a 64-bit C long. The conversion doesn't overflow, but ctypes itself silently casts the address to a 32-bit int. Invariably this causes a segfault, either directly or indirectly due to stack or heap corruption. It looks like you're also not setting restype to a pointer type for FindResourceW. Like with parameters, the default integer conversion type for a function result is a 32-bit C int. A 64-bit result will be silently truncated on Windows as well. Kernel and User handles never exceed 32-bit values, but don't assume that's true of all handles. HMODULE handles break this rule, as do others. Always assume a handle type requires the full range of a pointer. Here are some general suggestions. Use ctypes.WinDLL instead of ctypes.windll (the latter was a bad design for multiple reasons). Load the library with the option use_last_error=True, unless you're working with NT or COM libraries that return NTSTATUS or HRESULT values. Always set the function prototype -- at least argtypes; restype if the function returns a pointer type; and preferably an errcheck function that raises idiomatic exceptions. For example: import winerror import win32api import ctypes from ctypes import wintypes kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) def _check_zero(result, func, args): if not result: raise ctypes.WinError(ctypes.get_last_error()) return args kernel32.FindResourceW.errcheck = _check_zero kernel32.FindResourceW.restype = wintypes.HRSRC kernel32.FindResourceW.argtypes = ( wintypes.HMODULE, # _In_opt_ hModule wintypes.LPCWSTR, # _In_ lpName wintypes.LPCWSTR) # _In_ lpType kernel32.LoadResource.errcheck = _check_zero kernel32.LoadResource.restype = wintypes.HGLOBAL kernel32.LoadResource.argtypes = ( wintypes.HMODULE, # _In_opt_ hModule wintypes.HRSRC) # _In_ hResInfo kernel32.SizeofResource.errcheck = _check_zero kernel32.SizeofResource.restype = wintypes.DWORD kernel32.SizeofResource.argtypes = ( wintypes.HMODULE, # _In_opt_ hModule wintypes.HRSRC) # _In_ hResInfo kernel32.LockResource.restype = wintypes.LPVOID kernel32.LockResource.argtypes = ( wintypes.HGLOBAL,) # _In_ hResData def get_resource(filename, index, rtype): try: hLib = win32api.GetModuleHandle(filename) except win32api.error as e: if e.winerror != winerror.ERROR_MOD_NOT_FOUND: raise hLib = win32api.LoadLibrary(filename) index = wintypes.LPCWSTR(index) # MAKEINTRESOURCE rtype = wintypes.LPCWSTR(rtype) hResInfo = kernel32.FindResourceW(hLib, index, rtype) hRes = kernel32.LoadResource(hLib, hResInfo) size = kernel32.SizeofResource(hLib, hResInfo) addr = kernel32.LockResource(hRes) return ctypes.string_at(addr, size) if __name__ == '__main__': RT_MANIFEST = 24 manifest = get_resource(None, 1, RT_MANIFEST).decode('utf-8') print(manifest) The above demo prints the embedded manifest from python.exe. Of course, it would be a lot simpler to use win32api.LoadResource [1]: manifest = win32api.LoadResource(None, RT_MANIFEST, 1).decode('utf-8') [1]: http://docs.activestate.com/activepython/3.4/pywin32/win32api__LoadResource_meth.html From tfa.signup.test1 at gmail.com Mon Mar 20 11:13:54 2017 From: tfa.signup.test1 at gmail.com (Goku Balu) Date: Mon, 20 Mar 2017 20:43:54 +0530 Subject: [python-win32] Replace all child permissions Message-ID: Hi all, Is there anyway to do "Replace all child object permissions with inheritable permissions from this object" programatically using PyWin32. I found out that this resets the permissions for all the sub-folders and files deep-down even though the permissions are set separately. def remove_permission(path): sd = win32security.GetFileSecurity(path, win32security.DACL_SECURITY_INFORMATION) dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = win32security.ACL() win32security.SetNamedSecurityInfo(path, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION | win32security.UNPROTECTED_DACL_SECURITY_INFORMATION, None, None, dacl, None) I tried this on a folder. But didn't work. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau Mon Mar 20 12:52:02 2017 From: mc at mclaveau (mc at mclaveau) Date: Mon, 20 Mar 2017 17:52:02 +0100 Subject: [python-win32] Replace all child permissions In-Reply-To: References: Message-ID: <79f419d5-82e7-0530-e655-7d3396e86a14@mclaveau.com> Le 20.03.17 ? 16:13, Goku Balu a ?crit : > Hi all, > > Is there anyway to do "Replace all child object permissions with > inheritable permissions from this object" programatically using > PyWin32. I found out that this resets the permissions for all the > sub-folders and files deep-down even though the permissions are set > separately. > > def remove_permission(path): > sd = win32security.GetFileSecurity(path, > win32security.DACL_SECURITY_INFORMATION) > dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = > win32security.ACL() > win32security.SetNamedSecurityInfo(path, > win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION > | win32security.UNPROTECTED_DACL_SECURITY_INFORMATION, None, None, > dacl, None) > > I tried this on a folder. But didn't work. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 Hi! You can call the Windows's command* CACLS *(in command line). @+ -- Michel Claveau -- -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sign-styloplume.GIF Type: image/gif Size: 9129 bytes Desc: not available URL: From eryksun at gmail.com Mon Mar 20 17:46:18 2017 From: eryksun at gmail.com (eryk sun) Date: Mon, 20 Mar 2017 21:46:18 +0000 Subject: [python-win32] Replace all child permissions In-Reply-To: References: Message-ID: On Mon, Mar 20, 2017 at 3:13 PM, Goku Balu wrote: > > Is there anyway to do "Replace all child object permissions with inheritable > permissions from this object" programatically using PyWin32. I found out > that this resets the permissions for all the sub-folders and files deep-down > even though the permissions are set separately. > > def remove_permission(path): > sd = win32security.GetFileSecurity(path, > win32security.DACL_SECURITY_INFORMATION) > dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = > win32security.ACL() > win32security.SetNamedSecurityInfo(path, win32security.SE_FILE_OBJECT, > win32security.DACL_SECURITY_INFORMATION | > win32security.UNPROTECTED_DACL_SECURITY_INFORMATION, None, None, dacl, None) > > I tried this on a folder. But didn't work. The docs for SetNamedSecurityInfo state the following: If you are setting the discretionary access control list (DACL) or any elements in the system access control list (SACL) of an object, the system automatically propagates any inheritable access control entries (ACEs) to existing child objects, according to the rules of inheritance. It works for me when I add an inheritable ACE that denies execute access to files under a given directory, e.g. dacl.AddAccessDeniedAceEx( win32security.ACL_REVISION_DS, win32security.INHERIT_ONLY_ACE | win32security.OBJECT_INHERIT_ACE, ntsecuritycon.FILE_EXECUTE, win32security.LookupAccountName(None, name)[0]) SetNamedSecurityInfo propagates the ACE to a file that's in a subdirectory of the target path. From tfa.signup.test1 at gmail.com Tue Mar 21 05:57:51 2017 From: tfa.signup.test1 at gmail.com (Goku Balu) Date: Tue, 21 Mar 2017 15:27:51 +0530 Subject: [python-win32] Replace all child permissions In-Reply-To: References: Message-ID: Hi Eryk, Thanks for responding. Here's my use case. I deny Write, Delete and Delete_Child permissions for all folders and files under a particular folder to make it read-only. When the user uninstalls our application, we remove the Deny ACE for all the sub-folders and files under it by iterating the folder. However in the UI, this can be easily achieved by removing the Deny ACE for top-most parent and checking "Replace all child object permissions with inheritable permissions from this object" and clicking Yes in the warning dialog. I wonder if this could be done programatically? Regards, Goku On Tue, Mar 21, 2017 at 3:16 AM, eryk sun wrote: > On Mon, Mar 20, 2017 at 3:13 PM, Goku Balu > wrote: > > > > Is there anyway to do "Replace all child object permissions with > inheritable > > permissions from this object" programatically using PyWin32. I found out > > that this resets the permissions for all the sub-folders and files > deep-down > > even though the permissions are set separately. > > > > def remove_permission(path): > > sd = win32security.GetFileSecurity(path, > > win32security.DACL_SECURITY_INFORMATION) > > dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = > > win32security.ACL() > > win32security.SetNamedSecurityInfo(path, > win32security.SE_FILE_OBJECT, > > win32security.DACL_SECURITY_INFORMATION | > > win32security.UNPROTECTED_DACL_SECURITY_INFORMATION, None, None, dacl, > None) > > > > I tried this on a folder. But didn't work. > > The docs for SetNamedSecurityInfo state the following: > > If you are setting the discretionary access control list (DACL) > or any elements in the system access control list (SACL) of an > object, the system automatically propagates any inheritable > access control entries (ACEs) to existing child objects, > according to the rules of inheritance. > > It works for me when I add an inheritable ACE that denies execute > access to files under a given directory, e.g. > > dacl.AddAccessDeniedAceEx( > win32security.ACL_REVISION_DS, > win32security.INHERIT_ONLY_ACE | > win32security.OBJECT_INHERIT_ACE, > ntsecuritycon.FILE_EXECUTE, > win32security.LookupAccountName(None, name)[0]) > > SetNamedSecurityInfo propagates the ACE to a file that's in a > subdirectory of the target path. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tfa.signup.test1 at gmail.com Tue Mar 21 06:08:58 2017 From: tfa.signup.test1 at gmail.com (Goku Balu) Date: Tue, 21 Mar 2017 15:38:58 +0530 Subject: [python-win32] python-win32 Digest, Vol 168, Issue 3 In-Reply-To: References: Message-ID: Hi Michel, Thanks for the response. Yes that's an option available. I've already tried this for setting permissions on files and folders. Since each invocation constitutes a System Call, it fills up the stack easily and the OS denies the handle thereafter. I'm trying to achieve it in a more native and pythonic way. Regards, Goku Le 20.03.17 ? 16:13, Goku Balu a ?crit : > > Hi all, > > > > Is there anyway to do "Replace all child object permissions with > > inheritable permissions from this object" programatically using > > PyWin32. I found out that this resets the permissions for all the > > sub-folders and files deep-down even though the permissions are set > > separately. > > > > def remove_permission(path): > > sd = win32security.GetFileSecurity(path, > > win32security.DACL_SECURITY_INFORMATION) > > dacl = sd.GetSecurityDescriptorDacl() # instead of dacl = > > win32security.ACL() > > win32security.SetNamedSecurityInfo(path, > > win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION > > | win32security.UNPROTECTED_DACL_SECURITY_INFORMATION, None, None, > > dacl, None) > > > > I tried this on a folder. But didn't work. > > Hi! > > You can call the Windows's command* CACLS *(in command line). > > @+ > -- > Michel Claveau > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eryksun at gmail.com Tue Mar 21 09:00:03 2017 From: eryksun at gmail.com (eryk sun) Date: Tue, 21 Mar 2017 13:00:03 +0000 Subject: [python-win32] Replace all child permissions In-Reply-To: References: Message-ID: On Tue, Mar 21, 2017 at 9:57 AM, Goku Balu wrote: > > Thanks for responding. Here's my use case. I deny Write, Delete and > Delete_Child permissions for all folders and files under a particular folder > to make it read-only. > > When the user uninstalls our application, we remove the Deny ACE for all the > sub-folders and files under it by iterating the folder. > > However in the UI, this can be easily achieved by removing the Deny ACE for > top-most parent and checking "Replace all child object permissions with > inheritable permissions from this object" and clicking Yes in the warning > dialog. I wonder if this could be done programatically? I thought you wanted to propagate inheritable permissions, which includes removing inherited permissions from subfolders and files. It should suffice to get the DACL from the base folder via GetNamedSecurityInfo; remove the inheritable ACEs that you no longer want; and then call SetNamedSecurityInfo to set the modified DACL. OTOH, if you need to remove explicitly set permissions, then you'll have to reset each folder and file in the tree one at a time. One approach would be to manually do a top-down walk over the tree, e.g. using os.walk(). Modify the security on each file and directory by writing an empty DACL, i.e. win32security.ACL(), and specifying UNPROTECTED_DACL_SECURITY_INFORMATION. This will reset each file and directory using only inherited permissions. The authorization API has the function TreeSetNamedSecurityInfo to implement this. But PyWin32's win32security module doesn't wrap it for some reason. You may prefer this approach, in which case we can use ctypes to call this function. I wrote a wrapper for this a few minutes ago if you want it. From robin at reportlab.com Wed Mar 22 10:48:18 2017 From: robin at reportlab.com (Robin Becker) Date: Wed, 22 Mar 2017 14:48:18 +0000 Subject: [python-win32] sys.path for windows multiple pythons Message-ID: <43bcd9fe-41c6-5ea9-09af-b3b7899cd997@chamonix.reportlab.co.uk> I have many different pythons installed on my windows 7 development machine. The default python which I use is installed in c:\python27 and I have c:\python27 & c:\python27\scripts in my execution path. However, when I run various other pythons I see the default python path appearing in their sys.path eg default > C:\Users\rptlab>c:\Python27\python.exe -c"import sys;print('\n'.join(sys.path))" > > C:\Python27 > C:\Python27\Scripts > C:\Windows\system32\python27.zip > c:\Python27\DLLs > c:\Python27\lib > c:\Python27\lib\plat-win > c:\Python27\lib\lib-tk > c:\Python27\lib\site-packages > c:\Python27\lib\site-packages\FontTools > c:\Python27\lib\site-packages\win32 > c:\Python27\lib\site-packages\win32\lib > c:\Python27\lib\site-packages\Pythonwin > c:\python27\lib\site-packages python 3.6 > C:\Users\rptlab>"c:\Python36\python.exe" -c"import sys;print('\n'.join(sys.path))" > > C:\Python27 > C:\Python27\Scripts > c:\Python36\python36.zip > c:\Python36\DLLs > c:\Python36\lib > c:\Python36 > c:\Python36\lib\site-packages do I get extra stuff from c:\Python27 because those folders are in my execution PATH variable; seems a bit dodgy to have those folders ending up in a python 3.6 environment. -- Robin Becker From david at graniteweb.com Wed Mar 22 11:14:15 2017 From: david at graniteweb.com (David Rock) Date: Wed, 22 Mar 2017 10:14:15 -0500 Subject: [python-win32] sys.path for windows multiple pythons In-Reply-To: <43bcd9fe-41c6-5ea9-09af-b3b7899cd997@chamonix.reportlab.co.uk> References: <43bcd9fe-41c6-5ea9-09af-b3b7899cd997@chamonix.reportlab.co.uk> Message-ID: <04977511-2E82-4E91-B446-0C16A1E452C1@graniteweb.com> > On Mar 22, 2017, at 09:48, Robin Becker wrote: > > do I get extra stuff from c:\Python27 because those folders are in my execution PATH variable; Yes; that?s how Windows works. > seems a bit dodgy to have those folders ending up in a python 3.6 environment. Python isn?t going to replace your path, it?s going to append to it. If you have the python27 stuff in your path, python36 has no way of knowing the path info is ?dodgy.? As far as it knows, that?s completely acceptable information. Is it actually causing an issue, or does it just look odd? ? David Rock david at graniteweb.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 203 bytes Desc: Message signed with OpenPGP using GPGMail URL: From zachary.ware+pydev at gmail.com Wed Mar 22 11:27:03 2017 From: zachary.ware+pydev at gmail.com (Zachary Ware) Date: Wed, 22 Mar 2017 10:27:03 -0500 Subject: [python-win32] sys.path for windows multiple pythons In-Reply-To: <04977511-2E82-4E91-B446-0C16A1E452C1@graniteweb.com> References: <43bcd9fe-41c6-5ea9-09af-b3b7899cd997@chamonix.reportlab.co.uk> <04977511-2E82-4E91-B446-0C16A1E452C1@graniteweb.com> Message-ID: On Wed, Mar 22, 2017 at 10:14 AM, David Rock wrote: > >> On Mar 22, 2017, at 09:48, Robin Becker wrote: >> >> do I get extra stuff from c:\Python27 because those folders are in my execution PATH variable; > > Yes; that?s how Windows works. No; that's not how Python works. Python does not care about PATH, but it does care about PYTHONPATH. PYTHONPATH should not be set permanently; it should only ever be set by a virtual environment or temporarily to add a particular directory to sys.path. >> seems a bit dodgy to have those folders ending up in a python 3.6 environment. > > Python isn?t going to replace your path, it?s going to append to it. If you have the python27 stuff in your path, python36 has no way of knowing the path info is ?dodgy.? As far as it knows, that?s completely acceptable information. > > Is it actually causing an issue, or does it just look odd? Including "C:\Python27" and "C:\Python27\Scripts" in PYTHONPATH isn't going to cause much issue, because the actual libraries are in C:\Python27\Lib and C:\Python27\DLLs. You would be able to attempt to import from the 2.7 standard library by importing, for example, Lib.argparse, though. -- Zach From robin at reportlab.com Wed Mar 22 13:08:11 2017 From: robin at reportlab.com (Robin Becker) Date: Wed, 22 Mar 2017 17:08:11 +0000 Subject: [python-win32] sys.path for windows multiple pythons In-Reply-To: References: <43bcd9fe-41c6-5ea9-09af-b3b7899cd997@chamonix.reportlab.co.uk> <04977511-2E82-4E91-B446-0C16A1E452C1@graniteweb.com> Message-ID: <3eda8876-8e49-b682-dac1-e4eaa38e49d4@chamonix.reportlab.co.uk> On 22/03/2017 15:27, Zachary Ware wrote: > On Wed, Mar 22, 2017 at 10:14 AM, David Rock wrote: >> >>> On Mar 22, 2017, at 09:48, Robin Becker wrote: >>> >>> do I get extra stuff from c:\Python27 because those folders are in my execution PATH variable; >> >> Yes; that?s how Windows works. > > No; that's not how Python works. Python does not care about PATH, but > it does care about PYTHONPATH. PYTHONPATH should not be set > permanently; it should only ever be set by a virtual environment or > temporarily to add a particular directory to sys.path. > yes I think it's the PYTHONPATH that's doing this. I don't think I have added it though and python seems to work happily without having any pythonpath set. >>> seems a bit dodgy to have those folders ending up in a python 3.6 environment. >> >> Python isn?t going to replace your path, it?s going to append to it. If you have the python27 stuff in your path, python36 has no way of knowing the path info is ?dodgy.? As far as it knows, that?s completely acceptable information. >> >> Is it actually causing an issue, or does it just look odd? > > Including "C:\Python27" and "C:\Python27\Scripts" in PYTHONPATH isn't > going to cause much issue, because the actual libraries are in > C:\Python27\Lib and C:\Python27\DLLs. You would be able to attempt to > import from the 2.7 standard library by importing, for example, > Lib.argparse, though. > I haven't noticed any real oddness, but it causes a bit of worry that something might go wrong. -- Robin Becker From belallioui at gmail.com Wed Mar 22 13:23:51 2017 From: belallioui at gmail.com (Brahim EL ALLIOUI) Date: Wed, 22 Mar 2017 17:23:51 +0000 Subject: [python-win32] Equivalence of win32com.client under Linux Message-ID: Hello, I use win32com.client to integrate a C # dll under python. This works well under windows >From win32com.client import Dispatch, pythoncom >From ctypes import cdll Mydll = cdll.LoadLibrary (spath) Pythoncom.CoInitialize () Zk = Dispatch ("zkemkeeper.ZKEM") But do not works under unix What should you do at the Debian level? Thank you *Brahim EL ALLIOUI* *General Manager* belallioui at e-acta.com Skype : belallioui Tel : +212535749410 Mobile : +212661940077 www.e-acta.com www.actaERP.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From graemeglass at gmail.com Thu Mar 23 10:07:11 2017 From: graemeglass at gmail.com (Graeme Glass) Date: Thu, 23 Mar 2017 16:07:11 +0200 Subject: [python-win32] Equivalence of win32com.client under Linux In-Reply-To: References: Message-ID: Are you running this under WINE? On 22 March 2017 at 19:23, Brahim EL ALLIOUI wrote: > Hello, > > I use win32com.client to integrate a C # dll under python. This works well > under windows > > From win32com.client import Dispatch, pythoncom > From ctypes import cdll > Mydll = cdll.LoadLibrary (spath) > Pythoncom.CoInitialize () > Zk = Dispatch ("zkemkeeper.ZKEM") > > But do not works under unix > > What should you do at the Debian level? > Thank you > > *Brahim EL ALLIOUI* > *General Manager* > belallioui at e-acta.com > Skype : belallioui > Tel : +212535749410 <+212%205357-49410> > Mobile : +212661940077 <+212%20661-940077> > www.e-acta.com > www.actaERP.com > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From planders at gmail.com Thu Mar 23 11:32:19 2017 From: planders at gmail.com (Preston Landers) Date: Thu, 23 Mar 2017 15:32:19 +0000 Subject: [python-win32] Equivalence of win32com.client under Linux In-Reply-To: References: Message-ID: I wouldn't say it's 100% impossible - there is a thing called Mono which allows, subject to numerous limitations, running some .NET code on Linux. However it certainly wouldn't be the easiest path to take. I guess the question is why do you feel the need to run this code under Linux. It would be much easier to run the code on Windows, whether under a virtual machine inside a Linux host or on a separate host. And then write some bridge code - a network server or some other kind of communication channel - to communicate between the Linux process and the Windows one. It all begs the question of why you want to do this under Linux and what the real requirements are. On Thu, Mar 23, 2017 at 10:19 AM Brahim EL ALLIOUI wrote: > Thank you for the answer > > My goal is to interface a C# dll with python > At win32com.client I use just Dispatch and pythoncom, I think there is > probably an equivalent of these two components > > Is there a way to use a C# dll via python on Linux? > > I found in the net pypiwin32 but I can not install it and I do not know is > what it will meet my need or not > > > *Brahim EL ALLIOUI* > *General Manager* > belallioui at e-acta.com > Skype : belallioui > Tel : +212535749410 <+212%205357-49410> > Mobile : +212661940077 <+212%20661-940077> > www.e-acta.com > www.actaERP.com > > > 2017-03-23 14:06 GMT+00:00 Preston Landers : > > Python-Win32 is code that works with "Win32" aka Microsoft Windows. > > Debian is a distribution of Linux, which is a completely different system > that is not compatible with Win32 code. > > The only thing to be done in Debian is install a virtual machine with > Windows inside. > > > On Thu, Mar 23, 2017 at 8:44 AM Brahim EL ALLIOUI > wrote: > > Hello, > > I use win32com.client to integrate a C # dll under python. This works well > under windows > > From win32com.client import Dispatch, pythoncom > From ctypes import cdll > Mydll = cdll.LoadLibrary (spath) > Pythoncom.CoInitialize () > Zk = Dispatch ("zkemkeeper.ZKEM") > > But do not works under unix > > What should you do at the Debian level? > Thank you > > *Brahim EL ALLIOUI* > *General Manager* > belallioui at e-acta.com > Skype : belallioui > Tel : +212535749410 <+212%205357-49410> > Mobile : +212661940077 <+212%20661-940077> > www.e-acta.com > www.actaERP.com > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Mar 23 12:58:48 2017 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Mar 2017 09:58:48 -0700 Subject: [python-win32] Equivalence of win32com.client under Linux In-Reply-To: References: Message-ID: <704ad7df-4612-524d-cbd8-3136d7a51738@probo.com> Brahim EL ALLIOUI wrote: > > I use win32com.client to integrate a C # dll under python. This works > well under windows > > From win32com.client import Dispatch, pythoncom > From ctypes import cdll > Mydll = cdll.LoadLibrary (spath) > Pythoncom.CoInitialize () > Zk = Dispatch ("zkemkeeper.ZKEM") > > But do not works under unix > > What should you do at the Debian level? Well, the first and most difficult thing you have to do is contact ZKTeco and convince them to port zkemkeeper to Linux. Right now, their products only run on Windows. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From belallioui at gmail.com Thu Mar 23 11:44:45 2017 From: belallioui at gmail.com (Brahim EL ALLIOUI) Date: Thu, 23 Mar 2017 15:44:45 +0000 Subject: [python-win32] Equivalence of win32com.client under Linux In-Reply-To: References: Message-ID: The requirement is that we use the odoo erp under windows and we have a module allowing communication with the timers and which uses the sdk of the manufacturer. We want to migrate to linux, everything goes well except this module we have developed ourselves *Brahim EL ALLIOUI* *General Manager* belallioui at e-acta.com Skype : belallioui Tel : +212535749410 Mobile : +212661940077 www.e-acta.com www.actaERP.com 2017-03-23 15:32 GMT+00:00 Preston Landers : > I wouldn't say it's 100% impossible - there is a thing called Mono which > allows, subject to numerous limitations, running some .NET code on Linux. > > However it certainly wouldn't be the easiest path to take. I guess the > question is why do you feel the need to run this code under Linux. > > It would be much easier to run the code on Windows, whether under a > virtual machine inside a Linux host or on a separate host. And then write > some bridge code - a network server or some other kind of communication > channel - to communicate between the Linux process and the Windows one. It > all begs the question of why you want to do this under Linux and what the > real requirements are. > > > > On Thu, Mar 23, 2017 at 10:19 AM Brahim EL ALLIOUI > wrote: > >> Thank you for the answer >> >> My goal is to interface a C# dll with python >> At win32com.client I use just Dispatch and pythoncom, I think there is >> probably an equivalent of these two components >> >> Is there a way to use a C# dll via python on Linux? >> >> I found in the net pypiwin32 but I can not install it and I do not know >> is what it will meet my need or not >> >> >> *Brahim EL ALLIOUI* >> *General Manager* >> belallioui at e-acta.com >> Skype : belallioui >> Tel : +212535749410 <+212%205357-49410> >> Mobile : +212661940077 <+212%20661-940077> >> www.e-acta.com >> www.actaERP.com >> >> >> 2017-03-23 14:06 GMT+00:00 Preston Landers : >> >> Python-Win32 is code that works with "Win32" aka Microsoft Windows. >> >> Debian is a distribution of Linux, which is a completely different system >> that is not compatible with Win32 code. >> >> The only thing to be done in Debian is install a virtual machine with >> Windows inside. >> >> >> On Thu, Mar 23, 2017 at 8:44 AM Brahim EL ALLIOUI >> wrote: >> >> Hello, >> >> I use win32com.client to integrate a C # dll under python. This works >> well under windows >> >> From win32com.client import Dispatch, pythoncom >> From ctypes import cdll >> Mydll = cdll.LoadLibrary (spath) >> Pythoncom.CoInitialize () >> Zk = Dispatch ("zkemkeeper.ZKEM") >> >> But do not works under unix >> >> What should you do at the Debian level? >> Thank you >> >> *Brahim EL ALLIOUI* >> *General Manager* >> belallioui at e-acta.com >> Skype : belallioui >> Tel : +212535749410 <+212%205357-49410> >> Mobile : +212661940077 <+212%20661-940077> >> www.e-acta.com >> www.actaERP.com >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From bobklahn at comcast.net Fri Mar 24 10:43:01 2017 From: bobklahn at comcast.net (Bob Klahn) Date: Fri, 24 Mar 2017 10:43:01 -0400 Subject: [python-win32] import dde failure; server Create failure Message-ID: I'm running 64-bit Python 2.7.13 under Windows 7, and I've installed build 220 of Mark Hammond's package. When I try this: import win32ui, dde from a Windows 7 command window, I receive the message "This must be an MFC application - try 'import win32ui' first". I get the same message when I try three separate imports, in this order: import win32ui import dde When I try the same import statement from PythonWin, it succeeds. And when I follow that up with server = dde.CreateServer() that succeeds as well. But when I follow that up with server.Create("any text here") I get this: Traceback (most recent call last): File "", line 1, in error: The server could not be created What I really need is for dde to work from a Windows 7 command window, but I can't even import it. Help! From bobklahn at comcast.net Fri Mar 24 16:58:30 2017 From: bobklahn at comcast.net (Bob Klahn) Date: Fri, 24 Mar 2017 16:58:30 -0400 Subject: [python-win32] Fwd: import dde failure; server Create failure In-Reply-To: References: Message-ID: <4fdd04d8-83fa-2ac0-af9f-6493a1ab2cf5@comcast.net> I sent the note below before subscribing to this list. Not knowing if one has to be a subscriber first and a sender second, i.e., not knowing if my note below made it to the list, I've decided that I'd better send this out the door again. -------- Forwarded Message -------- Subject: import dde failure; server Create failure Date: Fri, 24 Mar 2017 10:43:01 -0400 To: python-win32 at python.org I'm running 64-bit Python 2.7.13 under Windows 7, and I've installed build 220 of Mark Hammond's package. When I try this: import win32ui, dde from a Windows 7 command window, I receive the message "This must be an MFC application - try 'import win32ui' first". I get the same message when I try three separate imports, in this order: import win32ui import dde When I try the same import statement from PythonWin, it succeeds. And when I follow that up with server = dde.CreateServer() that succeeds as well. But when I follow that up with server.Create("any text here") I get this: Traceback (most recent call last): File "", line 1, in error: The server could not be created What I really need is for dde to work from a Windows 7 command window, but I can't even import it. Help! -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Thu Mar 23 11:49:42 2017 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Thu, 23 Mar 2017 15:49:42 +0000 Subject: [python-win32] Equivalence of win32com.client under Linux In-Reply-To: References: Message-ID: You can call into Mono from CPython on Linux and OSX using pythonnet: https://github.com/pythonnet/pythonnet On Thu, Mar 23, 2017, 10:32 AM Preston Landers wrote: > I wouldn't say it's 100% impossible - there is a thing called Mono which > allows, subject to numerous limitations, running some .NET code on Linux. > > However it certainly wouldn't be the easiest path to take. I guess the > question is why do you feel the need to run this code under Linux. > > It would be much easier to run the code on Windows, whether under a > virtual machine inside a Linux host or on a separate host. And then write > some bridge code - a network server or some other kind of communication > channel - to communicate between the Linux process and the Windows one. It > all begs the question of why you want to do this under Linux and what the > real requirements are. > > > > On Thu, Mar 23, 2017 at 10:19 AM Brahim EL ALLIOUI > wrote: > > Thank you for the answer > > My goal is to interface a C# dll with python > At win32com.client I use just Dispatch and pythoncom, I think there is > probably an equivalent of these two components > > Is there a way to use a C# dll via python on Linux? > > I found in the net pypiwin32 but I can not install it and I do not know is > what it will meet my need or not > > > > *Brahim EL ALLIOUI* > *General Manager* > belallioui at e-acta.com > Skype : belallioui > Tel : +212535749410 <+212%205357-49410> > Mobile : +212661940077 <+212%20661-940077> > www.e-acta.com > www.actaERP.com > > > 2017-03-23 14:06 GMT+00:00 Preston Landers : > > Python-Win32 is code that works with "Win32" aka Microsoft Windows. > > Debian is a distribution of Linux, which is a completely different system > that is not compatible with Win32 code. > > The only thing to be done in Debian is install a virtual machine with > Windows inside. > > > > On Thu, Mar 23, 2017 at 8:44 AM Brahim EL ALLIOUI > wrote: > > Hello, > > I use win32com.client to integrate a C # dll under python. This works well > under windows > > From win32com.client import Dispatch, pythoncom > From ctypes import cdll > Mydll = cdll.LoadLibrary (spath) > Pythoncom.CoInitialize () > Zk = Dispatch ("zkemkeeper.ZKEM") > > But do not works under unix > > What should you do at the Debian level? > Thank you > > *Brahim EL ALLIOUI* > *General Manager* > belallioui at e-acta.com > Skype : belallioui > Tel : +212535749410 <+212%205357-49410> > Mobile : +212661940077 <+212%20661-940077> > www.e-acta.com > www.actaERP.com > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Mar 27 11:28:50 2017 From: timr at probo.com (Tim Roberts) Date: Mon, 27 Mar 2017 08:28:50 -0700 Subject: [python-win32] Equivalence of win32com.client under Linux In-Reply-To: References: Message-ID: <06d55c98-f750-ce93-b94e-12c75c0e0a5e@probo.com> Brahim EL ALLIOUI wrote: > > The requirement is that we use the odoo erp under windows and we have > a module allowing communication with the timers and which uses the sdk > of the manufacturer. We want to migrate to linux, everything goes well > except this module we have developed ourselves Well, hang on. Your original question said you were looking for a way to call the zkemkeeper product from Python on Linux. The big problem with that plan is that Zkemkeeper does not run on Linux. Are you hoping to find a way to call from Python on Linux into Zkemkeeper running on Windows? That's not impossible, but it's a different kind of problem. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Tue Mar 28 20:32:00 2017 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 29 Mar 2017 11:32:00 +1100 Subject: [python-win32] [ANN] pywin32 build 221 released. Message-ID: <5e98d82a-1bdd-5ce1-5f73-4cf4de13e703@skippinet.com.au> Hi all, I'm happy to announce the release of pywin32 build 221. This release has addressed a number of bugs with previous builds (most notably failure to install in Python 3.6) and has added a few new features, mostly around win32com.client.exchange - I've appended the change log at the end of this mail. Downloads are available at: https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/ For initial support (eg, to ask questions about the release etc), please contact this mailing-list (python-win32 at python.org). If you want to report a bug, please do so at https://sf.net/projects/pywin32. As always, thanks to everyone who contributed to this release, both in terms of code and reporting bugs to the tracker. Cheers, Mark. Changes: Since build 220: ---------------- * Add PyIMapiSession::AdminServices method (Nick Czeczulin via patch #161) * Allow win32com.client.CastTo() to have a typelib specified, which will be used to locate the object definition (Pieter Aarnoutse via patch #136) * Add pythoncom.StgOpenStorageOnILockBytes (Nick Czeczulin via patch #135) * IDispatch failures will try and get error information via IErrorInfo (Stefan Schukat via patch #130) * A null SPropTagArray will now return None instead of crashing. * New mapi/exchange interfaces PyIExchangeManageStoreEx, PyIMAPIAdviseSink, PyIMsgStore::Advise, PyIMsgStore::Unadvise, HrAllocAdviseSink, HrThisThreadAdviseSink, and HrDispatchNotifications (Nick Czeczulin)