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

Python utils.is_float函数代码示例

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

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



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

示例1: process_data_timestamp

def process_data_timestamp(data, current_datetime=None):
    if is_float(data["timestamp"]):
        try:
            data["timestamp"] = datetime.fromtimestamp(float(data["timestamp"]))
        except Exception:
            raise InvalidTimestamp("Invalid value for timestamp: %r" % data["timestamp"])
    elif not isinstance(data["timestamp"], datetime):
        if "." in data["timestamp"]:
            format = "%Y-%m-%dT%H:%M:%S.%f"
        else:
            format = "%Y-%m-%dT%H:%M:%S"
        if "Z" in data["timestamp"]:
            # support UTC market, but not other timestamps
            format += "Z"
        try:
            data["timestamp"] = datetime.strptime(data["timestamp"], format)
        except Exception:
            raise InvalidTimestamp("Invalid value for timestamp: %r" % data["timestamp"])

    if current_datetime is None:
        current_datetime = datetime.now()

    if data["timestamp"] > current_datetime + timedelta(minutes=1):
        raise InvalidTimestamp("Invalid value for timestamp (in future): %r" % data["timestamp"])

    if data["timestamp"] < current_datetime - timedelta(days=30):
        raise InvalidTimestamp("Invalid value for timestamp (too old): %r" % data["timestamp"])

    data["timestamp"] = float(data["timestamp"].strftime("%s"))

    return data
开发者ID:achun2080,项目名称:sentry,代码行数:31,代码来源:coreapi.py


示例2: process_data_timestamp

def process_data_timestamp(data):
    if is_float(data['timestamp']):
        try:
            data['timestamp'] = datetime.fromtimestamp(
                float(data['timestamp']))
        except Exception:
            raise InvalidTimestamp(
                'Invalid value for timestamp: %r' % data['timestamp'])
    elif not isinstance(data['timestamp'], datetime):
        if '.' in data['timestamp']:
            format = '%Y-%m-%dT%H:%M:%S.%f'
        else:
            format = '%Y-%m-%dT%H:%M:%S'
        if 'Z' in data['timestamp']:
            # support UTC market, but not other timestamps
            format += 'Z'
        try:
            data['timestamp'] = datetime.strptime(data['timestamp'], format)
        except Exception:
            raise InvalidTimestamp(
                'Invalid value for timestamp: %r' % data['timestamp'])

    if data['timestamp'] > datetime.now() + timedelta(minutes=1):
        raise InvalidTimestamp(
            'Invalid value for timestamp (in future): %r' % data['timestamp'])

    return data
开发者ID:ecarreras,项目名称:sentry,代码行数:27,代码来源:coreapi.py


示例3: process_data_timestamp

 def process_data_timestamp(data):
     if is_float(data['timestamp']):
         try:
             data['timestamp'] = datetime.fromtimestamp(float(data['timestamp']))
         except:
             logger.exception('Failed reading timestamp')
             del data['timestamp']
     elif not isinstance(data['timestamp'], datetime):
         try:
             data['timestamp'] = dateutil.parser.parse(data['timestamp'])
         except:
             logger.exception('Failed reading timestamp')
             del data['timestamp']
开发者ID:Kronuz,项目名称:django-sentry,代码行数:13,代码来源:coreapi.py


示例4: process_data_timestamp

def process_data_timestamp(data):
    if is_float(data['timestamp']):
        try:
            data['timestamp'] = datetime.fromtimestamp(float(data['timestamp']))
        except Exception:
            logger.exception('Failed reading timestamp')
            del data['timestamp']
    elif not isinstance(data['timestamp'], datetime):
        if '.' in data['timestamp']:
            format = '%Y-%m-%dT%H:%M:%S.%f'
        else:
            format = '%Y-%m-%dT%H:%M:%S'
        if 'Z' in data['timestamp']:
            # support UTC market, but not other timestamps
            format += 'Z'
        try:
            data['timestamp'] = datetime.strptime(data['timestamp'], format)
        except Exception:
            raise InvalidTimestamp('Invalid value for timestamp: %r' % data['timestamp'])

    return data
