On Thu, 25 May 2006, Thomas Thomas wrote:
> I am trying to access a mapped network drive folder. everything works > fine normally. But when i run the application as service I am getting > the error The error is on the line: for filename in os.listdir(folder):#line 25 and I have to assume that the bad call here is to os.listdir(). What's the particular input that's being sent to os.listdir() at the point of failure? As far as I can tell, the error message: > Traceback (most recent call last): > File "docBoxApp.py", line 129, in ? > File "core\PollFiles.pyc", line 332, in doPoll > File "core\PollFiles.pyc", line 47, in createFileList > File "core\PollFiles.pyc", line 25, in addFolderFiles > WindowsError: [Errno 5] Access is denied:'G:\\DT Hot Folder test/*.*' suggests that 'G:\\DT Hot Folder test/*.*' might be the folder being passed. If so, that could be the problem, since os.listdir takes the name of a directory: it does not take a file glob. Can you check to see what 'folder' is being passed into your program in the context of a file service? The problem may simply be bad input. We can check early on this by programming a bit defensively, mandating that on entry to addFolderFiles that 'folder' must be an existing directory: ######################################## def addFolderFiles(folder, filelist=[]): assert os.path.isdir(folder) ... ######################################## in which case, if we get past the assertion, we'll be able to at least know that we're getting in semi-good input. One other note: it is not recommended that we use a list as a default parameter value. That value will be shared among all calls to addFolderFiles, so we will see side effects. See the "Important Warning" in: http://docs.python.org/tut/node6.html#SECTION006710000000000000000 -- http://mail.python.org/mailman/listinfo/python-list