import platform import shutil from subprocess import Popen import sys import os sys.path.append('/usr/lib/airtime/api_clients/') import api_client from configobj import ConfigObj if os.geteuid() != 0: print "Please run this as root." sys.exit(1) def is_natty(): try: f = open('/etc/lsb-release') except IOError as e: #File doesn't exist, so we're not even dealing with Ubuntu return False for line in f: split = line.split("=") split[0] = split[0].strip(" \r\n") split[1] = split[1].strip(" \r\n") if split[0] == "DISTRIB_CODENAME" and (split[1] == "natty" or split[1] == "oneiric"): return True return False def get_current_script_dir(): current_script_dir = os.path.realpath(__file__) index = current_script_dir.rindex('/') return current_script_dir[0:index] def generate_liquidsoap_config(ss): 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'): temp = d[u'value'] if(temp == ""): temp = "" buffer += "\"" + temp + "\"" else: temp = d[u'value'] if(temp == ""): temp = "0" buffer += temp buffer += "\n" fh.write(buffer) fh.write("log_file = \"/var/log/airtime/pypo-liquidsoap/