-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.py
More file actions
72 lines (59 loc) · 2.18 KB
/
info.py
File metadata and controls
72 lines (59 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding:utf-8 -*-
__author__ = 'Furnace'
import crcmod
import json
import redis
import tool
def info():
# load conf.json
with open("conf.json",'r') as conf_file:
conf = json.load(conf_file)
ipaddr = conf['ipaddr']
port = conf['port']
dbno = conf['dbno']
redis_tool = tool.RedisTool(ipaddr, port, dbno)
conn = redis_tool.get_conn()
# print('Is connected to Redis: ', conn.ping() )
if not conn.ping():
print('Is connected to Redis: ', conn.ping() )
return
# infos
friend_name_list = conn.lrange('friend_name_list', 0, -1)
# print('friend_name_list = ', friend_name_list)
for friend_name in friend_name_list:
# friend_name = unicode(friend_name, 'utf-8') # python 2
friend_name = friend_name.decode('utf-8').replace('\n', '') # python 3
print('friend_name = ', friend_name )
print('')
index = conn.get('index')
index = int(index)
print('index = ', index)
print('')
message_pool_length = conn.llen('message_pool')
print('message_pool_length = ', message_pool_length)
message_pool = conn.lrange('message_pool', 0, -1)
# print('message_pool = ', message_pool)
for i, msg in enumerate(message_pool):
if i >= 5:
break
# msg = unicode(msg, 'utf-8') # python 2
msg = msg.decode('utf-8') # python 3
print('i = %d, msg = %s' % (i, msg) )
print('')
message_pool_crc_length = conn.scard('message_pool_crc')
print('message_pool_crc_length = ', message_pool_crc_length)
message_pool_crc = conn.smembers('message_pool_crc')
# print('message_pool_crc = ', message_pool_crc)
for i, msg_crc in enumerate(message_pool_crc):
if i >= 5:
break
# msg_crc = unicode(msg_crc, 'utf-8') # python 2
msg_crc = msg_crc.decode('utf-8') # python 3
print('i = %d, msg_crc = %s' % (i, msg_crc) )
print('')
last_hot_msg_update_timestamp = conn.get('last_hot_msg_update_timestamp')
last_hot_msg_update_timestamp = int(last_hot_msg_update_timestamp)
print('last_hot_msg_update_timestamp = ', last_hot_msg_update_timestamp)
print('')
if __name__ == '__main__':
info()