Pywintypes.error
the examples you like, or click to vote down the exmaples you don't like. Your votes will be used in our system to extract more high-quality examples. You may also check out all available functions/classes of the module pywintypes , or try the search function . Example 1 From project nova-compute-lxd-master, under directory tools, in source file colorizer.py. Score: 10 def supported(cls, stream=sys.stdout): try: import win32console screenBuffer = win32console.GetStdHandle( win32console.STD_OUT_HANDLE) except ImportError: return False import pywintypes try: screenBuffer.SetConsoleTextAttribute( win32console.FOREGROUND_RED | win32console.FOREGROUND_GREEN | win32console.FOREGROUND_BLUE) except pywintypes.error: return False else: return True Example 2 From project searchlight-master, under directory tools, in source file colorizer.py. Score: 10 def supported(stream=sys.stdout): try: import win32console screenBuffer = win32console.GetStdHandle( win32console.STD_OUT_HANDLE) except ImportError: return False import pywintypes try: screenBuffer.SetConsoleTextAttribute( win32console.FOREGROUND_RED | win32console.FOREGROUND_GREEN | win32console.FOREGROUND_BLUE) except pywintypes.error: return False else: return True Example 3 From project play1, under directory python/Lib/site-packages/win32/lib, in source file win32serviceutil.py. Score: 10 def WaitForServiceStatus(serviceName, status, waitSecs, machine=None): """Waits for the service to return the specified status. You should have already requested the service to enter that state""" for i in range(waitSecs*4): now_status = QueryServiceStatus(serviceName, machine)[1] if now_status == status: break win32api.Sleep(250) else: raise pywintypes.error, (winerror.ERROR_SERVICE_REQUEST_TIMEOUT, "QueryServiceStatus", win32api.FormatMessage(winerror.ERROR_SERVICE_REQUEST_TIMEOUT)[:-2]) Example 4 From project nipype, under directory nipype/exter
Perl Lists Python Lists PHP Lists Ruby Lists Tcl Lists ActiveState Lists Lists » python-list Catching a pywintypes.api_error excpeption? From: Mark Hammond Fri, 02 Aug 2002 13:25:10 GMT Peter Hansen wrote: > Derek Basch wrote:> >>Hi,>>Can someone tell me how to catch this exception with a>>try, except clause:>>>> SetCommState(self.handle, dcb)>>pywintypes.api_error: (87, 'SetCommState', 'The>>parameter is incorrect.')>>>>every exception I have previously worked with has been>>a class such as IOError. How do i catch this one?> > > As with "except IOError", just use the name of the class:> > try:> SetCommState(self.handle, http://www.programcreek.com/python/example/1539/pywintypes.error dcb)> except pywintypes.api_error:> print 'spam spam spam spam' It *should* be pywintypes.api_error, but for historical reasons this is not correct :( I have finally fixed it so the exception printed is 'pywintypes.error', which is actually an exception you can catch. In the win32 extensions, every module exposes an 'error' object - and all are the exact same error object. Thus, as these functions come http://code.activestate.com/lists/python-list/290599/ from win32file, you typically catch win32file.error, but pywintypes.error, and basically win32*.error, will all work. ie: >>> pywintypes.error is win32file.error True > (Although this sounds more like an exception coming from> a bug, not a runtime condition that you would want to catch> like an IOError.) No, this is just the standard exception raised by the win32 exceptions whenever the underlying win32 API function fails. The error code is in the exception. Mark. Recent Messages in this Thread Catching a pywintypes.api_error excpeption? Peter Hansen Aug 02, 2002 11:49 am Catching a pywintypes.api_error excpeption? Mark Hammond Aug 02, 2002 01:25 pm ◄ Messages in this thread ► Previous post: Python Bytecode Next post: PIL & fixed-width fonts Subscribe to the python-list RSS feed Accounts List Archives Perl ListsPython ListsPHP ListsRuby ListsTcl ListsActiveState Lists Manage ActiveState Subscriptions Feedback & Information Give Site Feedback Report a Site Problem About FAQ Terms of Service ActiveState ActiveState Blog Perl Solutions Python Solutions Tcl Solutions Download ActivePerl Download ActivePython Download ActiveTcl About ActiveState Careers Privacy Policy | Contact Us | Support © 2016 ActiveState Software Inc. All rights reserved. ActiveState, Komodo, ActiveState Perl Dev Kit, ActiveState Tcl De
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the http://stackoverflow.com/questions/19280894/py2exe-no-system-module-pywintypes workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions https://bytes.com/topic/python/answers/42328-handling-pywintypes-error-exceptions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up py2exe - No system module 'pywintypes' up vote 9 down vote favorite 2 I'm trying to convert a simple Python script into a Windows executable. My setup.py script is: from distutils.core import setup import py2exe setup( name = "Simple Script", options = { "py2exe": { "dll_excludes" : ["libmmd.dll","libifcoremd.dll","libiomp5md.dll","libzmq.dll"] } }, console=['simple_script.py'] ) I have added the dll_excludes as each one of them caused a failure. Now I've hit a failure that I can't simply exlude. This is the error trace: Traceback (most recent call last): File "setup.py", line 12, in console=['rules signed.py'] File "C:\Anaconda\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Anaconda\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\Anaconda\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "C:\Anaconda\lib\site-packages\py2exe\build_exe.py", line 243, in run self._run() File "C:\Anaconda\lib\site-packages\py2exe\build_exe.py", line 306, in _run self.plat_finalize(mf.modules, py_files, extensions, dlls) File "C:\Anaconda\lib\site-packages\py2exe\build_exe.py", line 1157, in plat_finalize import pythoncom File "C:\Anaconda\lib\site-packages\pythoncom.py", line 2, in import pywintypes File "C:\Anaconda\lib\site-packages\win32\lib\pywintypes.py", line 124, in __import_pywin32_system_module__("pywintypes", globals()) File "C:\Anaconda\lib\site-packages\win32\lib\pywintypes.py", line 98, in __import_pywin32_system_module__ raise ImportError("No system module '%s' (%s)" % (modname, filename)) ImportError: No system module 'pywintypes' (pywintypes27.dll) I've installed pywin32 and tried excluding "pywintypes27.dll", "pywintypes", "pywin", "pywin.debugger" in my setup options, with no success. Also tried applying all other solutions I found on SO, such as moving "pythoncom27.dll", "pythoncomloader27.dll", and "pywintypes27.dll" to a top level directory. Nothing has eliminated the "ImportError: No system module 'pywintypes' (pywintypes27.dll)" pr
question and get tips & solutions from a community of 418,626 IT Pros & Developers. It's quick & easy. handling pywintypes.error exceptions P: n/a Lucas Machado I'm using the win32 api to map samba shares, and I'm having trouble handling some exceptions. In my script there are 2 possible exceptions when the script attempts to map a share: win32net.NetUseAdd(None, 1, {'remote':r'\\foo\bar','local':'X Traceback (most recent call last): File "", line 1, in ? pywintypes.error: (53, 'NetUseAdd', 'The network path was not found.') This exception occurs when '\\foo\bar' is not an existing share. Also, when a drive letter is already in use the following occurs: win32net.NetUseAdd(None, 1, {'remote':r'\\some_server\share','local':'Y:'}) Traceback (most recent call last): File "", line 1, in ? pywintypes.error: (85, 'NetUseAdd', 'The local device name is already in use.') I know the exception raised in these cases is "pywintypes.error", but how can i differentiate between the two exceptions? Being able to do this is critical for my script.... Thanks in advance, --Lucas Machado Jul 18 '05 #1 Post Reply Share this Question 1 Reply P: n/a Roger Upole You can capture the extra exception data like this. try: ....win32net.NetUseAdd(None, 1, {'remote':r'\\foo\bar','local':'X except pywintypes.error,details: ....err_code=details[0] .... Roger "Lucas Machado" wrote in message news:11**********************@f14g2000cwb.googlegr oups.com... I'm using the win32 api to map samba shares, and I'm having trouble handling some exceptions. In my script there are 2 possible exceptions when the script attempts to map a share: win32net.NetUseAdd(None, 1, {'remote':r'\\foo\bar','local':'X Traceback (most recent call last): File "", line 1, in ? pywintypes.error: (53, 'NetUseAdd', 'The network path was not found.') This exception occurs when '\\foo\bar' is not an existing share. Also, when a drive letter is already in use the following occurs: win32net.NetUseAdd(None, 1, {'remote':r'\\some_server\share','local':'Y:'}) Traceback (most recent call last): File "", line 1, in ? pywintypes.error: (85, 'NetUseAdd', 'The local device name is already in use.') I know the exception raised in these cases is "pywintypes.error", but how can i differentiate between the two exceptions? Being able to do this is critical for my script.... Thanks in advance, --Lucas Machado ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----=