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


Groups > comp.lang.python > #33328

Re: Detect file is locked - windows

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
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; 'permissions': 0.07; 'subject:file': 0.07; 'python': 0.09; '"can\'t': 0.09; 'obstacles': 0.09; 'open()': 0.09; 'windows,': 0.09; 'cc:addr :python-list': 0.10; 'anyway': 0.11; "wouldn't": 0.11; 'feedback.': 0.15; 'file,': 0.15; '%s."': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'hypothetical': 0.16; 'merely': 0.16; 'message- id:@timgolden.me.uk': 0.16; 'obviously,': 0.16; 'partly': 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; 'subject:windows': 0.16; 'tjg': 0.16; 'use".': 0.16; 'wanted.': 0.16; 'wrote:': 0.17; 'sort': 0.21; 'precise': 0.22; 'cc:2**0': 0.23; 'this:': 0.23; 'cc:no real name:2**0': 0.24; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'expand': 0.26; 'prevent': 0.27; 'behaviour': 0.29; 'overhead': 0.29; 'source': 0.29; "i'm": 0.29; 'e.g.': 0.30; 'function': 0.30; 'error': 0.30; 'point': 0.31; "who's": 0.32; 'could': 0.32; 'messages,': 0.33; 'received:192.168.100': 0.33; "can't": 0.34; 'something': 0.35; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'possible': 0.37; 'does': 0.37; 'two': 0.37; 'listing': 0.37; 'subject:: ': 0.38; 'speak': 0.38; 'some': 0.38; 'delete': 0.38; 'several': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'first': 0.61; 'information': 0.63; 'more': 0.63; 'realise': 0.65; 'from:addr:mail': 0.71; 'exercise.': 0.84; 'to:none': 0.93
Date Wed, 14 Nov 2012 12:09:07 +0000
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
MIME-Version 1.0
CC python-list@python.org
Subject Re: Detect file is locked - windows
References <2af436e3-1336-42ae-aa2f-9e33135a3f2c@googlegroups.com> <mailman.3676.1352887368.27098.python-list@python.org> <50a385a5$0$6916$e4fe514c@news2.news.xs4all.nl>
In-Reply-To <50a385a5$0$6916$e4fe514c@news2.news.xs4all.nl>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.3680.1352894950.27098.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352894950 news.xs4all.nl 6864 [2001:888:2000:d::a6]:41418
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33328

Show key headers only | View raw


On 14/11/2012 11:51, Hans Mulder wrote:
> It would be nice if he could give specific error messages, e.g.
> 
>     "Can't write %s because it is locked by %s."
> 
> vs.
> 
>     "Can't write %s because you don't have write access."
> 
> I can't speak for Ali, but I'm always annoyed by error messages
> listing several possible cuases, such as "Can't delete file,
> because the source or destination is in use".

(I realise you're not demanding this particular behaviour from Python
but just to expand on what the obstacles are to this at present):

Speaking merely from the point of view of the current Python
implementation on Windows, there are two obstacles to this:

* Python calls into the CRT which simply returns 13 (EACCESS) for both
of these situations. Obviously, Python could do its own thing on
Windows, partly reimplementing what the CRT does anyway and giving more
precise feedback. Equally obviously, this wouldn't be a trivial exercise.

* The added information -- who's locked the file, what permissions are
in place which prevent you gaining the requested access -- is
surprisingly fiddly to get hold of and would be something of an overhead
for the majority of the time when it's not wanted. Of course, in this
hypothetical Python one could add some sort of flag to the open()
function which requested or not the additional information.

The first obstacle is more significant than the second but neither is
negligible.

TJG

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


Thread

Detect file is locked - windows Ali Akhavan <a.akhavan.b@gmail.com> - 2012-11-13 16:33 -0800
  Re: Detect file is locked - windows Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-11-14 01:14 +0000
    Re: Detect file is locked - windows Hans Mulder <hansmu@xs4all.nl> - 2012-11-14 09:55 +0100
      Re: Detect file is locked - windows Tim Golden <mail@timgolden.me.uk> - 2012-11-14 09:06 +0000
  Re: Detect file is locked - windows Tim Golden <mail@timgolden.me.uk> - 2012-11-14 10:02 +0000
    Re: Detect file is locked - windows Hans Mulder <hansmu@xs4all.nl> - 2012-11-14 12:51 +0100
      Re: Detect file is locked - windows Tim Golden <mail@timgolden.me.uk> - 2012-11-14 12:09 +0000
    Re: Detect file is locked - windows aahz@pythoncraft.com (Aahz) - 2012-11-15 08:01 -0800
  Re: Detect file is locked - windows Tim Golden <mail@timgolden.me.uk> - 2012-11-14 11:50 +0000

csiph-web