mdserver-web/plugins/simpleping/simpleping_index.py

73 lines
1.7 KiB
Python
Raw Permalink Normal View History

2024-07-10 14:35:33 -04:00
# coding:utf-8
import sys
import io
import os
import time
import re
import json
import shutil
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'simpleping'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def pingData(args = ()):
2024-10-16 10:01:16 -04:00
# print(args)
2024-07-10 14:35:33 -04:00
conn = mw.M('sp_ping').dbPos(getServerDir()+'/data', 'simpleping', 'db3')
2024-10-16 10:01:29 -04:00
field = 'id,speed,created_unix'
2024-07-10 14:35:33 -04:00
conn = conn.field(field)
data = []
atype = args['type']
2024-07-11 03:20:11 -04:00
if not 'ip' in args:
ip = 'all'
else:
ip = args['ip']
2024-07-11 03:17:57 -04:00
2024-07-10 14:35:33 -04:00
if atype == 'pos':
2024-10-16 10:01:16 -04:00
if 'pos' in args:
pos = args['pos']
conn.where('created_unix>?',(pos,)).limit("3000")
if ip != 'all':
conn.andWhere('ip=?',(ip,))
2024-07-10 14:35:33 -04:00
elif atype == 'range':
start = args['start']
end = args['end']
2024-10-16 10:01:16 -04:00
conn.where('created_unix>=? and created_unix<=?',(start,end,)).limit("1000")
if ip != 'all':
conn.andWhere('ip=?',(ip,))
data = conn.select()
2024-07-10 14:35:33 -04:00
return data
2024-07-13 10:05:27 -04:00
def pingMySQLData(args = ()):
conn = mw.M('sp_mysql_ping').dbPos(getServerDir()+'/data', 'simpleping', 'db3')
field = 'id,value,created_unix'
conn = conn.field(field)
data = []
atype = args['type']
if atype == 'pos':
pos = args['pos']
data = conn.where('created_unix>?',(pos,)).limit("3000").select()
elif atype == 'range':
start = args['start']
end = args['end']
data = conn.where('created_unix>=? and created_unix<=?',(start,end)).limit("1000").select()
return data