os listdir access denied when run as a service
Ian Parker
parker at hiredatum.demon.co.uk
Thu May 25 03:38:32 EDT 2006
In message <mailman.6178.1148529545.27775.python-list at python.org>,
Thomas Thomas <thomas at eforms.co.nz> writes
>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
>
This may be relevant. IIRC, when you run a service under the system
account it doesn't have network access. You need to run it under an
account that does have access to the drive.
Regards
Ian
--
Ian Parker
More information about the Python-list
mailing list