#!/usr/bin/python # -*- coding: utf-8 -*- import json from configobj import ConfigObj
def add(self, false=None):
self.log.debug("list")
try:
conf_ini = CONFIG_INI_PATH+"users.ini.bak"
config = ConfigObj(conf_ini, encoding='UTF8')
req = self.input["input"]
data = req["data"]
userName = data["userName"]
disc = data["disc"]
ip = data["ip"]
expMonth = int(float(data["expDate"]) * 12)
for user in config.items():
if userName == user[0]:
self.out = '{"status": 1,"msg":"用户名已存在!"}'
return false
else:
pass
config[userName] = {}
config[userName]['user'] = userName
config[userName]['disc'] = disc
config[userName]['ip'] = ip
config[userName]['validity_date'] = data["expDate"]
config[userName]['cert_expired'] = get_today_month(expMonth)
config[userName]['enable'] = 0
config[userName]['path'] = USER_KEY_PATH + userName
config.write()
self.out = '{"status": 0,"msg":"操作成功!"}'
except Exception, e:
self.out = '{"status":1, "msg":"'+str(e)+'"}'
def modify(self):
self.log.debug("modify")
try:
conf_ini = CONFIG_INI_PATH + "users.ini.bak"
config = ConfigObj(conf_ini, encoding='UTF8')
req = self.input["input"]
data = req["data"]
userName = data["userName"]
disc = data["disc"]
ip = data["ip"]
config[userName]['disc'] = disc
config[userName]['ip'] = ip
config.write()
self.out = '{"status": 0,"msg":"操作成功!"}'
except Exception, e:
self.out = '{"status":1, "msg":"'+str(e)+'"}'
def delete(self, false=None):
self.log.debug("delete")
try:
conf_ini = CONFIG_INI_PATH + "users.ini.bak"
config = ConfigObj(conf_ini, encoding='UTF8')
req = self.input["input"]
data = req["data"]
userName = data["userName"]
for user in config.items():
if userName == user[0]:
del config[userName]
config.write()
self.out = '{"status": 0,"msg":"操作成功!"}'
return false
else:
pass
self.out = '{"status": 1,"msg":"用户不存在!"}'
except Exception, e:
self.out = '{"status":1, "msg":"config err!"}'
def list(self):
self.log.debug("list")
try:
req = self.input["input"]
data = req["data"]
pageSize = req["pageSize"]
pageIndex = req["pageIndex"]
userName = data["userName"]
conf_ini = CONFIG_INI_PATH + "users.ini.bak"
config = ConfigObj(conf_ini, encoding='UTF8')
users = []
n = 0
if userName == '':
for user in config.items():
n = n + 1
if pageSize * pageIndex + 1 <= n <= pageSize * (pageIndex + 1):
users.append(user[1])
else:
pass
else:
for user in config.items():
if userName == user[0]:
n = n + 1
if pageSize * pageIndex + 1 <= n <= pageSize * (pageIndex + 1):
users.append(user[1])
else:
pass
else:
pass
utext = json.dumps(users)
self.out = '{"status": 0,"total":'+str(n)+',"data":' + utext + '}'
except Exception, e:
self.out = '{"status":1, "msg":"' + str(e) + '"}'
self.log.debug("list in.")
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有