diff --git a/pypo/api_clients/api_client.py b/pypo/api_clients/api_client.py index 98abcaa28..0cc782c8e 100644 --- a/pypo/api_clients/api_client.py +++ b/pypo/api_clients/api_client.py @@ -14,7 +14,7 @@ import sys import time import urllib import logging -from util import json +import json import os from urlparse import urlparse @@ -118,7 +118,7 @@ class AirTimeApiClient(ApiClientInterface): response = urllib.urlopen(url) data = response.read() logger.debug("Data: %s", data) - response_json = json.read(data) + response_json = json.loads(data) version = response_json['version'] logger.debug("Airtime Version %s detected", version) except Exception, e: @@ -223,7 +223,7 @@ class AirTimeApiClient(ApiClientInterface): try: response_json = urllib.urlopen(export_url).read() #logger.debug("%s", response_json) - response = json.read(response_json) + response = json.loads(response_json) #logger.info("export status %s", response['check']) status = response['check'] except Exception, e: @@ -281,7 +281,7 @@ class AirTimeApiClient(ApiClientInterface): try: response = urllib.urlopen(url) - response = json.read(response.read()) + response = json.loads(response.read()) logger.info("API-Status %s", response['status']) logger.info("API-Message %s", response['message']) @@ -302,7 +302,7 @@ class AirTimeApiClient(ApiClientInterface): if (data[0] != '{'): return response try: - data = json.read(data) + data = json.loads(data) logger.debug(str(data)) schedule_id = data["schedule_id"] url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"] @@ -311,7 +311,7 @@ class AirTimeApiClient(ApiClientInterface): url = url.replace("%%api_key%%", self.config["api_key"]) logger.debug(url) response = urllib.urlopen(url) - response = json.read(response.read()) + response = json.loads(response.read()) logger.info("API-Status %s", response['status']) logger.info("API-Message %s", response['message']) @@ -329,7 +329,7 @@ class AirTimeApiClient(ApiClientInterface): # #try: # response = urllib.urlopen(url, self.api_auth) - # response = json.read(response.read()) + # response = json.loads(response.read()) # logger.debug("Trying to contact %s", url) # logger.info("API-Status %s", response['status']) # logger.info("API-Message %s", response['message']) @@ -349,7 +349,7 @@ class AirTimeApiClient(ApiClientInterface): data["schedule_id"] = playlist['id'] except Exception, e: data["schedule_id"] = 0 - data = json.write(data) + data = json.dumps(data) return data @@ -404,7 +404,7 @@ class ObpApiClient(): try: logger.debug("Trying to contact %s", url) response = urllib.urlopen(url, self.api_auth) - response_json = json.read(response.read()) + response_json = json.loads(response.read()) obp_version = int(response_json['version']) logger.debug("OBP Version %s detected", obp_version) @@ -471,7 +471,7 @@ class ObpApiClient(): try: response_json = urllib.urlopen(export_url).read() logger.debug("%s", response_json) - response = json.read(response_json) + response = json.loads(response_json) logger.info("export status %s", response['check']) status = response['check'] except Exception, e: @@ -502,7 +502,7 @@ class ObpApiClient(): try: response = urllib.urlopen(url, self.api_auth) - response = json.read(response.read()) + response = json.loads(response.read()) logger.info("API-Status %s", response['status']) logger.info("API-Message %s", response['message']) @@ -536,7 +536,7 @@ class ObpApiClient(): try: response = urllib.urlopen(url, self.api_auth) - response = json.read(response.read()) + response = json.loads(response.read()) logger.info("API-Status %s", response['status']) logger.info("API-Message %s", response['message']) logger.info("TXT %s", response['str_dls']) @@ -556,7 +556,7 @@ class ObpApiClient(): try: response = urllib.urlopen(url, self.api_auth) - response = json.read(response.read()) + response = json.loads(response.read()) logger.debug("Trying to contact %s", url) logger.info("API-Status %s", response['status']) logger.info("API-Message %s", response['message']) @@ -580,6 +580,6 @@ class ObpApiClient(): data["playlist_id"] = 0 data["user_id"] = 0 data["transmission_id"] = 0 - data = json.write(data) + data = json.dumps(data) return data diff --git a/pypo/dls/dls_client.py b/pypo/dls/dls_client.py index 2b09a75b5..94a8abd3d 100755 --- a/pypo/dls/dls_client.py +++ b/pypo/dls/dls_client.py @@ -8,8 +8,6 @@ import time import logging -from util import json - import os import socket @@ -87,4 +85,4 @@ class DlsClient(): - \ No newline at end of file + diff --git a/pypo/pypo-cli.py b/pypo/pypo-cli.py index 98e61c42e..75a08409f 100755 --- a/pypo/pypo-cli.py +++ b/pypo/pypo-cli.py @@ -19,12 +19,6 @@ Attention & ToDos - liquidsoap does not like mono files! So we have to make sure that only files with 2 channels are fed to LiquidSoap (solved: current = audio_to_stereo(current) - maybe not with ultimate performance) - - -made for python version 2.5!! -should work with 2.6 as well with a bit of adaption. for -sure the json parsing has to be changed -(2.6 has an parser, pypo brings it's own -> util/json.py) """ # python defaults (debian default) diff --git a/pypo/pypo-notify.py b/pypo/pypo-notify.py index cf542c105..ce068160a 100755 --- a/pypo/pypo-notify.py +++ b/pypo/pypo-notify.py @@ -29,6 +29,7 @@ import logging.config import urllib import urllib2 import string +import json # additional modules (should be checked) from configobj import ConfigObj @@ -97,7 +98,7 @@ class Notify: logger.debug('#################################################') logger.debug('data = '+ str(data)) #print 'options.data = '+ options.data - #data = json.read(options.data) + #data = json.loads(options.data) response = self.api_client.notify_media_item_start_playing(data, media_id) logger.debug("Response: "+str(response)) diff --git a/pypo/util/status.py b/pypo/util/status.py index 072fb4f5e..c05340705 100644 --- a/pypo/util/status.py +++ b/pypo/util/status.py @@ -7,8 +7,7 @@ import urllib import logging import telnetlib - -from util import json +import json import os @@ -26,7 +25,7 @@ class Status: # lookup OBP version try: response = urllib.urlopen(self.status_url) - response_json = json.read(response.read()) + response_json = json.loads(response.read()) obp_version = int(response_json['version']) logger.debug("OBP Version %s detected", obp_version)