-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.py
executable file
·67 lines (49 loc) · 1.53 KB
/
utility.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#from mod_python import apache
import ConfigParser
import sys
#import debug
#cfgFileName='/usr/local/share/pi/zones.cfg'
#cfgFileName='/data/gardenpi/zones.cfg'
cfgFileName='/var/www/raspberry/zones.cfg'
def getInclude(part):
fileName="/var/www/raspberry/%s.inc" % part
fHeader=open(fileName,'r')
header = fHeader.read()
fHeader.close()
return header
def saveConfig2(zones):
#cfgFileName='/usr/local/share/pi/zones.cfg'
config=ConfigParser.RawConfigParser()
i=0
while i < len(zones):
section="Zona %u" % (i+1)
config.add_section(section )
for key in zones[i]:
config.set(section,key,zones[i].get(key))
i=i+1
with open(cfgFileName,'wb') as configfile:
config.write(configfile)
return
def getDefaultFields():
return ['name','description','imagearea','days','start','duration']
def getConfig():
#restituisce un dictionary della zona con i parametri relativi
#cfgFileName='/usr/local/share/pi/zones.cfg'
config=ConfigParser.RawConfigParser()
return
def getConfigParameter(name):
#carica il file zone e restituisce un array con il valore del parametro passato
values = []
config=ConfigParser.RawConfigParser()
config.read(cfgFileName)
for section in config.sections():
values.append(config.get(section,name))
return values
def IrrigationProcess():
#cfgFileName='/usr/local/share/pi/zones.cfg'
config=ConfigParser.RawConfigParser()
config.read(cfgFileName)
zones=config.sections()
for key in zones:
sys.stdout.write(key)
return