473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 3058
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
Hi, Yesterday I signed up for another dedicated linux server with the hosting company I use and I am having problems getting MySQL 4.1.3 working on it. I've tried just about everything I can...
0
by: George | last post by:
Hello, I'm running an ASPX application "WebApplication1" which consumes a web service (service1.asmx) hosted on a machine with IP (128.1.7.x) . The web service is located in the intranet. The...
3
by: jliusolar | last post by:
Hi I am trying to figure out why an application get this error when I am trying to open the application's asmx file from localhost. I don't have indexing service running(it set as manual and not...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
4
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
3
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
6
by: royan | last post by:
Help please! I have the same problem which this post ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.