File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 54
54
from xmlrpclib import ServerProxy as XMLServerProxy
55
55
from xmlrpclib import _Method as XML_Method
56
56
import time
57
+ import string
58
+ import random
57
59
58
60
# Library includes
59
61
import jsonrpclib
66
68
try :
67
69
import cjson
68
70
except ImportError :
69
- pass
70
- if not cjson :
71
71
try :
72
72
import json
73
73
except ImportError :
74
- pass
75
- if not cjson and not json :
76
- try :
77
- import simplejson as json
78
- except ImportError :
79
- raise ImportError ('You must have the cjson, json, or simplejson ' +
80
- 'module(s) available.' )
74
+ try :
75
+ import simplejson as json
76
+ except ImportError :
77
+ raise ImportError (
78
+ 'You must have the cjson, json, or simplejson ' +
79
+ 'module(s) available.'
80
+ )
81
+
82
+ IDCHARS = string .ascii_lowercase + string .digits
83
+
81
84
82
85
#JSON Abstractions
83
86
@@ -97,7 +100,7 @@ def jloads(json_string):
97
100
return json .loads (json_string )
98
101
99
102
100
- # XMLRPClib re-implemntations
103
+ # XMLRPClib re-implementations
101
104
102
105
class ProtocolError (Exception ):
103
106
pass
@@ -359,13 +362,9 @@ def __repr__(self):
359
362
return '<Fault %s: %s>' % (self .faultCode , self .faultString )
360
363
361
364
def random_id (length = 8 ):
362
- import string
363
- import random
364
- random .seed ()
365
- choices = string .lowercase + string .digits
366
365
return_id = ''
367
366
for i in range (length ):
368
- return_id += random .choice (choices )
367
+ return_id += random .choice (IDCHARS )
369
368
return return_id
370
369
371
370
class Payload (dict ):
You can’t perform that action at this time.
0 commit comments