开发者ID:Crowdbooster,项目名称:sentry,代码行数:21,代码来源:coreapi.py


示例5: process_data_timestamp

def process_data_timestamp(data):
    if is_float(data["timestamp"]):
        try:
            data["timestamp"] = datetime.fromtimestamp(float(data["timestamp"]))
        except:
            logger.exception("Failed reading timestamp")
            del data["timestamp"]
    elif not isinstance(data["timestamp"], datetime):
        if "." in data["timestamp"]:
            format = "%Y-%m-%dT%H:%M:%S.%f"
        else:
            format = "%Y-%m-%dT%H:%M:%S"
        if "Z" in data["timestamp"]:
            # support UTC market, but not other timestamps
            format += "Z"
        try:
            data["timestamp"] = datetime.strptime(data["timestamp"], format)
        except:
            raise InvalidTimestamp("Invalid value for timestamp: %r" % data["timestamp"])

    return data
开发者ID:nikitka,项目名称:sentry,代码行数:21,代码来源:coreapi.py


示例6: _process_data_timestamp

    def _process_data_timestamp(self, data, current_datetime=None):
        value = data['timestamp']
        if not value:
            del data['timestamp']
            return data
        elif is_float(value):
            try:
                value = datetime.fromtimestamp(float(value))
            except Exception:
                raise InvalidTimestamp('Invalid value for timestamp: %r' % data['timestamp'])
        elif not isinstance(value, datetime):
            # all timestamps are in UTC, but the marker is optional
            if value.endswith('Z'):
                value = value[:-1]
            if '.' in value:
                # Python doesn't support long microsecond values
                # https://github.com/getsentry/sentry/issues/1610
                ts_bits = value.split('.', 1)
                value = '%s.%s' % (ts_bits[0], ts_bits[1][:2])
                fmt = '%Y-%m-%dT%H:%M:%S.%f'
            else:
                fmt = '%Y-%m-%dT%H:%M:%S'
            try:
                value = datetime.strptime(value, fmt)
            except Exception:
                raise InvalidTimestamp('Invalid value for timestamp: %r' % data['timestamp'])

        if current_datetime is None:
            current_datetime = datetime.now()

        if value > current_datetime + timedelta(minutes=1):
            raise InvalidTimestamp('Invalid value for timestamp (in future): %r' % value)

        if value < current_datetime - timedelta(days=30):
            raise InvalidTimestamp('Invalid value for timestamp (too old): %r' % value)

        data['timestamp'] = float(value.strftime('%s'))

        return data
开发者ID:haojiang1,项目名称:sentry,代码行数:39,代码来源:coreapi.py


示例7: process_data_timestamp

def process_data_timestamp(data):
    if is_float(data["timestamp"]):
        try:
            data["timestamp"] = datetime.fromtimestamp(float(data["timestamp"]))
        except Exception:
            raise InvalidTimestamp("Invalid value for timestamp: %r" % data["timestamp"])
    elif not isinstance(data["timestamp"], datetime):
        if "." in data["timestamp"]:
            format = "%Y-%m-%dT%H:%M:%S.%f"
        else:
            format = "%Y-%m-%dT%H:%M:%S"
        if "Z" in data["timestamp"]:
            # support UTC market, but not other timestamps
            format += "Z"
        try:
            data["timestamp"] = datetime.strptime(data["timestamp"], format)
        except Exception:
            raise InvalidTimestamp("Invalid value for timestamp: %r" % data["timestamp"])

    if data["timestamp"] > datetime.now() + timedelta(minutes=1):
        raise InvalidTimestamp("Invalid value for timestamp (in future): %r" % data["timestamp"])

    return data
开发者ID:BlaShadow,项目名称:sentry,代码行数:23,代码来源:coreapi.py


