Пример #1
0
def http_request_demo():
    listener =  BlenderListener(event_type="SPACE", catch=True)
    title("HTTP Requests")
    prompt("Retrieving blendernation's newsfeed ...")
    request_coro = aiohttp.request('get', 'http://feeds.feedburner.com/Blendernation')
    try:
        request = yield from wait_for(request_coro,  3)
    except asyncio.TimeoutError:
        prompt("Sorry, server couldn't be reached.")
        yield from sleep(3)
        return

    feed_title_text = bpy.data.objects['feed_title']
    feed_text = bpy.data.objects['feed_text']
    feed_title_text.hide = False
    feed_text.hide = False

    prompt("Reading Feed...")
    text = yield from wait_for(request.text(), 10)
    feed = feedparser.parse(text)
    feed_title_text.data.body = feed['feed']['title']
    feed_content = ""
    for entry in feed['entries'][:10]:
        feed_content += entry['title'] + "\n"
    feed_text.data.body = feed_content
    prompt("Press Space to continue...")
    yield from listener.wait()
    listener.remove()

    feed_title_text.hide = True
    feed_text.hide = True
Пример #2
0
def http_request_demo():
    listener = BlenderListener(event_type="SPACE", catch=True)
    title("HTTP Requests")
    prompt("Retrieving blendernation's newsfeed ...")
    request_coro = aiohttp.request(
        'get', 'http://feeds.feedburner.com/Blendernation')
    try:
        request = yield from wait_for(request_coro, 3)
    except asyncio.TimeoutError:
        prompt("Sorry, server couldn't be reached.")
        yield from sleep(3)
        return

    feed_title_text = bpy.data.objects['feed_title']
    feed_text = bpy.data.objects['feed_text']
    feed_title_text.hide = False
    feed_text.hide = False

    prompt("Reading Feed...")
    text = yield from wait_for(request.text(), 10)
    feed = feedparser.parse(text)
    feed_title_text.data.body = feed['feed']['title']
    feed_content = ""
    for entry in feed['entries'][:10]:
        feed_content += entry['title'] + "\n"
    feed_text.data.body = feed_content
    prompt("Press Space to continue...")
    yield from listener.wait()
    listener.remove()

    feed_title_text.hide = True
    feed_text.hide = True
Пример #3
0
def test_1():
    feed_title_text = bpy.data.objects['feed_title']
    feed_text = bpy.data.objects['feed_text']
    feed_title_text.hide = True
    feed_text.hide = True

    listener =  BlenderListener(event_type="SPACE", catch=True)
    title("AsyncIO Demonstration")
    prompt("Note: Blender stays responsive all the time!\nPress 'Space' to continue...")
    yield from listener.wait()
    bpy.ops.screen.animation_play()

    title("Basic Timeouts")
    prompt("Press 'Space' to continue...")
    for i in reversed(range(10)):
        prompt("Count down {0}...".format(i))
        yield from sleep(1)

    listener.remove()

    yield from http_request_demo()
    yield from http_server_demo()
Пример #4
0
def test_1():
    feed_title_text = bpy.data.objects['feed_title']
    feed_text = bpy.data.objects['feed_text']
    feed_title_text.hide = True
    feed_text.hide = True

    listener = BlenderListener(event_type="SPACE", catch=True)
    title("AsyncIO Demonstration")
    prompt(
        "Note: Blender stays responsive all the time!\nPress 'Space' to continue..."
    )
    yield from listener.wait()
    bpy.ops.screen.animation_play()

    title("Basic Timeouts")
    prompt("Press 'Space' to continue...")
    for i in reversed(range(10)):
        prompt("Count down {0}...".format(i))
        yield from sleep(1)

    listener.remove()

    yield from http_request_demo()
    yield from http_server_demo()