From 2010778876a1b12f5ffe560f609466690d8c181a Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 15 Nov 2012 13:33:27 -0500 Subject: [PATCH] cleanup redundant code, remove whitespace --- .../pypo/liquidsoap_scripts/ls_lib.liq | 28 +++++-------------- utils/airtime-test-stream.py | 24 ++++++++-------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index 5c5919e2e..0305a72e4 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -254,29 +254,15 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de if user == "" then user_ref := "source" end - - description_ref = ref description - if description == "" then - description_ref := "N/A" - end - - genre_ref = ref genre - if genre == "" then - genre_ref := "N/A" - end - - url_ref = ref url - if url == "" then - url_ref := "N/A" - end + output.shoutcast_mono = output.shoutcast(id = "shoutcast_stream_#{stream}", host = host, port = port, password = pass, fallible = true, - url = !url_ref, - genre = !genre_ref, - name = !description_ref, + url = url, + genre = genre, + name = description, user = !user_ref, on_error = on_error, on_connect = on_connect) @@ -286,9 +272,9 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de port = port, password = pass, fallible = true, - url = !url_ref, - genre = !genre_ref, - name = !description_ref, + url = url, + genre = genre, + name = description, user = !user_ref, on_error = on_error, on_connect = on_connect) diff --git a/utils/airtime-test-stream.py b/utils/airtime-test-stream.py index b7d887c0d..a2ab06982 100644 --- a/utils/airtime-test-stream.py +++ b/utils/airtime-test-stream.py @@ -27,14 +27,14 @@ def printUsage(): print " -m mount (default: test) " print " -h show help menu" - + def find_liquidsoap_binary(): """ Starting with Airtime 2.0, we don't know the exact location of the Liquidsoap binary because it may have been installed through a debian package. Let's find the location of this binary. """ - + rv = subprocess.call("which airtime-liquidsoap > /dev/null", shell=True) if rv == 0: return "airtime-liquidsoap" @@ -78,7 +78,7 @@ for o, a in optlist: mount = a try: - + print "Protocol: %s " % stream_type print "Host: %s" % host print "Port: %s" % port @@ -86,35 +86,35 @@ try: print "Password: %s" % password if stream_type == "icecast": print "Mount: %s\n" % mount - + url = "http://%s:%s/%s" % (host, port, mount) print "Outputting to %s streaming server. You should be able to hear a monotonous tone on '%s'. Press ctrl-c to quit." % (stream_type, url) - + liquidsoap_exe = find_liquidsoap_binary() - + if liquidsoap_exe is None: raise Exception("Liquidsoap not found!") - + if stream_type == "icecast": command = "%s 'output.icecast(%%vorbis, host = \"%s\", port = %s, user= \"%s\", password = \"%s\", mount=\"%s\", sine())'" % (liquidsoap_exe, host, port, user, password, mount) else: command = "%s /usr/lib/airtime/pypo/bin/liquidsoap_scripts/library/pervasives.liq 'output.shoutcast(%%mp3, host=\"%s\", port = %s, user= \"%s\", password = \"%s\", sine())'" \ % (liquidsoap_exe, host, port, user, password) - + if not verbose: command += " 2>/dev/null | grep \"failed\"" else: print command - + #print command rv = subprocess.call(command, shell=True) - + #if we reach this point, it means that our subprocess exited without the user - #doing a keyboard interrupt. This means there was a problem outputting to the + #doing a keyboard interrupt. This means there was a problem outputting to the #stream server. Print appropriate message. print "There was an error with your stream configuration. Please review your configuration " + \ "and run this program again. Use the -h option for help" - + except KeyboardInterrupt, ki: print "\nExiting" except Exception, e: