ActivePython 2.0 - ConfigParser used in a service, or not -- different results

Mark Hammond MarkH at ActiveState.com
Tue Nov 21 19:56:15 EST 2000


Mark Tompkins wrote:

> Hi,
> 
> I have encountered a perplexing problem, when attempting to use a config
> file, which gets read during service startup (read_cfg_file called from
> SvcDoRun()).

...

>                 #x = self.cfgfp.readlines()                      -- when
> this code is uncommented, it works !!!

So uncomment that line ;-)

>                 self.cfg.readfp(self.cfgfp,self.cfgfile)    -- this code
> fails, even though the file is open for read !!!

Well, you are calling a method called "self.readfp", but you havent 
given us the code for it.  The error is in this function somewhere.

>             except Exception,value:
>                servicemanager.LogErrorMsg('unable to read
> :'+repr(self.cfgfp)+ ', except : '+repr(Exception)+' '+repr(value))

Remove the exception handler.  This will cause a "default" error message 
to be written which includes the traceback (or see the "traceback" 
module to get this traceback yourself in your handler).  The traceback 
should give you more information about the error, which is:

> unable to read :<open file 'hotstandby.cfg', mode 'r' at c23420>, except
> : <class exceptions.Exception at b88970> <exceptions.AttributeError
> instance at c233d0>

So, for some reason, your code is causing an attribute error.  You will 
need to know what the attribute is, and exactly where it happened to 
determine the cause.

Mark.




More information about the Python-list mailing list