469,579 Members | 1,899 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

os listdir access denied when run as a service

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

May 25 '06 #1
2 2785
Thomas Thomas wrote:
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

Remember that services run under a different context than the
foreground login. You can configure services to run under
a user context by editing that info in the service control
panel applet under the Log On tab at the top. The default
is to run the service under Local System account which
probably doesn't have any mapped drives.

-Larry Bates
May 25 '06 #2
In message <ma***************************************@python. org>,
Thomas Thomas <th****@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
May 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Steve | last post: by
3 posts views Thread by jliusolar | last post: by
reply views Thread by ASP.Confused | last post: by
3 posts views Thread by Shailesh Humbad | last post: by
3 posts views Thread by David Thielen | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.