forked from ImAnyOne/SSR-Bash-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow_flow.py
More file actions
29 lines (21 loc) · 713 Bytes
/
show_flow.py
File metadata and controls
29 lines (21 loc) · 713 Bytes
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
# -*- coding:utf-8 -*-
import json
f = file("/usr/local/shadowsocksr/mudb.json");
json = json.load(f);
print "用户名\t端口\t已用流量\t流量限制"
for x in json:
#Convert Unit To MB
transfer_enable_int = int(x[u"transfer_enable"])/1024/1024;
d_int = int(x[u"d"])/1024/1024;
transfer_unit = "MB"
d_unit = "MB"
#Convert Unit To GB For Those Number Which Exceeds 1024MB
if(transfer_enable_int > 1024):
transfer_enable_int = transfer_enable_int/1024
transfer_unit = "GB"
if(transfer_enable_int > 1024):
d_int = d_int/1024
d_unit = "GB"
#Print In Format
print "%s\t%s\t%d%s\t\t%d%s" %(x[u"user"],x[u"port"],d_int,d_unit,transfer_enable_int,transfer_unit)
f.close();