Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'help?': 0.03; 'permissions': 0.04; 'python)': 0.05; 'url:bugs': 0.05; 'function,': 0.07; 'python': 0.08; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'linux': 0.11; 'result.': 0.14; 'wrote:': 0.14; '[1].': 0.16; 'posix': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'useless.': 0.16; 'cc:addr :python-list': 0.17; 'script.': 0.19; 'issue.': 0.19; 'subject:Windows': 0.20; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'fine': 0.22; 'cc:no real name:2**0': 0.23; 'incorrect': 0.23; 'platforms.': 0.23; 'code': 0.24; '(and': 0.25; 'function': 0.25; 'match': 0.26; 'windows': 0.26; 'tried': 0.27; 'problem': 0.28; 'solving': 0.29; 'version': 0.29; 'bit': 0.30; 'cc:addr:python.org': 0.30; 'tjg': 0.30; 'it.': 0.31; 'patch': 0.32; 'does': 0.33; '[1]': 0.34; 'that,': 0.34; 'header:User- Agent:1': 0.35; 'not,': 0.35; 'idea': 0.36; 'issue': 0.37; 'url:python': 0.38; 'url:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'user': 0.39; 'meaning': 0.40; 'really': 0.40; 'help': 0.40; 'received:192.168.1': 0.40; 'from:addr:mail': 0.65; 'to:none': 0.93; 'permission.': 0.93 Date: Thu, 19 May 2011 20:43:55 +0100 From: Tim Golden User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 CC: python-list@python.org Subject: Re: os.access giving incorrect results on Windows References: <21581D39FA3BDF40904D75AF9653CE2606567E4A@blrex.prog.altair.com> In-Reply-To: <21581D39FA3BDF40904D75AF9653CE2606567E4A@blrex.prog.altair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305834251 news.xs4all.nl 49182 [::ffff:82.94.164.166]:34317 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5783 On 19/05/2011 20:37, Ayaskanta Swain wrote: > Please help me in solving this issue. I want to check the write > permissions on a directory on windows from my python script. > > I tried to use *os.access(dirpath, os.W_OK)*to check whether the user > has write access or not, but it gives me incorrect result. It always > gives me False even if the user has write permission. Interestingly this > function works just fine on Linux platforms. This is basically issue2528 [1]. The problem is that, although Windows (and Python) expose a version of os.access to match the Posix function, the meaning is so far removed on Windows as to be useless. Really what you need to do is use the AccessCheck API, which is a little bit tortuous, but is intended for this purpose. You can look at the code in my patch for that issue to get an idea of how to do it. Does that help? TJG [1] http://bugs.python.org/issue2528