31 lines
		
	
	
		
			929 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			929 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| #!/usr/bin/env python
 | |
| 
 | |
| import configparser
 | |
| import sys
 | |
| 
 | |
| from aman.config.Server import Server
 | |
| from aman.config.Weather import Weather
 | |
| 
 | |
| class System:
 | |
|     def __init__(self, filepath : str):
 | |
|         config = configparser.ConfigParser()
 | |
|         config.read(filepath)
 | |
| 
 | |
|         # search the required sections
 | |
|         serverSectionAvailable = False
 | |
|         for key in config:
 | |
|             if 'SERVER' == key:
 | |
|                 serverSectionAvailable = True
 | |
|             elif 'WEATHER' == key:
 | |
|                 weatherSectionAvailable = True
 | |
| 
 | |
|         if not serverSectionAvailable:
 | |
|             sys.stderr.write('No server-configuration section found!')
 | |
|             sys.exit(-1)
 | |
|         if not weatherSectionAvailable:
 | |
|             sys.stderr.write('No weather-configuration section found!')
 | |
|             sys.exit(1)
 | |
| 
 | |
|         self.Server = Server(config['SERVER'])
 | |
|         self.Weather = Weather(config['WEATHER'])
 |