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


Python Event.width方法代码示例

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


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

示例1: gatraPlayer_PostEvent

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import width [as 别名]
def gatraPlayer_PostEvent(request, id):

    allowed_methods = ['POST', 'OPTIONS']

    if request.method == 'OPTIONS':
        response = HttpResponse('', status=http_REQUEST_OK)
        response['Allow'] = ', '.join(allowed_methods)
        return response

    if request.method != 'POST':
        return HttpResponse('', status=http_NOT_ALLOWED)

    if 'HTTP_GATRA_HASH' in request.META.keys():
        _hash = request.META['HTTP_GATRA_HASH']
        try:
            h = Hash.objects.get(valid_hash = _hash)
        except:
            return HttpResponse(_hash, status=http_UNAUTHORIZED)
    else:
        return HttpResponse('', status=http_UNAUTHORIZED)

    if id is None:
        return HttpResponse('', status=http_BAD_REQUEST)

    try:
        jsonData = json.loads(request.body)
    except:
        return HttpResponse('Could not load json', status=http_BAD_REQUEST)

    if ('type' in jsonData.keys() and
    'trigger' in jsonData.keys() and
    'width' in jsonData.keys() and
    'container_height' in jsonData.keys() and
    'container_width' in jsonData.keys() and
    'state' in jsonData.keys() and
    'position' in jsonData.keys() and
    'fullscreen' in jsonData.keys() and
    'volume' in jsonData.keys()):

        try:
            play_id = Play.objects.get(id = id)
        except:
            return HttpResponse('Play ID not found', status=http_BAD_REQUEST)

        event = Event()
        event.play		= play_id
        event.type              = jsonData['type']
        event.trigger           = jsonData['trigger']
        event.width             = jsonData['width']
        event.container_height  = jsonData['container_height']
        event.container_width	= jsonData['container_width']
        event.state             = jsonData['state']
        event.position          = jsonData['position']
        event.fullscreen        = jsonData['fullscreen']
        event.volume            = jsonData['volume']

        if 'bitrate' in jsonData.keys():
            event.bitrate = jsonData['bitrate']

        if 'bandwidth' in jsonData.keys():
            event.bandwidth = jsonData['bandwidth']

        if 'media_seq' in jsonData.keys():
            event.media_seq = jsonData['media_seq']

        if 'load_time' in jsonData.keys():
            event.load_time = jsonData['load_time']

        if 'quality_label' in jsonData.keys():
            event.quality_label = jsonData['quality_label']

        event.save()

        status = http_POST_OK
        return HttpResponse('', status=status, content_type='application/json')

    return HttpResponse('Mandatory json value not found', status=http_BAD_REQUEST)
开发者ID:npajoni,项目名称:gatra,代码行数:79,代码来源:views.py


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