[python-win32] Python service needs to access network resources

Chris Bennett cman122887 at hotmail.com
Thu Apr 21 00:35:30 CEST 2011




From: cman122887 at hotmail.com
To: roberto.c.aguilar at gmail.com
Subject: RE: [python-win32] Python service needs to access network resources
Date: Wed, 20 Apr 2011 11:10:56 -0500










> Subject: Re: [python-win32] Python service needs to access network resources
> From: roberto.c.aguilar at gmail.com
> Date: Tue, 19 Apr 2011 20:02:34 -0700
> CC: python-win32 at python.org
> To: cman122887 at hotmail.com
> 
> On Apr 19, 2011, at 5:48 PM, Chris Bennett wrote:
> > I have been trying to figure this out for weeks now.
> > I have made a simply Python service on my local computer, but it needs to import a module from the network.
> > I have tried appending the UNC of the folder to the path but it still says "there is no module named X"
> > Then when I tried running the service logged on as NT AUTHORITY\NetworkService it cannot find my service object, even if I point to it with UNC in the registry.
> > I am running out of ideas. Does anybody have any suggestions? Is it a firewall issue?
> > 
> > Windows XP. Python 2.5. 
> 

Thank you Roberto! Because of what you said I got it to work.
I was appending to the path outside of the the service class when i should have been appending it inside.

> Have you tried running the script that imports the module as a stand alone program and _not_ as a service?  Can it access the network module?

 The script imports the module fine if it runs as a stand alone program. So yes it easily accesses the module, but I am logged in under a user that has that network device connected and mapped.
 
> Can os.listdir(unc_path) list the directory?

Yes it can when i run the service logged in under my user name.

> I assume, when you say appending the UNC to the path you mean sys.path?

Correct.

> Have you tried mapping the network drive to a drive letter and adding that to the path?

^^^ THIS SUGGESTION LED ME TO THE ANSWER. When I tried to map the network drive outside the service class it threw an error saying it already existed. When I mapped the network drive and appended the path (appending the UNC worked too), I was able to use the module. much appreciated. This was making me quite aggravated.
 
> If the module is on the local machine does it import properly?

yes it does.

> -Roberto.
> 

-Chris
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110420/0ed56905/attachment.html>


More information about the python-win32 mailing list