当前位置: 首页>>代码示例>>Python>>正文


Python utils.get_currtime函数代码示例

本文整理汇总了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, )
开发者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


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