本文整理汇总了Python中toughlib.utils.get_currtime函数的典型用法代码示例。如果您正苦于以下问题:Python get_currtime函数的具体用法?Python get_currtime怎么用?Python get_currtime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_currtime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
def register(self):
conn = self.db()
try:
node = conn.query(models.TrRadAgent).filter_by(
endpoint=self.listen,
protocol='zeromq',
radius_type='acctounting'
).first()
if not node:
node = models.TrRadAgent()
node.radius_type = 'acctounting'
node.protocol = 'zeromq'
node.endpoint = self.listen
node.create_time = utils.get_currtime()
node.last_check = utils.get_currtime()
conn.add(node)
conn.commit()
else:
node.last_check = utils.get_currtime()
conn.commit()
except Exception as err:
self.syslog.error(u"register acctounting agent error %s" % utils.safeunicode(err.message))
finally:
conn.close()
reactor.callLater(10.0, self.register, )
示例2: event_syslog_trace
def event_syslog_trace(self, name, message,**kwargs):
""" syslog trace event """
message = u"%s - %s" % (utils.get_currtime(), message)
if name == 'radius' and 'username' in kwargs:
self.trace_radius(kwargs['username'], message)
else:
self.trace_log(name, message)
示例3: add_oplog
def add_oplog(self,message):
ops_log = models.TrOperateLog()
ops_log.operator_name = self.current_user.username
ops_log.operate_ip = self.current_user.ipaddr
ops_log.operate_time = utils.get_currtime()
ops_log.operate_desc = message
self.db.add(ops_log)
示例4: get_current_user
def get_current_user(self):
session_opr = ObjectDict()
session_opr.username = 'api'
session_opr.ipaddr = self.request.remote_ip
session_opr.opr_type = 0
session_opr.login_time = utils.get_currtime()
return session_opr
示例5: post
def post(self):
account_number = self.get_argument("account_number")
account = self.db.query(models.TrAccount).get(account_number)
if account.status != 1:
return self.render_json(code=1, msg=u"用户当前状态不允许停机")
_datetime = utils.get_currtime()
account.last_pause = _datetime
account.status = 2
accept_log = models.TrAcceptLog()
accept_log.accept_type = 'pause'
accept_log.accept_source = 'console'
accept_log.accept_desc = u"用户停机:上网账号:%s" % (account_number)
accept_log.account_number = account.account_number
accept_log.accept_time = _datetime
accept_log.operator_name = self.current_user.username
self.db.add(accept_log)
self.db.commit()
onlines = self.db.query(models.TrOnline).filter_by(account_number=account_number)
for _online in onlines:
pass
return self.render_json(msg=u"操作成功")
示例6: post
def post(self):
account_number = self.get_argument("account_number")
account = self.db.query(models.TrAccount).get(account_number)
if account.status != 2:
return self.render_json(code=1, msg=u"用户当前状态不允许复机")
account.status = 1
_datetime = datetime.datetime.now()
_pause_time = datetime.datetime.strptime(account.last_pause, "%Y-%m-%d %H:%M:%S")
_expire_date = datetime.datetime.strptime(account.expire_date + ' 23:59:59', "%Y-%m-%d %H:%M:%S")
days = (_expire_date - _pause_time).days
new_expire = (_datetime + datetime.timedelta(days=int(days))).strftime("%Y-%m-%d")
account.expire_date = new_expire
accept_log = models.TrAcceptLog()
accept_log.accept_type = 'resume'
accept_log.accept_source = 'console'
accept_log.accept_desc = u"用户复机:上网账号:%s" % (account_number)
accept_log.account_number = account.account_number
accept_log.accept_time = utils.get_currtime()
accept_log.operator_name = self.current_user.username
self.db.add(accept_log)
self.db.commit()
dispatch.pub(db_cache.CACHE_DELETE_EVENT,account_cache_key(account.account_number), async=True)
return self.render_json(msg=u"操作成功")
示例7: post
def post(self):
uname = self.get_argument("username")
upass = self.get_argument("password")
if not uname:
return self.render_json(code=1, msg=u"请填写用户名")
if not upass:
return self.render_json(code=1, msg=u"请填写密码")
enpasswd = md5(upass.encode()).hexdigest()
opr = self.db.query(models.TrwOperator).filter_by(
operator_name=uname,
operator_pass=enpasswd
).first()
if not opr:
return self.render_json(code=1, msg=u"用户名密码不符")
if opr.operator_status == 1:
return self.render_json(code=1, msg=u"该操作员账号已被停用")
self.set_session_user(uname, self.request.remote_ip, opr.operator_type, utils.get_currtime())
self.add_oplog( u'操作员(%s)登陆' % (uname,))
self.db.commit()
self.render_json(code=0, msg="ok")
示例8: post
def post(self):
account_number = self.get_argument("account_number")
account = self.db.query(models.TrAccount).get(account_number)
if account.status != 1:
return self.render_json(code=1, msg=u"用户当前状态不允许停机")
_datetime = utils.get_currtime()
account.last_pause = _datetime
account.status = 2
accept_log = models.TrAcceptLog()
accept_log.accept_type = "pause"
accept_log.accept_source = "console"
accept_log.accept_desc = u"用户停机:上网账号:%s" % (account_number)
accept_log.account_number = account.account_number
accept_log.accept_time = _datetime
accept_log.operator_name = self.current_user.username
self.db.add(accept_log)
self.db.commit()
dispatch.pub(ACCOUNT_PAUSE_EVENT, account.account_number, async=True)
dispatch.pub(db_cache.CACHE_DELETE_EVENT, account_cache_key(account.account_number), async=True)
return self.render_json(msg=u"操作成功")
示例9: post
def post(self):
account_number = self.get_argument("account_number")
account = self.db.query(models.TrAccount).get(account_number)
user = self.query_account(account_number)
form = account_forms.account_cancel_form()
if account.status != 1:
return self.render("account_form.html", user=user, form=form, msg=u"无效用户状态")
if not form.validates(source=self.get_params()):
return self.render("account_form.html", user=user, form=form)
accept_log = models.TrAcceptLog()
accept_log.accept_type = 'cancel'
accept_log.accept_source = 'console'
accept_log.account_number = form.d.account_number
accept_log.accept_time = utils.get_currtime()
accept_log.operator_name = self.current_user.username
accept_log.accept_desc = u"用户销户退费%s(元);%s" % (
form.d.fee_value, utils.safeunicode(form.d.operate_desc))
self.db.add(accept_log)
self.db.flush()
self.db.refresh(accept_log)
old_expire_date = account.expire_date
order = models.TrCustomerOrder()
order.order_id = utils.gen_order_id()
order.customer_id = user.customer_id
order.product_id = user.product_id
order.account_number = form.d.account_number
order.order_fee = 0
order.actual_fee = -utils.yuan2fen(form.d.fee_value)
order.pay_status = 1
order.order_source = 'console'
order.accept_id = accept_log.id
order.create_time = utils.get_currtime()
order.order_desc = accept_log.accept_desc
self.db.add(order)
account.status = 3
self.db.commit()
dispatch.pub(ACCOUNT_CHANNEL_EVENT, account.account_number, async=True)
dispatch.pub(db_cache.CACHE_DELETE_EVENT,account_cache_key(account.account_number), async=True)
for online in self.db.query(models.TrOnline).filter_by(account_number=account_number):
dispatch.pub(UNLOCK_ONLINE_EVENT,account_number,online.nas_addr, online.acct_session_id,async=True)
self.redirect(self.detail_url_fmt(account_number))
示例10: post
def post(self):
account_number = self.get_argument("account_number")
account = self.db.query(models.TrAccount).get(account_number)
user = self.query_account(account_number)
form = account_forms.account_cancel_form()
if account.status != 1:
return self.render("account_form.html", user=user, form=form, msg=u"无效用户状态")
if not form.validates(source=self.get_params()):
return self.render("account_form.html", user=user, form=form)
accept_log = models.TrAcceptLog()
accept_log.accept_type = "cancel"
accept_log.accept_source = "console"
accept_log.account_number = form.d.account_number
accept_log.accept_time = utils.get_currtime()
accept_log.operator_name = self.current_user.username
accept_log.accept_desc = u"用户销户退费%s(元);%s" % (form.d.fee_value, utils.safeunicode(form.d.operate_desc))
self.db.add(accept_log)
self.db.flush()
self.db.refresh(accept_log)
old_expire_date = account.expire_date
order = models.TrCustomerOrder()
order.order_id = utils.gen_order_id()
order.customer_id = user.customer_id
order.product_id = user.product_id
order.account_number = form.d.account_number
order.order_fee = 0
order.actual_fee = -utils.yuan2fen(form.d.fee_value)
order.pay_status = 1
order.order_source = "console"
order.accept_id = accept_log.id
order.create_time = utils.get_currtime()
order.order_desc = accept_log.accept_desc
self.db.add(order)
account.status = 3
self.db.commit()
onlines = self.db.query(models.TrOnline).filter_by(account_number=account_number)
for _online in onlines:
pass
self.redirect(self.detail_url_fmt(account_number))
示例11: post
def post(self):
account_number = self.get_argument("account_number")
account = self.db.query(models.TrAccount).get(account_number)
user = self.query_account(account_number)
form = account_forms.account_charge_form()
if account.status not in (1, 4):
return render("account_form", user=user, form=form, msg=u"无效用户状态")
if not form.validates(source=self.get_params()):
return render("account_form", user=user, form=form)
accept_log = models.TrAcceptLog()
accept_log.accept_type = 'charge'
accept_log.accept_source = 'console'
_new_fee = account.balance + utils.yuan2fen(form.d.fee_value)
accept_log.accept_desc = u"用户充值:充值前%s元,充值后%s元;%s" % (
utils.fen2yuan(account.balance),
utils.fen2yuan(_new_fee),
(form.d.operate_desc or '')
)
accept_log.account_number = form.d.account_number
accept_log.accept_time = utils.get_currtime()
accept_log.operator_name = self.current_user.username
self.db.add(accept_log)
self.db.flush()
self.db.refresh(accept_log)
order = models.TrCustomerOrder()
order.order_id = utils.gen_order_id()
order.customer_id = user.customer_id
order.product_id = user.product_id
order.account_number = form.d.account_number
order.order_fee = utils.yuan2fen(form.d.fee_value)
order.actual_fee = utils.yuan2fen(form.d.fee_value)
order.pay_status = 1
order.accept_id = accept_log.id
order.order_source = 'console'
order.create_time = utils.get_currtime()
order.order_desc = accept_log.accept_desc
self.db.add(order)
self.add_oplog(order.order_desc)
account.balance += order.actual_fee
self.db.commit()
self.redirect(self.detail_url_fmt(account_number))
示例12: get
def get(self):
ostype_id = self.get_argument("ostype_id")
self.db.query(models.TrwOSTypes).filter_by(id=ostype_id).delete()
ops_log = models.TrwOperateLog()
ops_log.operator_name = self.get_secure_cookie("tra_user")
ops_log.operate_ip = self.get_secure_cookie("tra_login_ip")
ops_log.operate_time = utils.get_currtime()
ops_log.operate_desc = u'操作员(%s)删除设备类型信息:%s' % (ops_log.operator_name, ostype_id)
self.db.add(ops_log)
self.db.commit()
self.redirect("/ostype",permanent=False)
示例13: get
def get(self):
operator_id = self.get_argument("operator_id")
opr = self.db.query(models.TrwOperator).get(operator_id)
self.db.query(models.TrwOperatorRule).filter_by(operator_name=opr.operator_name).delete()
self.db.query(models.TrwOperator).filter_by(id=operator_id).delete()
ops_log = models.TrwOperateLog()
ops_log.operator_name = self.get_secure_cookie("tra_user")
ops_log.operate_ip = self.get_secure_cookie("tra_login_ip")
ops_log.operate_time = utils.get_currtime()
ops_log.operate_desc = u'删除操作员%s信息' % opr.operator_name
self.db.add(ops_log)
self.db.commit()
self.redirect("/operator",permanent=False)
示例14: post
def post(self):
try:
req_msg = self.parse_form_request()
except Exception as err:
self.render_result(code=1, msg=safeunicode(err.message))
return
ispserv = models.TrwIspService()
ispserv.isp_code = req_msg.get("isp_code")
ispserv.service_type = req_msg.get("service_type")
ispserv.sub_time = get_currtime()
self.db.add(ispserv)
self.db.commit()
self.render_result(code=0, msg="success")
示例15: post
def post(self):
form = ssid_form.ssid_update_form([])
if not form.validates(source=self.get_params()):
return self.render("base_form.html", form=form)
mssid = self.db.query(models.TrwSsid).get(form.d.id)
mssid.domain_code = form.d.domain_code
mssid.ssid_desc = form.d.ssid_desc
ops_log = models.TrwOperateLog()
ops_log.operator_name = self.get_secure_cookie("tra_user")
ops_log.operate_ip = self.get_secure_cookie("tra_login_ip")
ops_log.operate_time = utils.get_currtime()
ops_log.operate_desc = u'操作员(%s)修改SSID信息:%s' % (ops_log.operator_name, mssid.ssid)
self.db.add(ops_log)
self.db.commit()
self.redirect("/ssid",permanent=False)