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


Python Utils.parse_int方法代码示例

本文整理汇总了Python中tinyms.core.common.Utils.parse_int方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.parse_int方法的具体用法?Python Utils.parse_int怎么用?Python Utils.parse_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tinyms.core.common.Utils的用法示例。


在下文中一共展示了Utils.parse_int方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: finger_tpl_save

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
    def finger_tpl_save(self):
        index = Utils.parse_int(self.param("index"))
        tpl = self.param("tpl")
        archives_id = Utils.parse_int(self.param("archives_id"))
        sf = SessionFactory.new()
        obj = sf.query(ValidWorkFingerTemplate) \
            .filter(ValidWorkFingerTemplate.archives_id == archives_id) \
            .filter(ValidWorkFingerTemplate.finger_index == index).limit(1).scalar()

        machines_sn = sf.query(ValidWorkMachine.sn).all()
        machines_sn = [sn[0] for sn in machines_sn]
        name = sf.query(Archives.name).filter(Archives.id == archives_id).limit(1).scalar()
        for sn in machines_sn:
            ValidWorkHelper.push_user_fp_to_machine(sn, archives_id, name, index, tpl)

        if obj:
            obj.tpl = tpl
            sf.commit()
            return ["success"]
        else:
            if archives_id:
                sf = SessionFactory.new()
                obj = ValidWorkFingerTemplate()
                obj.card_no = ""
                obj.finger_index = index
                obj.tpl = tpl
                obj.archives_id = archives_id
                sf.add(obj)
                sf.commit()
                return ["success"]
        return ["failure"]
开发者ID:tinyms,项目名称:Matty,代码行数:33,代码来源:controller.py

示例2: post

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
    def post(self, *args, **kwargs):

        #记录机器访问数据
        params_ = self.wrap_params_to_dict()
        sn = params_.get("SN")
        sf = SessionFactory.new()
        machine = sf.query(ValidWorkMachine).filter(ValidWorkMachine.sn == sn).limit(1).scalar()
        table = params_.get("table")
        if table == "OPERLOG":
            op_stamp = params_.get("OpStamp")
            if op_stamp and machine:
                machine.opstamp = Utils.parse_int(op_stamp)
                sf.commit()
            self.write("OK")
        elif table == "ATTLOG":
            stamp = params_.get("Stamp")
            if stamp and machine:
                stamp = Utils.parse_int(stamp)
                machine.stamp = stamp
                sf.commit()

            if stamp and stamp > 0:
                records_text = self.request.body
                if records_text:
                    records_text = records_text.decode("utf-8")
                    records = list()
                    for line in records_text.split("\n"):
                        items = line.split("\t")
                        if len(items) >= 2:
                            records.append((items[0], items[1]))
                    for r in records:
                        archives_id = r[0]
                        touch_time = datetime.strptime(r[1], "%Y-%m-%d %H:%M:%S")
                        self.detect_chkon_status(archives_id, touch_time)
                    self.write("OK")
开发者ID:tinyms,项目名称:Matty,代码行数:37,代码来源:controller.py

示例3: list

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
    def list(self, id_):
        name = DataViewModule.__view_mapping__.get(id_)
        if not name:
            self.set_status(403, "Error!")

        self.set_header("Content-Type", "text/json;charset=utf-8")
        display_start = Utils.parse_int(self.get_argument("iDisplayStart"))
        display_length = Utils.parse_int(self.get_argument("iDisplayLength"))

        total = 0
        ds = list()

        custom_data_provider = ObjectPool.dataview_provider.get(name)
        if custom_data_provider:
            default_search_value = self.get_argument("sSearch")
            obj = custom_data_provider()
            if hasattr(obj, "count"):
                total = obj.count(default_search_value, self)
            if hasattr(obj, "list"):
                ds = obj.list(default_search_value, display_start, display_length, self)

        results = dict()
        results["sEcho"] = self.get_argument("sEcho")
        results["iTotalRecords"] = total
        results["iTotalDisplayRecords"] = total
        results["aaData"] = ds

        self.write(json.dumps(results, cls=JsonEncoder))
开发者ID:tinyms,项目名称:Matty,代码行数:30,代码来源:widgets.py

