예제 #1
0
 def test_new(self):
     ret = {'id': "ABC", 'password': '******', 'url': 'https://example.org'}
     with mock.patch('inthing.jsonrpc.JSONRPC.call', mock.Mock(return_value=ret)):
         stream = Stream.new()
     self.assertEqual(stream.id, ret['id'])
     self.assertEqual(stream.password, ret['password'])
     self.assertEqual(stream.url, ret['url'])
예제 #2
0
파일: demo.py 프로젝트: willmcgugan/inthing
"""An example of posting a text event to a stream."""

from inthing import Stream


def mandel(xsize=80, ysize=20, max_iteration=50):
    """Render an ascii mandelbrot set!"""
    chars = " .,~:;+*%@##"
    rows = []
    for pixy in xrange(ysize):
        y0 = (float(pixy) / ysize) * 2 - 1
        row = ""
        for pixx in xrange(xsize):
            x0 = (float(pixx) / xsize) * 3 - 2
            x = 0
            y = 0
            iteration = 0
            while (x * x + y * y < 4) and iteration < max_iteration:
                xtemp = x * x - y * y + x0
                y = 2 * x * y + y0
                x = xtemp
                iteration += 1
            row += chars[iteration % 10]
        rows.append(row)
    return "```\n{}\n```\n#mandlebrot".format('\n'.join(rows))


stream = Stream.new()
result = stream.text(mandel(), title="Mandelbrot Set!")
result.browse()
예제 #3
0
from inthing import Stream
s = Stream.new()
with Stream.new().capture('example') as capture:
    print('hello')
capture.browse()