clean up source file tailing whitespace
This commit is contained in:
parent
6438b54a5f
commit
5bd0fe0300
|
@ -11,40 +11,40 @@ from configobj import ConfigObj
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print "Please run this as root."
|
print "Please run this as root."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def get_current_script_dir():
|
def get_current_script_dir():
|
||||||
current_script_dir = os.path.realpath(__file__)
|
current_script_dir = os.path.realpath(__file__)
|
||||||
index = current_script_dir.rindex('/')
|
index = current_script_dir.rindex('/')
|
||||||
return current_script_dir[0:index]
|
return current_script_dir[0:index]
|
||||||
|
|
||||||
def copy_dir(src_dir, dest_dir):
|
def copy_dir(src_dir, dest_dir):
|
||||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||||
shutil.rmtree(dest_dir)
|
shutil.rmtree(dest_dir)
|
||||||
if not (os.path.exists(dest_dir)):
|
if not (os.path.exists(dest_dir)):
|
||||||
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||||
shutil.copytree(src_dir, dest_dir)
|
shutil.copytree(src_dir, dest_dir)
|
||||||
|
|
||||||
def create_dir(path):
|
def create_dir(path):
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_rand_string(length=10):
|
def get_rand_string(length=10):
|
||||||
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
||||||
|
|
||||||
def get_rand_string(length=10):
|
def get_rand_string(length=10):
|
||||||
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
||||||
|
|
||||||
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Absolute path this script is in
|
# Absolute path this script is in
|
||||||
current_script_dir = get_current_script_dir()
|
current_script_dir = get_current_script_dir()
|
||||||
|
|
||||||
if not os.path.exists(PATH_INI_FILE):
|
if not os.path.exists(PATH_INI_FILE):
|
||||||
shutil.copy('%s/../pypo.cfg'%current_script_dir, PATH_INI_FILE)
|
shutil.copy('%s/../pypo.cfg'%current_script_dir, PATH_INI_FILE)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove("/etc/airtime/liquidsoap.cfg")
|
os.remove("/etc/airtime/liquidsoap.cfg")
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -59,7 +59,7 @@ try:
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print 'Error loading config file: ', e
|
print 'Error loading config file: ', e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
#copy monit files
|
#copy monit files
|
||||||
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True)
|
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True)
|
||||||
|
@ -80,13 +80,13 @@ try:
|
||||||
create_dir(config['cache_dir'])
|
create_dir(config['cache_dir'])
|
||||||
create_dir(config['file_dir'])
|
create_dir(config['file_dir'])
|
||||||
create_dir(config['tmp_dir'])
|
create_dir(config['tmp_dir'])
|
||||||
|
|
||||||
create_dir(config["base_recorded_files"])
|
create_dir(config["base_recorded_files"])
|
||||||
|
|
||||||
#copy files to bin dir
|
#copy files to bin dir
|
||||||
copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/")
|
copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/")
|
||||||
|
|
||||||
# delete /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap.cfg
|
# delete /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap.cfg
|
||||||
# as we don't use it anymore.(CC-2552)
|
# as we don't use it anymore.(CC-2552)
|
||||||
os.remove(config["bin_dir"]+"/bin/liquidsoap_scripts/liquidsoap.cfg")
|
os.remove(config["bin_dir"]+"/bin/liquidsoap_scripts/liquidsoap.cfg")
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ try:
|
||||||
|
|
||||||
#copy log rotate script
|
#copy log rotate script
|
||||||
shutil.copy(config["bin_dir"]+"/bin/liquidsoap_scripts/airtime-liquidsoap.logrotate", "/etc/logrotate.d/airtime-liquidsoap")
|
shutil.copy(config["bin_dir"]+"/bin/liquidsoap_scripts/airtime-liquidsoap.logrotate", "/etc/logrotate.d/airtime-liquidsoap")
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print e
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue