Remove use of json so as to support python 2.4 and 2.5

This commit is contained in:
Andrew Cammell 2014-10-07 20:48:38 +08:00
parent 20257151f4
commit ad57c7cf2e
1 changed files with 4 additions and 5 deletions

View File

@ -30,7 +30,6 @@ import signal
import socket import socket
import timeit import timeit
import threading import threading
from json import dump as jsonDump, load as jsonLoad
# Used for bound_interface # Used for bound_interface
socket_socket = socket.socket socket_socket = socket.socket
@ -562,7 +561,7 @@ def speedtest():
print_('Unable to open configuration file %s' print_('Unable to open configuration file %s'
% args.saveconfig) % args.saveconfig)
sys.exit(1) sys.exit(1)
jsonDump(config, configfile) configfile.write(str(config))
configfile.close() configfile.close()
else: else:
if not args.simple: if not args.simple:
@ -573,7 +572,7 @@ def speedtest():
except: except:
print_('Unable to open configuration file %s' % args.loadconfig) print_('Unable to open configuration file %s' % args.loadconfig)
sys.exit(1) sys.exit(1)
config = jsonLoad(confFile) config = eval(confFile.read())
confFile.close() confFile.close()
if args.showconfig: if args.showconfig:
@ -616,7 +615,7 @@ def speedtest():
except: except:
print_('Unable to open server file') print_('Unable to open server file')
sys.exit(1) sys.exit(1)
jsonDump(servers, svrFile) svrFile.write(str(servers))
svrFile.close() svrFile.close()
print_('Done') print_('Done')
sys.exit(0) sys.exit(0)
@ -629,7 +628,7 @@ def speedtest():
except: except:
print_('Unable to open server file') print_('Unable to open server file')
sys.exit(1) sys.exit(1)
allServers = jsonLoad(svrFile) allServers = eval(svrFile.read())
svrFile.close() svrFile.close()
if len(allServers) > 10: if len(allServers) > 10:
servers = allServers[:5] servers = allServers[:5]