os listdir access denied when run as a service

Thomas Thomas thomas at eforms.co.nz
Wed May 24 23:59:08 EDT 2006


Hi All,

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

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/*.*'


below is my code


def addFolderFiles(folder,filelist=[]):
    logger=ServerInterface.getErrorLogger()
    folder = folder.encode('ascii') #convert path to ascii for  File Method
    for filename in os.listdir(folder):#line 25
            file=os.path.join(folder,filename)
            logger.error("loop file :"+file);
            if os.path.isfile(file):
                logger.error("is file :"+file);
                if ((not (file.find(".tmp")>=0)) and (not
(file.find("~")>=0))):
                    filelist.append(file)
            elif os.path.isdir(file):
                logger.error("file is a directory :"+file);
                addFolderFiles(file,filelist)

def createFileList(files,folders,filelist=[]):
    logger=ServerInterface.getErrorLogger()
    for file in files:
        file = file.encode('ascii') #convert path to ascii for  File Method
        if os.path.isfile(file):
           if ((not (file.find(".tmp")>=0)) and (not (file.find("~")>=0))):
                filelist.append(file)

    for folder in  folders:
        logger.error("got a folder :"+folder);
        logger.error("it was in the list :"+folders.__str__());
        addFolderFiles(folder,filelist)
    return (1,filelist)

anything I can do about this..


-----------------------------------------------------
Thomas Thomas




More information about the Python-list mailing list