-removed json.py and now using native python 2.6 implementation

This commit is contained in:
martin 2011-02-15 20:59:04 -05:00
parent 33a881f65c
commit 59462ef697
5 changed files with 19 additions and 27 deletions

View File

@ -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

View File

@ -8,8 +8,6 @@ import time
import logging
from util import json
import os
import socket
@ -87,4 +85,4 @@ class DlsClient():

View File

@ -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)

View File

@ -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))

View File

@ -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)