summaryrefslogtreecommitdiff
path: root/jsonrpclib
diff options
context:
space:
mode:
authorJosh Marshall <jmarshall@josh-virtual-ubuntu.(none)>2011-02-12 12:19:12 -0600
committerJosh Marshall <jmarshall@josh-virtual-ubuntu.(none)>2011-02-12 12:19:12 -0600
commit1a566f9e69b6e8b42333124d7552b02cb000ff8e (patch)
treed979a3af173a8f793c92be037f91fe33405d8a91 /jsonrpclib
parenta0cd6268562129127ef26cf22391d0a41ed2f05f (diff)
downloadjsonrpclib-1a566f9e69b6e8b42333124d7552b02cb000ff8e.tar.gz
Fixed cjson import error and random id on Windows error.
Diffstat (limited to 'jsonrpclib')
-rw-r--r--jsonrpclib/jsonrpc.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/jsonrpclib/jsonrpc.py b/jsonrpclib/jsonrpc.py
index 8e50079..a5c37f2 100644
--- a/jsonrpclib/jsonrpc.py
+++ b/jsonrpclib/jsonrpc.py
@@ -54,6 +54,8 @@ from xmlrpclib import SafeTransport as XMLSafeTransport
from xmlrpclib import ServerProxy as XMLServerProxy
from xmlrpclib import _Method as XML_Method
import time
+import string
+import random
# Library includes
import jsonrpclib
@@ -66,18 +68,19 @@ json = None
try:
import cjson
except ImportError:
- pass
-if not cjson:
try:
import json
except ImportError:
- pass
-if not cjson and not json:
- try:
- import simplejson as json
- except ImportError:
- raise ImportError('You must have the cjson, json, or simplejson ' +
- 'module(s) available.')
+ try:
+ import simplejson as json
+ except ImportError:
+ raise ImportError(
+ 'You must have the cjson, json, or simplejson ' +
+ 'module(s) available.'
+ )
+
+IDCHARS = string.ascii_lowercase+string.digits
+
#JSON Abstractions
@@ -97,7 +100,7 @@ def jloads(json_string):
return json.loads(json_string)
-# XMLRPClib re-implemntations
+# XMLRPClib re-implementations
class ProtocolError(Exception):
pass
@@ -359,13 +362,9 @@ class Fault(object):
return '<Fault %s: %s>' % (self.faultCode, self.faultString)
def random_id(length=8):
- import string
- import random
- random.seed()
- choices = string.lowercase+string.digits
return_id = ''
for i in range(length):
- return_id += random.choice(choices)
+ return_id += random.choice(IDCHARS)
return return_id
class Payload(dict):