示例4: task_assign

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def task_assign(self):
     archives_id = Utils.parse_int(self.param("id"))
     task_id = Utils.parse_int(self.param("st_id"))
     if archives_id and task_id:
         sf = SessionFactory.new()
         usr = sf.query(Archives).get(archives_id)
         if usr:
             usr.validworkscheduletasks = []
             task = sf.query(ValidWorkScheduleTask).get(task_id)
             usr.validworkscheduletasks.append(task)
             sf.commit()
             return ["success"]
     return ["failure"]
开发者ID:tinyms,项目名称:Matty,代码行数:15,代码来源:controller.py

示例5: save

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def save(self):
     account_id = Utils.parse_int(self.param("id"))
     role_id = Utils.parse_int(self.param("role_id"))
     state = Utils.parse_int(self.param("state"))
     cnn = SessionFactory.new()
     account = cnn.query(Account).get(account_id)
     if account:
         role = cnn.query(Role).get(role_id)
         if role:
             if state == 0:
                 account.roles.append(role)
             else:
                 account.roles.remove(role)
             cnn.commit()
             return ["success"]
     return ["failure"]
开发者ID:tinyms,项目名称:Matty,代码行数:18,代码来源:security.py

示例6: list_fingers

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def list_fingers(self):
     sf = SessionFactory.new()
     archives_id = Utils.parse_int(self.param("archives_id"))
     items = sf.query(ValidWorkFingerTemplate.finger_index) \
         .filter(ValidWorkFingerTemplate.archives_id == archives_id).all()
     items = [item[0] for item in items]
     return items
开发者ID:tinyms,项目名称:Matty,代码行数:9,代码来源:controller.py

示例7: list

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
    def list(self, keywords, start, limit, http_req):
        org_id = Utils.parse_int(http_req.get_argument("org_id"))
        sf = SessionFactory.new()
        q = sf.query(Archives.id, Archives.name, Archives.sex, Archives.org_id, ValidWorkScheduleTask.name,
                     ValidWorkScheduleTask.id) \
            .outerjoin(ValidWorkScheduleTask, Archives.validworkscheduletasks)
        q = q.filter(Archives.name != "超级管理员")
        if keywords:
            q = q.filter(Archives.name.like("%" + keywords + "%"))
        if org_id:
            q = q.filter(Archives.org_id == org_id)

        rows = q.order_by(Archives.name).offset(start).limit(limit).all()
        items = list()
        for row in rows:
            item = dict()
            item["id"] = row[0]
            item["name"] = row[1]
            item["sex"] = row[2]
            item["org_id"] = row[3]
            item["st_name"] = row[4]
            if not row[4]:
                item["st_name"] = ""
            item["st_id"] = row[5]
            if not row[5]:
                item["st_id"] = 0
            items.append(item)
        return items
开发者ID:tinyms,项目名称:Matty,代码行数:30,代码来源:controller.py

示例8: list

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def list(self):
     account_id = Utils.parse_int(self.param("id"))
     cnn = SessionFactory.new()
     ds = cnn.query(Role.id).join(Account, Role.accounts).filter(Account.id == account_id).all()
     roles = list()
     for row in ds:
         roles.append(row[0])
     return roles
开发者ID:tinyms,项目名称:Matty,代码行数:10,代码来源:security.py

示例9: after_add

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def after_add(self, entity_obj, sf, req):
     length = len(str(sf.query(func.count(Archives.id)).scalar()))
     obj = sf.query(Archives).get(entity_obj.id)
     max_length = AppSettingHelper.get("s_usr_code_fmt_length", "5")
     prefix = AppSettingHelper.get("s_usr_code_prefix", "P")
     if length > Utils.parse_int(max_length):
         max_length = "%s" % (length + 1)
     fmt = prefix + "%0" + max_length + "d"
     obj.code = fmt % entity_obj.id
     sf.commit()
开发者ID:tinyms,项目名称:ArchiveX,代码行数:12,代码来源:archives.py

示例10: save

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def save(self):
     id_ = Utils.parse_int(self.param("id"))
     tb_id = Utils.parse_int(self.param("tb_id"))
     state = self.param("s")
     if id_ > 0 and tb_id > 0:
         if state == "1":
             sf = SessionFactory.new()
             task = sf.query(ValidWorkScheduleTask).get(id_)
             timeblock = sf.query(ValidWorkTimeBlock).get(tb_id)
             task.validworktimeblocks.append(timeblock)
             sf.commit()
         else:
             sf = SessionFactory.new()
             task = sf.query(ValidWorkScheduleTask).get(id_)
             timeblock = sf.query(ValidWorkTimeBlock).get(tb_id)
             task.validworktimeblocks.remove(timeblock)
             sf.commit()
         return ["success"]
     return ["failure"]
