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

mark tompkins mdtompkins at home.com
Wed Nov 22 00:20:11 EST 2000


Mark,

self.cfg.readfp() is an instance of ConfigParser class, a standard module.  I
looked at the code for readfp(), which calls __read().  This method does the
job of reading each line of input, and parsing the file, according to the
rules for ConfigParser.  I'm not sure whether this is a regular expression
problem, or not.

I read before another post on ConfigParser, that mentioned case sensitivity
problems.  But why does this problem occur only when the code runs from
within a service??  Why should a standard module fail, when called from
within a service???

I really appreciate the help you've given.

And, the book was amazing.  I always steered away from windows system stuff,
because of the complexity of the apis.  Your book provided an opportunity to
experience a side of windows that I would otherwise never have attempted.

I guess this is where I get off my keester, and start trying to figure this
out myself.

thx

Mark

Mark Hammond wrote:

> 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