I created a python script and trying to run it as a windows service. In my script I am reading some data from a configuration file . My problem is , if I run the script in python editor it will work fine and when running the same as windows service it throws an error saying that there is no such section in the file
The code that reads the configuration file is as follows,
cp = ConfigParser() cp.read ("feedmonitor.cfg") self._server = cp.get ("mail", "server")
and the configuration file is feedmonitor.cfg and its contents are as follows,
[mail] server=192.168.0.5 port= user= password= [monitor] file = D:\pyscripts\txn_%Y%m%d.log start = 07:30:00 end = 18:00:00 timeout = 180
Error is as follows,
File "d:\pyscripts\FeedMonitor1.py", line 32, in SvcDoRun
File "d:\pyscripts\FeedMonitor1.py", line 60, in loadConfig
File "D:\Python25\Lib\ConfigParser.py", line 511, in get
<class 'ConfigParser.NoSectionError'>: No section: 'mail'
I wonders how the same code behaves differently in these cases.
Any solution on the above will be appreciated,