Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeder.news-service.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'filename:fname piece:py': 0.04; 'permissions': 0.04; 'suggestions.': 0.07; 'python': 0.08; 'executed': 0.09; 'tim,': 0.09; 'def': 0.12; 'error:': 0.12; 'bangalore': 0.14; 'defined': 0.14; '[errno': 0.16; 'oserror:': 0.16; 'received:203.200': 0.16; 'tests)': 0.16; 'permission': 0.16; 'traceback': 0.16; '(most': 0.16; 'skip:= 70': 0.17; 'suggest': 0.19; 'script.': 0.19; 'subject:Windows': 0.20; 'wrote': 0.22; 'last):': 0.23; 'code': 0.24; 'function': 0.25; 'user.': 0.26; '>': 0.26; '(in': 0.26; 'script': 0.27; 'tried': 0.27; 'thanks': 0.28; '(not': 0.28; 'skip:- 70': 0.29; 'class': 0.29; 'skip:( 20': 0.30; 'ran': 0.30; 'looks': 0.31; 'it.': 0.31; "skip:' 10": 0.32; 'patch': 0.32; 'to:addr:python-list': 0.33; 'error': 0.33; '...': 0.34; 'file': 0.34; 'using': 0.35; 'test': 0.35; 'charset:us-ascii': 0.36; 'open': 0.36; 'skip:& 20': 0.37; 'url:rec-html40': 0.37; 'issue': 0.37; 'checks': 0.37; 'case': 0.37; 'url:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.38; 'to:addr:python.org': 0.39; 'under': 0.40; 'providing': 0.61; 'forward': 0.62; 'content- type:application/octet-stream': 0.63; 'straight': 0.63; 'reply': 0.63; 'denied:': 0.84; 'received:192.168.0.100': 0.84; 'tricky': 0.84 X-IronPort-AV: E=Sophos;i="4.65,242,1304274600"; d="py'?scan'208,217";a="298497" X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01CC16E0.56C00585" Subject: Re: os.access giving incorrect results on Windows Date: Fri, 20 May 2011 16:56:19 +0530 X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: Re: os.access giving incorrect results on Windows Thread-Index: AcwW4L2yHW4fJcD+Sw6G4LJM3DDjJQ== From: "Ayaskanta Swain" To: 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: 327 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305890612 news.xs4all.nl 49179 [::ffff:82.94.164.166]:36187 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5849 This is a multi-part message in MIME format. ------_=_NextPart_001_01CC16E0.56C00585 Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01CC16E0.56C00585" ------_=_NextPart_002_01CC16E0.56C00585 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Tim, =20 Thanks for the reply and suggestions. I followed the patch provided by you in issue 2528, but the code looks very tricky to me. Anyways I wrote my Test.py script & tried only the def test_access_w(self): test case which is defined under class FileTests(unittest.TestCase) by providing my own directory path to check the write permissions on it. =20 I executed my But it failed with the following errors - =20 > python Test.py C:\temp\my_dir test_access_w (__main__.FileTests) ... ERROR =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ERROR: test_access_w (__main__.FileTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "Test.py", line 14, in test_access_w f =3D os.open(dirpath, os.O_CREAT) OSError: [Errno 13] Permission denied: 'C:\\temp\\my_dir' =20 ---------------------------------------------------------------------- Ran 1 test in 0.000s =20 FAILED (errors=3D1) =20 Basically the os.open() function is failing to open a directory (In this case my_dir). The directory has write permissions for the user. Attached herewith is my Test script. Can you please suggest some simple python code which checks the write permissions of a directory in a straight forward way (Not by using unit tests) =20 Thanks Ayaskant- Bangalore =20 ------_=_NextPart_002_01CC16E0.56C00585 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Tim,

 

Thanks for the reply and suggestions. I followed the = patch provided by you in issue 2528, but the code looks very tricky to me. = Anyways I wrote my Test.py script & tried only the def test_access_w(self): = test case which is defined under class FileTests(unittest.TestCase) by providing = my own directory path to check the write permissions on it.

 

I executed my But it failed with the following errors = –

 

> python Test.py = C:\temp\my_dir

test_access_w (__main__.FileTests) ... = ERROR

 

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D

ERROR: test_access_w = (__main__.FileTests)

------------------------------------------------------= ----------------

Traceback (most recent call = last):

  File "Test.py", line 14, in = test_access_w

    f =3D os.open(dirpath, = os.O_CREAT)

OSError: [Errno 13] Permission denied: = 'C:\\temp\\my_dir'

 

------------------------------------------------------= ----------------

Ran 1 test in 0.000s

 

FAILED (errors=3D1)

 

Basically the os.open() function is failing to open a directory (In this case my_dir). The directory has write permissions for = the user. Attached herewith is my Test script. Can you please suggest some = simple python code which checks the write permissions of a directory in a straight = forward way (Not by using unit tests)

 

Thanks

Ayaskant-

Bangalore

 

------_=_NextPart_002_01CC16E0.56C00585-- ------_=_NextPart_001_01CC16E0.56C00585 Content-Type: application/octet-stream; name="Test.py" Content-Transfer-Encoding: base64 Content-Description: Test.py Content-Disposition: attachment; filename="Test.py" aW1wb3J0IG9zDQppbXBvcnQgdW5pdHRlc3QNCmltcG9ydCB3YXJuaW5ncw0KaW1wb3J0IHN5cw0K ZnJvbSB0ZXN0IGltcG9ydCB0ZXN0X3N1cHBvcnQNCg0KZGlycGF0aCA9IHN5cy5hcmd2WzFdDQpj bGFzcyBGaWxlVGVzdHModW5pdHRlc3QuVGVzdENhc2UpOg0KICAgIA0KICAgIGRlZiBzZXRVcChz ZWxmKToNCiAgICAgICAgcGFzcw0KICAgICAgICANCiAgICBkZWYgdGVzdF9hY2Nlc3NfdyhzZWxm KToNCiAgICAgICAgZiA9IG9zLm9wZW4oZGlycGF0aCwgb3MuT19DUkVBVCkNCiAgICAgICAgb3Mu Y2xvc2UoZikNCiAgICAgICAgb3Muc3lzdGVtKCJlY2hvIHl8IGNhY2xzICVzIC9EIEV2ZXJ5b25l IiAlIGRpcnBhdGgpDQogICAgICAgIHNlbGYuYXNzZXJ0Xyhub3Qgb3MuYWNjZXNzKGRpcnBhdGgs IG9zLldfT0spKQ0KICAgICAgICBzZWxmLmFzc2VydF8obm90IG9zLmFjY2Vzcyh1bmljb2RlKGRp cnBhdGgpLCBvcy5XX09LKSkNCiAgICAgICAgb3Muc3lzdGVtKCJlY2hvIHl8IGNhY2xzICVzIC9H IEV2ZXJ5b25lOlIiICUgZGlycGF0aCkNCiAgICAgICAgc2VsZi5hc3NlcnRfKG5vdCBvcy5hY2Nl c3MoZGlycGF0aCwgb3MuV19PSykpDQogICAgICAgIHNlbGYuYXNzZXJ0Xyhub3Qgb3MuYWNjZXNz KHVuaWNvZGUoZGlycGF0aCksIG9zLldfT0spKQ0KICAgICAgICBvcy5zeXN0ZW0oImVjaG8geXwg Y2FjbHMgJXMgL0cgRXZlcnlvbmU6VyIgJSBkaXJwYXRoKQ0KICAgIC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ICJfX21haW5fXyI6DQogICAgdGVzdF9tYWluKCk= ------_=_NextPart_001_01CC16E0.56C00585--