Re: os.path.getsize() on Windows

2008-03-21 Thread Martin v. Löwis
>> Why do you say that? It most definitely returns what the size currently >> is, not what it will be in the future (how could it know, anyway). > > I've seen this before, when copying a file in Windows. Windows reports > the size the file will be after the copy is complete (it knows, after > al

Re: os.path.getsize() on Windows

2008-03-21 Thread Paul M¢Nett
Martin v. Löwis wrote: >> def isGrowing(f, timeout): >> ssize = os.path.getsize(f) >> time.sleep(timeout) >> esize =os.path.getsize(f) >> return esize != ssize >> >> On windows, this returns the size of the file as it _will be_, not the >> size that it currently is.

Re: os.path.getsize() on Windows

2008-03-21 Thread Martin v. Löwis
> def isGrowing(f, timeout): > ssize = os.path.getsize(f) > time.sleep(timeout) > esize =os.path.getsize(f) > return esize != ssize > > On windows, this returns the size of the file as it _will be_, not the > size that it currently is. Why do you say that? It most

Re: os.path.getsize() on Windows

2008-03-21 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > I think you're confused. Or possibly I'm confused. Or both. I think it is you, but then I could be wrong. > It seems to me that you're assuming that the OP has opened the file > for reading first, and *then* another process comes along and wants to >

Re: os.path.getsize() on Windows

2008-03-20 Thread Tim Roberts
Sean DiZazzo <[EMAIL PROTECTED]> wrote: > >The overall idea is to be able to tell if a file has finished being >placed in a directory without any control over what is putting it >there. There is simply no way to do this on Windows that works in the general case. -- Tim Roberts, [EMAIL PROTECTED]

Re: os.path.getsize() on Windows

2008-03-20 Thread Steven D'Aprano
On Thu, 20 Mar 2008 10:45:03 -0700, Sean DiZazzo wrote: > After trying again this morning, the file is opened for reading. I must > have had some wonky permissions on that file, so the error method won't > work. Then fix the permissions. -- Steven -- http://mail.python.org/mailman/listinfo/p

Re: os.path.getsize() on Windows

2008-03-20 Thread Steven D'Aprano
On Thu, 20 Mar 2008 13:42:22 +, Duncan Booth wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >> On Wed, 19 Mar 2008 12:34:34 +, Duncan Booth wrote: >>> By default Python on Windows allows you to open a file for reading >>> unless you specify a sharing mode which prevents it: >> >>

Re: os.path.getsize() on Windows

2008-03-20 Thread Duncan Booth
Sean DiZazzo <[EMAIL PROTECTED]> wrote: > In this case, there will be so few people touching the system, that I > think I can get away with having the copy be done from Unix, but it > would be nice to have a general way of knowing this on Windows. > Doesn't the CreateFile call I posted earlier d

Re: os.path.getsize() on Windows

2008-03-20 Thread Sean DiZazzo
On Mar 20, 6:42 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > > On Wed, 19 Mar 2008 12:34:34 +, Duncan Booth wrote: > >> By default Python on Windows allows you to open a file for reading > >> unless you specify a sharing mode which prevents it: > >

Re: os.path.getsize() on Windows

2008-03-20 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 19 Mar 2008 12:34:34 +, Duncan Booth wrote: >> By default Python on Windows allows you to open a file for reading >> unless you specify a sharing mode which prevents it: > > But the OP is talking about another process having opened the fil

Re: os.path.getsize() on Windows

2008-03-19 Thread Steven D'Aprano
On Wed, 19 Mar 2008 12:34:34 +, Duncan Booth wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >> This whole approach >> assumes that Windows does the sensible thing of returning a unique > error >> code when you try to open a file for reading that is already open for >> writing. >> >>

Re: os.path.getsize() on Windows

2008-03-19 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > This whole approach > assumes that Windows does the sensible thing of returning a unique error > code when you try to open a file for reading that is already open for > writing. > So how would you use a file to share data then? By default Python

Re: os.path.getsize() on Windows

2008-03-19 Thread Steven D'Aprano
On Tue, 18 Mar 2008 13:58:33 -0700, Sean DiZazzo wrote: > I'm seeing some behavior that is confusing me. I often use a simple > function to tell if a file is growing...ie being copied into a certain > location. (Can't process it until it's complete) Surely though, under Windows, while something

Re: os.path.getsize() on Windows

2008-03-18 Thread John Machin
On Mar 19, 9:27 am, Sean DiZazzo <[EMAIL PROTECTED]> wrote: > On Mar 18, 2:27 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > > > > Sean DiZazzo <[EMAIL PROTECTED]> wrote: > > > On windows, this returns the size of the file as it _will be_, not the > > > size that it currently is. Is this a featur

Re: os.path.getsize() on Windows

2008-03-18 Thread Sean DiZazzo
On Mar 18, 2:27 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > Sean DiZazzo <[EMAIL PROTECTED]> wrote: > > On windows, this returns the size of the file as it _will be_, not the > > size that it currently is.  Is this a feature?  What is the proper way > > to get the current size of the file?  I not

Re: os.path.getsize() on Windows

2008-03-18 Thread Duncan Booth
Sean DiZazzo <[EMAIL PROTECTED]> wrote: > On windows, this returns the size of the file as it _will be_, not the > size that it currently is. Is this a feature? What is the proper way > to get the current size of the file? I noticed > win32File.GetFileSize() Does that behave the way I expect?