From 078aa1d05ddf17f793a7149850d016ca03cd2211 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 23 Aug 2011 10:12:18 -0400 Subject: [PATCH] CC-2607: Handling comments - It handles comment lines - adding warning text telling not to edit liquidsoap.cfg file --- python_apps/pypo/install/pypo-install.py | 4 ++++ python_apps/pypo/pypofetch.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/python_apps/pypo/install/pypo-install.py b/python_apps/pypo/install/pypo-install.py index fcb4e7b81..272c4376b 100755 --- a/python_apps/pypo/install/pypo-install.py +++ b/python_apps/pypo/install/pypo-install.py @@ -117,10 +117,14 @@ try: # we should access the DB and generate liquidsoap.cfg under etc/airtime/ api_client = api_client.api_client_factory(config) ss = api_client.get_stream_setting() + # if api_client is somehow not working, just use original cfg file if(ss is not None): data = ss['msg'] fh = open('/etc/airtime/liquidsoap.cfg', 'w') + fh.write("################################################\n") + fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n") + fh.write("################################################\n") for d in data: buffer = d[u'keyname'] + " = " if(d[u'type'] == 'string'): diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index bc644b2dc..1f4dfd776 100755 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -117,7 +117,9 @@ class PypoFetch(Thread): while 1: line = fh.readline() if not line: - break; + break + if line.find('#') == 0: + continue key, value = line.split('=') key = key.strip() value = value.strip() @@ -176,6 +178,9 @@ class PypoFetch(Thread): if restart: fh = open('/etc/airtime/liquidsoap.cfg', 'w') logger.info("Rewriting liquidsoap.cfg...") + fh.write("################################################\n") + fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n") + fh.write("################################################\n") for d in setting: buffer = d[u'keyname'] + " = " if(d[u'type'] == 'string'):