• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_currtime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中toughlib.utils.get_currtime函数的典型用法代码示例。如果您正苦于以下问题:Python get_currtime函数的具体用法?Python get_currtime怎么用?Python get_currtime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_currtime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, )
开发者ID:davislidaqing,项目名称:ToughRADIUS,代码行数:27,代码来源:acctounting.py


示例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)
开发者ID:YMXZ,项目名称:ToughRADIUS,代码行数:7,代码来源:log_trace.py


示例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)
开发者ID:niebaopeng,项目名称:ToughRADIUS,代码行数:7,代码来源:base.py


示例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
开发者ID:Kge38131,项目名称:ToughRADIUS,代码行数:7,代码来源:apibase.py


示例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"操作成功")
开发者ID:davislidaqing,项目名称:ToughRADIUS,代码行数:27,代码来源:account_pause.py


示例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"操作成功")
开发者ID:Evan-hu,项目名称:ToughRADIUS,代码行数:26,代码来源:account_resume.py


示例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")
开发者ID:gvsurenderreddy,项目名称:toughwlan,代码行数:26,代码来源:login.py


示例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"操作成功")
开发者ID:lxyjyy,项目名称:ToughRADIUS,代码行数:26,代码来源:account_pause.py


示例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))
开发者ID:gyc291195485,项目名称:ToughRADIUS,代码行数:47,代码来源:account_cancel.py


示例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))
开发者ID:davislidaqing,项目名称:ToughRADIUS,代码行数:46,代码来源:account_cancel.py


示例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))
开发者ID:gyc291195485,项目名称:ToughRADIUS,代码行数:46,代码来源:account_charge.py


示例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)
开发者ID:gvsurenderreddy,项目名称:toughwlan,代码行数:13,代码来源:ostype.py


示例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)
开发者ID:gvsurenderreddy,项目名称:toughwlan,代码行数:14,代码来源:operator.py


示例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")
开发者ID:gvsurenderreddy,项目名称:toughwlan,代码行数:15,代码来源:api_isp.py


示例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)
开发者ID:lanyeit,项目名称:toughwlan,代码行数:17,代码来源:ssid.py


示例16: post

    def post(self):
        tpls = [(t.tpl_name, t.tpl_desc) for t in self.db.query(models.TrwTemplate)]
        form = domain_form.domain_update_vform(tpls=tpls)
        if not form.validates(source=self.get_params()):
            return self.render("base_form.html", form=form)
        domain = self.db.query(models.TrwDomain).get(form.d.id)
        domain.tpl_name = form.d.tpl_name
        domain.domain_desc = form.d.domain_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)修改域信息:%s' % (ops_log.operator_name, domain.domain_code)
        self.db.add(ops_log)

        self.db.commit()
        self.redirect("/domain",permanent=False)
开发者ID:lanyeit,项目名称:toughwlan,代码行数:18,代码来源:domain.py


示例17: post

    def post(self):
        form = ostype_forms.ostype_update_form()
        if not form.validates(source=self.get_params()):
            self.render("base_form.html", form=form)
            return
        ostype = self.db.query(models.TrwOSTypes).get(form.d.id)
        ostype.os_name = form.d.os_name
        ostype.dev_type = form.d.dev_type
        ostype.match_rule = form.d.match_rule

        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.os_name)
        self.db.add(ops_log)

        self.db.commit()
        self.redirect("/ostype",permanent=False)
开发者ID:gvsurenderreddy,项目名称:toughwlan,代码行数:19,代码来源:ostype.py


示例18: post

    def post(self):
        form = password_forms.password_update_form()
        if not form.validates(source=self.get_params()):
            self.render("base_form.html", form=form)
            return
        if form.d.tra_user_pass != form.d.tra_user_pass_chk:
            self.render("base_form.html", form=form, msg=u'确认密码不一致')
            return
        opr = self.db.query(models.TrwOperator).filter_by(operator_name=form.d.tra_user).first()
        opr.operator_pass = md5(form.d.tra_user_pass).hexdigest()

        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)修改密码' % (self.get_secure_cookie("tra_user"),)
        self.db.add(ops_log)

        self.db.commit()
        self.redirect("/")
开发者ID:lanyeit,项目名称:toughwlan,代码行数:20,代码来源:password.py


示例19: post

    def post(self):
        form = operator_form.operator_update_form()
        if not form.validates(source=self.get_params()):
            rules = self.db.query(models.TrwOperatorRule.rule_path).filter_by(operator_name=form.d.operator_name)
            rules = [r[0] for r in rules]
            return self.render("base_form.html", form=form,rules=rules)
        operator = self.db.query(models.TrwOperator).get(form.d.id)
        if form.d.operator_pass:
            operator.operator_pass = md5(form.d.operator_pass.encode()).hexdigest()
        operator.operator_desc = form.d.operator_desc
        operator.operator_status = form.d.operator_status

        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信息' % operator.operator_name
        self.db.add(ops_log)

        # update rules
        self.db.query(models.TrwOperatorRule).filter_by(operator_name=operator.operator_name).delete()

        for path in self.get_arguments("rule_item"):
            item = permit.get_route(path)
            if not item: continue
            rule = models.TrwOperatorRule()
            rule.operator_name = operator.operator_name
            rule.rule_name = item['name']
            rule.rule_path = item['path']
            rule.rule_category = item['category']
            self.db.add(rule)

        permit.unbind_opr(operator.operator_name)

        self.db.commit()

        for rule in self.db.query(models.TrwOperatorRule).filter_by(operator_name=operator.operator_name):
            permit.bind_opr(rule.operator_name, rule.rule_path)

        self.redirect("/operator",permanent=False)
开发者ID:gvsurenderreddy,项目名称:toughwlan,代码行数:40,代码来源:operator.py


示例20: post

    def post(self):
        form = product_forms.product_update_form()
        if not form.validates(source=self.get_params()):
            return self.render("product_form.html", form=form)

        product = self.db.query(models.TrProduct).get(form.d.id)
        product.product_name = form.d.product_name
        product.product_status = form.d.product_status
        product.fee_months = int(form.d.get("fee_months", 0))
        product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
        product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
        product.bind_mac = form.d.bind_mac
        product.bind_vlan = form.d.bind_vlan
        product.concur_number = form.d.concur_number
        product.fee_period = ''#form.d.fee_period or ''
        product.fee_price = utils.yuan2fen(form.d.fee_price)
        product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
        product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
        product.update_time = utils.get_currtime()
        self.add_oplog(u'修改资费信息:%s' % utils.safeunicode(product.product_name))
        self.db.commit()
        self.redirect("/admin/product", permanent=False)
开发者ID:Evan-hu,项目名称:ToughRADIUS,代码行数:22,代码来源:product.py



注:本文中的toughlib.utils.get_currtime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.safestr函数代码示例发布时间:2022-05-27
下一篇:
Python logger.info函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap