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


Python network.get_ip函数代码示例

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


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

示例1: _album_params

def _album_params(album):
    items = album.items
    if not items:
        abort(404)
    files = objects[Album](album)['files']

    types = set([f.processor for f in items])
    filename = album.hash
    subtitles = False
    for f in items:
        metadata = {}
        if f.metadata and f.metadata != 'null':
            try:
                metadata = json.loads(f.metadata)
            except:
                pass
        if 'has_subtitles' in metadata:
            subtitles = metadata['has_subtitles']

    can_delete = None
    try:
        if request.cookies.get('hist-opt-out', '0') == '1':
            can_delete = check_password_hash(f.ip, get_ip())
    except:
        pass

    return vars()
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:27,代码来源:media.py

示例2: inject

def inject():
    cdn = _cfg("cdn")
    if is_tor():
        cdn = _cfg("tor_domain")
    ads = True
    if 'ad-opt-out' in request.cookies:
        ads = False
    if g.do_not_track:
        ads = False
    if not _cfg("project_wonderful_id"):
        ads = False
    return {
        'mobile': g.mobile,
        'ua_platform': request.user_agent.platform,
        'analytics_id': _cfg("google_analytics_id"),
        'analytics_domain': _cfg("google_analytics_domain"),
        'dwolla_id': _cfg("dwolla_id"),
        'coinbase_id': _cfg("coinbase_id"),
        'flattr_id': _cfg("flattr_id"),
        'dark_theme': "dark_theme" in request.cookies,
        'ads': ads,
        'ad_id': _cfg("project_wonderful_id"),
        'notice_text': notice_text,
        'notice_enabled': notice_enabled,
        'share': share,
        'render_media': render_media,
        'len': len,
        'str': str,
        'get_mimetype': get_mimetype,
        'cdn': cdn,
        'is_tor': is_tor(),
        'ip': get_ip(),
        'media_url': media_url,
        'root': _cfg("protocol") + "://" + _cfg("domain")
    }
开发者ID:Jaex,项目名称:MediaCrush,代码行数:35,代码来源:app.py

示例3: hash_text

    def hash_text(self, h):
        klass = RedisObject.klass(h)
        max_length = 2048

        if not klass or klass not in [Album, File]:
            return {'error': 404}, 404

        properties = ["title", "description"]
        if not any(prop in request.form for prop in properties):
            return {'error': 400}, 400

        try:
            o = klass.from_hash(h) # We don't care about the object type
            if not check_password_hash(o.ip, get_ip()):
                return {'error': 401}, 401
        except:
            return {'error': 401}, 401

        if o.text_locked:
            return {'error': 408}, 408


        for prop in properties:
            if prop in request.form:
                data = request.form[prop]
                if len(data) > max_length:
                    return {'error': 414}, 414

                setattr(o, prop, data)
        o.save()
        return {'status': 'success'}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:31,代码来源:api.py

示例4: inject

def inject():
    cdn = _cfg("cdn")
    if is_tor():
        cdn = _cfg("tor_domain")
    return {
        "mobile": g.mobile,
        "analytics_id": _cfg("google_analytics_id"),
        "analytics_domain": _cfg("google_analytics_domain"),
        "dwolla_id": _cfg("dwolla_id"),
        "coinbase_id": _cfg("coinbase_id"),
        "flattr_id": _cfg("flattr_id"),
        "adsense_client": _cfg("adsense_client"),
        "adsense_slot": _cfg("adsense_slot"),
        "dark_theme": "dark_theme" in request.cookies,
        "ads": not "ad-opt-out" in request.cookies,
        "notice_text": notice_text,
        "notice_enabled": notice_enabled,
        "share": share,
        "render_media": render_media,
        "len": len,
        "str": str,
        "get_mimetype": get_mimetype,
        "cdn": cdn,
        "is_tor": is_tor(),
        "ip": get_ip(),
        "media_url": media_url,
        "root": _cfg("protocol") + "://" + _cfg("domain"),
    }
开发者ID:Thapelo-Tsotetsi,项目名称:MediaCrush,代码行数:28,代码来源:app.py

示例5: inject

def inject():
    cdn = _cfg("cdn")
    if is_tor():
        cdn = _cfg("tor_domain")
    return {
        'mobile': g.mobile,
        'analytics_id': _cfg("google_analytics_id"),
        'analytics_domain': _cfg("google_analytics_domain"),
        'dwolla_id': _cfg("dwolla_id"),
        'coinbase_id': _cfg("coinbase_id"),
        'flattr_id': _cfg("flattr_id"),
        'adsense_client': _cfg("adsense_client"),
        'adsense_slot': _cfg("adsense_slot"),
        'dark_theme': "dark_theme" in request.cookies,
        'ads': not "ad-opt-out" in request.cookies,
        'notice_text': notice_text,
        'notice_enabled': notice_enabled,
        'share': share,
        'render_media': render_media,
        'len': len,
        'str': str,
        'get_mimetype': get_mimetype,
        'cdn': cdn,
        'is_tor': is_tor(),
        'ip': get_ip(),
        'media_url': media_url,
        'root': _cfg("protocol") + "://" + _cfg("domain")
    }
开发者ID:JIVS,项目名称:MediaCrush,代码行数:28,代码来源:app.py

示例6: _template_params

def _template_params(f):
    if f.compression:
        compression = int(float(f.compression) * 100)
    if compression == 100 or f.status != "done":
        compression = None

    can_delete = None
    try:
        if request.cookies.get('hist-opt-out', '0') == '1':
            can_delete = check_password_hash(f.ip, get_ip())
    except:
        pass

    mimetype = f.mimetype
    processor = get_processor(f.processor)

    types = [mimetype]
    for f_ext in processor.outputs:
        types.append(get_mimetype(f_ext))

    if 'do-not-send' in request.cookies:
        try:
            blacklist = json.loads(request.cookies['do-not-send'])
            for t in blacklist:
                if t in types:
                    types.remove(t)
        except:
            pass
    metadata = {}
    if f.metadata and f.metadata != 'null':
        metadata = json.loads(f.metadata)
    subtitles = None
    if 'subtitles' in metadata and 'streams' in metadata['subtitles']:
        for stream in metadata['subtitles']['streams']:
            if stream['type'] == 'subtitle':
                subtitles = stream
                if subtitles['info']['codec_name'] == 'ssa':
                    subtitles['info']['codec_name'] = 'ass'
                subtitles['url'] = '/' + f.hash + '.' + subtitles['info']['codec_name']
                break

    return {
        'filename': f.hash,
        'original': f.original,
        'video': normalise_processor(f.processor) == 'video',
        'flags': f.flags.as_dict(),
        'metadata': metadata,
        'subtitles': subtitles,
        'has_subtitles': subtitles != None,
        'compression': compression,
        'mimetype': mimetype,
        'can_delete': can_delete if can_delete is not None else 'check',
        'fragment': 'fragments/' + fragment(f.processor) + '.html',
        'types': types,
        'processor': f.processor,
        'protocol': _cfg("protocol"),
        'domain': _cfg("domain"),
    }
开发者ID:Thapelo-Tsotetsi,项目名称:MediaCrush,代码行数:58,代码来源:media.py

示例7: delete

    def delete(self, h):
        klass = RedisObject.klass(h)

        if not klass:
            return {'error': 404}, 404
        try:
            o = klass.from_hash(h)
            if not check_password_hash(o.ip, get_ip()):
                return {'error': 401}, 401
        except:
            return {'error': 401}, 401

        deletion_procedures[klass](o)
        return {'status': 'success'}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:14,代码来源:api.py

示例8: _album_params

def _album_params(album):
    items = album.items
    if not items:
        abort(404)

    types = set([f.processor for f in items])

    can_delete = None
    try:
        if request.cookies.get('hist-opt-out', '0') == '1':
            can_delete = check_password_hash(f.ip, get_ip())
    except:
        pass

    return vars()
开发者ID:amumu,项目名称:MediaCrush,代码行数:15,代码来源:media.py

示例9: upload

def upload(f, filename):
    if not f.content_type:
        f.content_type = get_mimetype(filename) or "application/octet-stream"

    #if f.content_type.split("/")[0] not in ['video', 'image', 'audio']:
    #    return "no", 415

    ignore_limit = current_app.debug or r.sismember(_k("whitelisted_ips"), get_ip())
    if not ignore_limit:
        rate_limit_update(file_length(f))
        if rate_limit_exceeded():
            return None, 420

    h = get_hash(f)
    identifier = to_id(h)
    if "." not in filename:
        ext = mimetypes.guess_extension(f.content_type)[1:] # This not very scientific, but it works
    else:
        ext = extension(filename)

    filename = "%s.%s" % (identifier, ext)
    path = tempfile.NamedTemporaryFile(suffix="." + ext).name # Fix for imagemagick's silliness

    if os.path.exists(file_storage(filename)):
        if File.exists(identifier):
            return identifier, 409
        else:
            # Delete residual files from storage by creating a dummy File
            dummy = File(original=filename)
            dummy.delete = lambda: None # nop
            delete_file(dummy)

    f.seek(0)  # Otherwise it'll write a 0-byte file
    f.save(path)

    file_object = File(hash=identifier)
    file_object.compression = os.path.getsize(path)
    file_object.original = filename
    file_object.mimetype = f.content_type
    file_object.ip = secure_ip()

    result = process_file.delay(path, identifier, ignore_limit)
    file_object.taskid = result.id

    file_object.save()

    return identifier, 200
开发者ID:DiodeZ,项目名称:MediaCrush,代码行数:47,代码来源:files.py

示例10: _template_params

def _template_params(f):
    if f.compression:
        compression = int(float(f.compression) * 100)
    if compression == 100 or f.status != "done":
        compression = None

    can_delete = None
    try:
        if request.cookies.get('hist-opt-out', '0') == '1':
            can_delete = check_password_hash(f.ip, get_ip())
    except:
        pass

    mimetype = f.mimetype
    processor = get_processor(f.processor)

    types = [mimetype]
    for f_ext in processor.outputs:
        types.append(get_mimetype(f_ext))

    if 'do-not-send' in request.cookies:
        try:
            blacklist = json.loads(request.cookies['do-not-send'])
            for t in blacklist:
                if t in types:
                    types.remove(t)
        except:
            pass

    return {
        'filename': f.hash,
        'original': f.original,
        'video': mimetype in VIDEO_FORMATS,
        'loop': mimetype in LOOP_FORMATS,
        'autoplay': mimetype in AUTOPLAY_FORMATS,
        'compression': compression,
        'mimetype': mimetype,
        'can_delete': can_delete if can_delete is not None else 'check',
        'fragment': 'fragments/' + fragment(f.processor) + '.html',
        'types': types,
        'processor': f.processor,
        'protocol': _cfg("protocol"),
        'domain': _cfg("domain"),
    }
开发者ID:SCORE42,项目名称:MediaCrush,代码行数:44,代码来源:media.py

示例11: inject

def inject():
    if is_tor():
        cdn = _cfg("tor_domain")
    ads = True
    if "ad-opt-out" in request.cookies:
        ads = False
    if g.do_not_track:
        ads = False
    if not _cfg("project_wonderful_id"):
        ads = False

    return {
        "mobile": g.mobile,
        "ua_platform": request.user_agent.platform,
        "analytics_id": _cfg("google_analytics_id"),
        "analytics_domain": _cfg("google_analytics_domain"),
        "dwolla_id": _cfg("dwolla_id"),
        "coinbase_id": _cfg("coinbase_id"),
        "flattr_id": _cfg("flattr_id"),
        "dark_theme": "dark_theme" in request.cookies,
        "ads": ads,
        "ad_id": _cfg("project_wonderful_id"),
        "notice_text": notice_text,
        "notice_enabled": notice_enabled,
        "share": share,
        "render_media": render_media,
        "len": len,
        "str": str,
        "get_mimetype": get_mimetype,
        "cdn_url": cdn_url,
        "is_tor": is_tor(),
        "ip": get_ip(),
        "media_url": media_url,
        "root": _cfg("protocol") + "://" + _cfg("domain"),
        "random": random,
        "shard": shard,
        "max_file_size": get_maxsize(),
    }
开发者ID:zenny,项目名称:MediaCrush,代码行数:38,代码来源:app.py

示例12: flags_post

    def flags_post(self, h):
        klass = RedisObject.klass(h)

        if not klass:
            return {'error': 404}, 404
        try:
            o = klass.from_hash(h)
            if not check_password_hash(o.ip, get_ip()):
                return {'error': 401}, 401
        except:
            return {'error': 401}, 401

        # At this point, we're authenticated and o is the object.
        for flag, value in request.form.items():
            v = True if value == 'true' else False

            try:
                setattr(o.flags, flag, v)
            except AttributeError:
                return {'error': 415}, 415

        o.save()

        return {"flags": o.flags.as_dict()}
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:24,代码来源:api.py


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