Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5977

Re: List of WindowsError error codes and meanings

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <bahamutzero8825@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; 'attributes': 0.05; 'int': 0.05; 'string,': 0.05; '"""': 0.07; 'python': 0.08; "(it's": 0.09; 'attribute': 0.09; 'tuple': 0.09; 'output': 0.11; 'subject:error': 0.11; 'def': 0.12; 'exception': 0.12; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail-iw0-f174.google.com': 0.14; 'skip:f 30': 0.14; 'wrote:': 0.14; 'errno': 0.16; 'error_msg': 0.16; 'msdn': 0.16; 'object).': 0.16; 'received:192.168.1.6': 0.16; 'windowserror': 0.16; 'header:In-Reply-To:1': 0.21; 'ignore': 0.21; 'code.': 0.22; '2.5,': 0.23; '(and': 0.25; 'function': 0.25; 'subject:List': 0.26; 'match': 0.26; 'string': 0.26; 'windows': 0.26; 'noticed': 0.28; 'received:209.85.214': 0.28; 'typically': 0.28; 'lee': 0.29; 'lists': 0.29; 'bit': 0.30; 'module': 0.30; "skip:' 10": 0.32; 'maps': 0.32; 'to:addr:python-list': 0.33; 'post': 0.33; 'error': 0.33; "i'll": 0.34; 'file': 0.34; 'header:User-Agent:1': 0.35; 'try:': 0.35; 'else': 0.35; 'message-id:@gmail.com': 0.36; 'takes': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'anything': 0.38; 'but': 0.38; 'earlier': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'skip:s 20': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'received:192.168.1': 0.40; 'worth': 0.60; 'more': 0.60; 'here:': 0.62; 'john': 0.62; 'common,': 0.84; 'dir,': 0.84; 'num': 0.84; 'mistaken': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=o2NGXQ/xRMf8V5War6H1pl2UGvXdXHtxZx7HYmhFke0=; b=DeNZ0hBqJH5M5EPdguCx3mkw0ap47MQOau6D0/eFhg+8taVRw2srfL8ZLLLM4sjylJ fMqGx4xwvBPrDM3cxn76WIxSjpwV5ICf1r6JORqTif+Nm4AdG+j6kqZC+yvwSr6HPEAJ kYgMQymmhiaFELnRJCJvP1D1dJAB1gNDe1Sbo=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=AtFpkCPJlCLWEHffxJgZsg7vdZ7yBh/TVfWYT5Fzmh9G2yfTHMTrxth0jABbqCCSub MZlt6ZSyv1rFQT3umaB/jV+/2JBnBNbRK9ji1UfMEC5E1oksW9ioMKE5D08SSepwyqEk 9UoR8NusMVEYWuCrKWp1CuUfQqJGiPrQBppSY=
Date Sun, 22 May 2011 09:35:58 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5
MIME-Version 1.0
To python-list@python.org
Subject Re: List of WindowsError error codes and meanings
References <mailman.1847.1305914213.9059.python-list@python.org> <8762p48eel.fsf@pobox.com>
In-Reply-To <8762p48eel.fsf@pobox.com>
X-Enigmail-Version 1.1.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1916.1306074967.9059.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 82.94.164.166
X-Trace 1306074967 news.xs4all.nl 49174 [::ffff:82.94.164.166]:58495
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5977

Show key headers only | View raw


On 2011.05.21 06:46 AM, John J Lee wrote:
> Since Python 2.5, the errno attribute maps the Windows error to error
> codes that match the attributes of module errno.
I was able to whip up a nifty little function that takes the output of
sys.exc_info() after a WindowsError and return the error code. I was
mistaken in my earlier post about sys.exc_info()[1][0] - I hadn't
noticed the 'WindowsError' bit before the opening parenthesis and
mistook it for a tuple (it's a WindowsError object). Anyway:

> def find_win_error_no(error_msg):
>     """
>     error_msg is a string with the error message - typically
> sys.exc_info()[1] from a WindowsError exception
>     Returns the number as a string, not an int
>     """
>     win_error_re = re.compile('\[Error \d{1,5}\]')
>     win_error_num_re = re.compile('\d{1,5}')
>     win_error = win_error_re.findall(error_msg)[0]
>     return win_error_num_re.findall(win_error)[0]
I call it here:
> def make_prog_dir(dir):
>     try:
>         os.mkdir(dir)
>     except WindowsError:
>         error_info = str(sys.exc_info()[1])
>         num = find_win_error_no(error_msg=error_info)
>         if num == '183': # Error 183 = 'Cannot create a file when that
> file already exists'
>             logger.debug(dir + ' exists.') # Ignore the error, but
> make a note
>         elif num == '5': # Error 5 = 'Access is denied'
>             logger.critical('Could not create', dir, '\(access denied\).')
>         else:
>             logger.critical('Could not create', dir, '-', error_info)
Errors 183 and 5 are going to be the most common, but I'll look at the
lists on MSDN to see if there's anything else worth adding (and
familiarize myself with any more common errors).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-20 12:56 -0500
  Re: List of WindowsError error codes and meanings Genstein <genstein@invalid.invalid> - 2011-05-20 20:47 +0100
    Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-20 16:55 -0500
  Re: List of WindowsError error codes and meanings John J Lee <jjl@pobox.com> - 2011-05-21 12:46 +0100
    Re: List of WindowsError error codes and meanings Genstein <genstein@invalid.invalid> - 2011-05-21 16:35 +0100
      Re: List of WindowsError error codes and meanings John Lee <jjl@pobox.com> - 2011-05-22 17:55 +0000
    Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-22 09:35 -0500
  Re: List of WindowsError error codes and meanings Thomas Heller <theller@ctypes.org> - 2011-05-26 17:02 +0200
    Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-27 04:22 -0500

csiph-web