[python-win32] Calling random Windows function?

Aahz aahz at pythoncraft.com
Sun Oct 25 22:32:34 CET 2009


On Sun, Oct 25, 2009, Roger Upole wrote:
> Aahz wrote:
>> On Fri, Oct 23, 2009, Tim Roberts wrote:
>>> Aahz wrote:
>>>>
>>>> Perhaps it would be better to think more strategically.  I don't  
>>>> actually
>>>> care about the list of open files.  What I care about is a list of files
>>>> that I want to process and checking whether any of them are open.  What
>>>> would be the canonical way of doing that on Windows?  It doesn't matter
>>>> whether it is in batch or file-by-file.
>>>
>>> Wouldn't the least-effort solution be simply to try to open each file,
>>> and see if the open succeeds?
>>
>> We used to do that, but it was interfering with other programs.  (It's
>> similar to backup, and we don't want to interfere with e.g. Excel, which
>> previously was an issue if someone had an open spreadsheet and tried
>> saving it while we were uploading it.)
>
> Have you tried opening the files for exclusive access (ie no sharing) ?

That's exactly what was causing the problems.  (From what I understand,
this was before I joined the company.)

>> I suppose we could switch to using Volume Shadow Copy, I'm not sure why
>> we didn't try that earlier.
>
> If you decide to use Volume Shadow Copy, I've wrapped some of the
> IVss* interfaces for Python, enough to be able to backup selected
> files from a volume.  Bear in mind that if an application has a file
> open for writing and is not VSS-aware, you may get the file in an
> inconsistent state.

Yeah.  Plus I've done some research and because our software tries to run
backups in "realtime" I think the performance hit of VSS won't be
acceptable.  We really want to find out which files are open so that we
can skip them until later.  I'll just run with Tim Golden's code for now.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In the end, outside of spy agencies, people are far too trusting and
willing to help."  --Ira Winkler


More information about the python-win32 mailing list