18 | 18 |
"""
|
19 | 19 |
|
20 | 20 |
import logging
|
21 | |
import simplejson as json
|
|
21 |
import simplejson
|
22 | 22 |
|
23 | 23 |
|
24 | 24 |
logger = logging.getLogger(__name__)
|
|
99 | 99 |
return cls(
|
100 | 100 |
stream_name,
|
101 | 101 |
None if token == "batch" else int(token),
|
102 | |
json.loads(row_json)
|
|
102 |
simplejson.loads(row_json)
|
103 | 103 |
)
|
104 | 104 |
|
105 | 105 |
def to_line(self):
|
106 | 106 |
return " ".join((
|
107 | 107 |
self.stream_name,
|
108 | 108 |
str(self.token) if self.token is not None else "batch",
|
109 | |
json.dumps(self.row),
|
|
109 |
simplejson.dumps(self.row, namedtuple_as_object=False),
|
110 | 110 |
))
|
111 | 111 |
|
112 | 112 |
|
|
297 | 297 |
def from_line(cls, line):
|
298 | 298 |
cache_func, keys_json = line.split(" ", 1)
|
299 | 299 |
|
300 | |
return cls(cache_func, json.loads(keys_json))
|
301 | |
|
302 | |
def to_line(self):
|
303 | |
return " ".join((self.cache_func, json.dumps(self.keys)))
|
|
300 |
return cls(cache_func, simplejson.loads(keys_json))
|
|
301 |
|
|
302 |
def to_line(self):
|
|
303 |
return " ".join((
|
|
304 |
self.cache_func, simplejson.dumps(self.keys, namedtuple_as_object=False)
|
|
305 |
))
|
304 | 306 |
|
305 | 307 |
|
306 | 308 |
class UserIpCommand(Command):
|
|
324 | 326 |
def from_line(cls, line):
|
325 | 327 |
user_id, jsn = line.split(" ", 1)
|
326 | 328 |
|
327 | |
access_token, ip, user_agent, device_id, last_seen = json.loads(jsn)
|
|
329 |
access_token, ip, user_agent, device_id, last_seen = simplejson.loads(jsn)
|
328 | 330 |
|
329 | 331 |
return cls(
|
330 | 332 |
user_id, access_token, ip, user_agent, device_id, last_seen
|
331 | 333 |
)
|
332 | 334 |
|
333 | 335 |
def to_line(self):
|
334 | |
return self.user_id + " " + json.dumps((
|
|
336 |
return self.user_id + " " + simplejson.dumps((
|
335 | 337 |
self.access_token, self.ip, self.user_agent, self.device_id,
|
336 | 338 |
self.last_seen,
|
337 | 339 |
))
|