[Tutor] exception not raised XP file ?

Dave S pythontut at pusspaws.net
Sat Nov 18 12:07:29 CET 2006

Due to some sloppy programming on a commercial app :) I have a problem.

I have some directories on an XP machine, I need to know which of these 
directories (*.cab_tmp) contains a file that that is being accessed by 
another XP program. 

I set it up so that a known file (SIZES.DBF) in a known directory is being 
accessed by said program.

If I attempt to open said file with wordpad I get the error 'the 
document ...SIZES.DBF... is being used by another application and cannot be 
accessed !'

So I wrote the following code 

        posDirNames = filter((lambda x: x[-7:] == 'cab_tmp'), 
        for dirName in posDirNames:
            print dirName

            for fileName in os.listdir(gsrpath + '/' + dirName):

                    file = gsrpath + '/' + dirName + '/' + fileName
                    if fileName == 'SIZES.DBF': print file,
                    f = open(file, 'w')
                    print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                    print fileName, sys.exc_info()

Expecting it to raise an exception when it hits SIZES.DBF because I am opening 
the file to write - no exception is raised. I know it is scanning SIZES.DBF 
because my if statement picks it up.

Any ideas ?


More information about the Tutor mailing list