blob: cf33764190cd1fdec9adfa45d7cd77bff40e5911 (
plain)
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
|
#! /usr/bin/python2
#Helper program that generates gen_is.xml thats custom to linhes.
#Contents of gen_is.xml are read from /etc/gen_is_xml.d
#This script should be run everytime a is.xml entry is added or removed
import os, sys
import glob
def read_snippets(dir_name):
xml_snippets=""
try:
os.chdir(dir_name)
except:
print " gen_is_xml: Couldn't change dir to %s" %dir_name
print " Exiting"
sys.exit(0)
file_list=glob.glob("*.conf")
for conf_file in file_list:
try:
print " gen_is_xml: reading in %s" %conf_file
f=open(conf_file,'r')
lines=f.readlines()
f.close()
except:
print " gen_is_xml: Couldn't open %s for reading" %conf_file
print " Exiting"
sys.exit(1)
for line in lines:
xml_snippets+=line
if len(file_list) == 0:
print " gen_is_xml: no conf files found"
xml_snippets=""
return xml_snippets
def write_xml(xml,filename):
try:
f=open(filename, 'w')
except:
print " gen_is_xml: Couldn't open %s" %(filename)
print " Exiting"
sys.exit(2)
f.write(xml)
f.close()
def main():
filename="/usr/share/mythtv/gen_is.xml"
is_xml_dir="/etc/gen_is_xml.d/"
xml_snippets=read_snippets(is_xml_dir)
xml='''<mythmenu name="INTERNET_STREAMS">\n\n%s\n</mythmenu>\n''' %xml_snippets
write_xml(xml,filename)
if __name__ == "__main__":
main()
|