-
Notifications
You must be signed in to change notification settings - Fork 32
/
pp_resourcereader.py
51 lines (40 loc) · 1.73 KB
/
pp_resourcereader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import ConfigParser
from pp_utils import Monitor
class ResourceReader:
config=None
def __init__(self):
self.mon=Monitor()
self.mon.on()
def read(self,pp_dir,pp_home,pp_profile):
if ResourceReader.config==None:
# try inside profile
tryfile=pp_profile+os.sep+"resources.cfg"
# self.mon.log(self,"Trying resources.cfg in profile at: "+ tryfile)
if os.path.exists(tryfile):
filename=tryfile
else:
# try inside pp_home
# self.mon.log(self,"resources.cfg not found at "+ tryfile+ " trying pp_home")
tryfile=pp_home+os.sep+"resources.cfg"
if os.path.exists(tryfile):
filename=tryfile
else:
# try inside pipresents
# self.mon.log(self,"resources.cfg not found at "+ tryfile + " trying inside pipresents")
tryfile=pp_dir+os.sep+'pp_home'+os.sep+"resources.cfg"
if os.path.exists(tryfile):
filename=tryfile
else:
self.mon.log(self,"resources.cfg not found at "+ tryfile)
self.mon.err(self,"resources.cfg not found")
return False
ResourceReader.config = ConfigParser.ConfigParser()
ResourceReader.config.read(filename)
self.mon.log(self,"resources.cfg read from "+ filename)
return True
def get(self,section,item):
if ResourceReader.config.has_option(section,item)==False:
return False
else:
return ResourceReader.config.get(section,item)