开发者ID:tinyms,项目名称:Matty,代码行数:21,代码来源:controller.py

示例11: push_finger_tpl_to_machine

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def push_finger_tpl_to_machine(self):
     sf = SessionFactory.new()
     sn = sf.query(ValidWorkMachine.sn) \
         .filter(ValidWorkMachine.id == Utils.parse_int(self.param("machine_id"))).limit(1).scalar()
     peoples = sf.query(ValidWorkFingerTemplate.archives_id, Archives.name,
                        ValidWorkFingerTemplate.finger_index, ValidWorkFingerTemplate.tpl) \
         .join((Archives, ValidWorkFingerTemplate.archives)).all()
     finger_tpl_list = list()
     for p in peoples:
         finger_tpl_list.append(p)
     ValidWorkHelper.push_users_fp_to_machine(sn, finger_tpl_list)
     return ["success"]
开发者ID:tinyms,项目名称:Matty,代码行数:14,代码来源:controller.py

示例12: add

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def add(self, http_req):
     login_name = http_req.get_argument("login_name")
     if not login_name:
         return "UserLoginIdNotBlank"
     password = http_req.get_argument("password")
     if not password:
         return "PasswordNotBlank"
     repassword = http_req.get_argument("repassword")
     if password != repassword:
         return "PasswordNotSame"
     bind_target_user = http_req.get_argument("archives_id")
     enabled = Utils.parse_int(http_req.get_argument("enabled"))
     account_id = AccountHelper.create(login_name, password, bind_target_user, enabled)
     return account_id
开发者ID:tinyms,项目名称:Matty,代码行数:16,代码来源:security.py

示例13: modify

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def modify(self, id_, http_req):
     login_name = http_req.get_argument("login_name")
     if not login_name:
         return "UserLoginIdNotAllowedBlank"
     password = http_req.get_argument("password")
     print(password)
     if password:
         repassword = http_req.get_argument("repassword")
         if password != repassword:
             return "PasswordIsNotSame"
     bind_target_user = http_req.get_argument("archives_id")
     enabled = Utils.parse_int(http_req.get_argument("enabled"))
     msg = AccountHelper.update(id_, login_name, password, bind_target_user, enabled)
     if msg == "Updated":
         return ""
     return msg
开发者ID:tinyms,项目名称:Matty,代码行数:18,代码来源:security.py

示例14: dict

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
 def dict(self, dict_=None):
     """
     1, object to map
     2, map to object
     :param dict_:
     :return:
     """
     if not dict_:
         columns = [c.key for c in class_mapper(self.__class__).columns]
         return dict((c, getattr(self, c)) for c in columns)
     else:
         metas = self.cols_meta()
         for k, v in dict_.items():
             print(k, v)
             if not hasattr(self, k):
                 continue
             for m in metas:
                 if m["name"] == k:
                     if m["type"] == "int":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_int(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "numeric":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_float(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "datetime":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_datetime(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "date":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_date(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "time":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_time(v))
                         else:
                             setattr(self, k, v)
                     else:
                         setattr(self, k, v)
             pass
         pass
开发者ID:tinyms,项目名称:Matty,代码行数:49,代码来源:orm.py

示例15: create

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_int [as 别名]
    def create(login_id, pwd, archives_id=None, enabled=0):
        cnn = SessionFactory.new()
        obj = Account()
        obj.login_name = login_id
        obj.login_pwd = Utils.md5(pwd)
        obj.create_time = Utils.current_datetime()
        obj.enabled = enabled
        obj.archives_id = archives_id
        cnn.add(obj)
        cnn.flush()

        default_role_id = Utils.parse_int(AppSettingHelper.get("s_usr_register_default_role_name", "0"))
        if default_role_id > 0:
            default_role = cnn.query(Role).get(default_role_id)
            if default_role:
                obj.roles.append(default_role)

        cnn.commit()
        return obj.id
开发者ID:tinyms,项目名称:Matty,代码行数:21,代码来源:account.py


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