示例8: abort

    try:
        if format == 'pickle':
            data = pickle.loads(data)
        elif format == 'json':
            data = simplejson.loads(data)
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception('Bad data received')
        abort(403, 'Bad data reconstructing object (%s, %s)' % (e.__class__.__name__, e))

    # XXX: ensure keys are coerced to strings
    data = dict((smart_str(k), v) for k, v in data.iteritems())

    if 'timestamp' in data:
        if is_float(data['timestamp']):
            data['timestamp'] = datetime.datetime.fromtimestamp(float(data['timestamp']))
        else:
            if '.' in data['timestamp']:
                format = '%Y-%m-%dT%H:%M:%S.%f'
            else:
                format = '%Y-%m-%dT%H:%M:%S'
            data['timestamp'] = datetime.datetime.strptime(data['timestamp'], format)

    GroupedMessage.objects.from_kwargs(**data)
    
    return ''

@login_required
def group_plugin_action(request, group_id, slug):
    group = get_object_or_404(GroupedMessage, pk=group_id)
开发者ID:pombredanne,项目名称:sentry,代码行数:31,代码来源:views.py


示例9: abort

        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception("Bad data received")
        abort(400, "Bad data decoding request (%s, %s)" % (e.__class__.__name__, e))

    try:
        data = simplejson.loads(data)
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception("Bad data received")
        abort(403, "Bad data reconstructing object (%s, %s)" % (e.__class__.__name__, e))

    # XXX: ensure keys are coerced to strings
    data = dict((str(k), v) for k, v in data.iteritems())

    if "timestamp" in data:
        if is_float(data["timestamp"]):
            data["timestamp"] = datetime.datetime.fromtimestamp(float(data["timestamp"]))
        else:
            if "." in data["timestamp"]:
                format = "%Y-%m-%dT%H:%M:%S.%f"
            else:
                format = "%Y-%m-%dT%H:%M:%S"
            data["timestamp"] = datetime.datetime.strptime(data["timestamp"], format)

    # TODO
    store()

    return ""
开发者ID:dmr,项目名称:sentry,代码行数:30,代码来源:api.py


示例10: abort

        data = base64.b64decode(data).decode('zlib')
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception('Bad data received')
        abort(400, 'Bad data decoding request (%s, %s)' % (e.__class__.__name__, e))

    try:
        data = simplejson.loads(data)
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception('Bad data received')
        abort(403, 'Bad data reconstructing object (%s, %s)' % (e.__class__.__name__, e))

    # XXX: ensure keys are coerced to strings
    data = dict((str(k), v) for k, v in data.iteritems())

    if 'date' in data:
        if is_float(data['date']):
            data['date'] = datetime.datetime.fromtimestamp(float(data['date']))
        else:
            if '.' in data['date']:
                format = '%Y-%m-%dT%H:%M:%S.%f'
            else:
                format = '%Y-%m-%dT%H:%M:%S'
            data['date'] = datetime.datetime.strptime(data['date'], format)

    app.client.store(**data)
    
    return ''
开发者ID:gandalfar,项目名称:sentry,代码行数:31,代码来源:api.py


示例11: abort

    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception("Bad data received")
        abort(400, "Bad data decoding request (%s, %s)" % (e.__class__.__name__, e))

    try:
        data = simplejson.loads(data)
    except Exception, e:
        # This error should be caught as it suggests that there's a
        # bug somewhere in the client's code.
        logger.exception("Bad data received")
        abort(403, "Bad data reconstructing object (%s, %s)" % (e.__class__.__name__, e))

    # XXX: ensure keys are coerced to strings
    data = dict((str(k), v) for k, v in data.iteritems())

    if "date" in data:
        if is_float(data["date"]):
            data["date"] = datetime.datetime.fromtimestamp(float(data["date"]))
        else:
            if "." in data["date"]:
                format = "%Y-%m-%dT%H:%M:%S.%f"
            else:
                format = "%Y-%m-%dT%H:%M:%S"
            data["date"] = datetime.datetime.strptime(data["date"], format)

    app.client.store(**data)

    return ""
开发者ID:vvangelovski,项目名称:sentry,代码行数:30,代码来源:api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.transform函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_filters函数代码示例发布时间: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