コード例 #1
0
ファイル: chatroom.py プロジェクト: benlewis-tes/flexx
 def _update_participants(self):
     proxies = app.manager.get_connections(self.__class__.__name__)
     names = [p.app.name.text() for p in proxies]
     text = '<br />%i persons in this chat:<br /><br />' % len(names)
     text += '<br />'.join([name or 'anonymous' for name in sorted(names)])
     self.people.text(text)
     app.call_later(3, self._update_participants)
コード例 #2
0
ファイル: test_live.py プロジェクト: silky/flexx
def runner(cls):

    # Run with a fresh server
    server = app.create_server(port=0, new_loop=True)

    t = app.launch(cls, 'firefox-app')
    t.test_init()
    t.test_set_result()
    # Install failsafe. Use a closure so failsafe wont spoil a future test
    isrunning = True

    def stop():
        if isrunning:
            app.stop()

    app.call_later(TIMEOUT1, stop)
    # Enter main loop until we get out
    t0 = time.time()
    app.start()
    print('ran %f seconds' % (time.time() - t0))
    isrunning = False
    # Check result
    if True:  # not (ON_TRAVIS and ON_PYPY):  # has intermittent fails on pypy3
        t.test_check()
    # Shut down
    t.session.close()
コード例 #3
0
def runner(cls):
    t = app.launch(cls, 'firefox')
    t.test_init()
    app.call_later(5, app.stop)
    app.run()
    if not (ON_TRAVIS and ON_PYPY):  # has intermittent fails on pypy3
        t.test_check()
コード例 #4
0
 def tick(self):
     t = time.time()
     for i, circle in enumerate(self._circles):
         x = math.sin(i*0.2 + t)*0.3 + 0.5
         y = math.cos(i*0.2 + t)*0.3 + 0.5
         circle.pos((x, y))
     app.call_later(0.03, self.tick)
コード例 #5
0
ファイル: chatroom.py プロジェクト: paladin74/flexx
 def _update_participants(self):
     proxies = app.manager.get_connections(self.__class__.__name__)
     names = [p.app.name.text() for p in proxies]
     text = '<br />%i persons in this chat:<br /><br />' % len(names)
     text += '<br />'.join([name or 'anonymous' for name in sorted(names)])
     self.people.text(text)
     app.call_later(3, self._update_participants)
コード例 #6
0
def runner(cls):
    t = app.launch(cls, 'firefox')  # fails somehow with XUL
    t.test_init()
    app.call_later(TIMEOUT1, app.stop)
    app.run()
    if not (ON_TRAVIS and ON_PYPY):  # has intermittent fails on pypy3
        t.test_check()
    t.session.close()
コード例 #7
0
ファイル: colab_painting.py プロジェクト: Konubinix/flexx
 def _update_participants(self):
     """ Keep track of the number of participants. """
     if not self.session.status:
         return  # and dont't invoke a new call
     proxies = app.manager.get_connections(self.__class__.__name__)
     n = len(proxies)
     del proxies
     self.people.text = '%i persons are painting' % n
     app.call_later(3, self._update_participants)
コード例 #8
0
ファイル: colab_painting.py プロジェクト: simonclouds/flexx
 def _update_participants(self):
     if not self.session.status:
         relay.disconnect('new_dot:' + self.id)
         return  # and dont't invoke a new call
     proxies = app.manager.get_connections(self.__class__.__name__)
     n = len(proxies)
     del proxies
     self.people.text = '%i persons are painting' % n
     app.call_later(3, self._update_participants)
コード例 #9
0
ファイル: colab_painting.py プロジェクト: silky/flexx
 def _update_participants(self):
     """ Keep track of the number of participants. """
     if not self.session.status:
         return  # and dont't invoke a new call
     proxies = app.manager.get_connections(self.__class__.__name__)
     n = len(proxies)
     del proxies
     self.people.text = '%i persons are painting' % n
     app.call_later(3, self._update_participants)
コード例 #10
0
ファイル: colab_painting.py プロジェクト: ajithpad/flexx
 def _update_participants(self):
     if not self.session.status:
         relay.disconnect('new_dot:' + self.id)
         return  # and dont't invoke a new call
     proxies = app.manager.get_connections(self.__class__.__name__)
     n = len(proxies)
     del proxies
     self.people.text = '%i persons are painting' % n
     app.call_later(3, self._update_participants)
コード例 #11
0
 def tick(self):
     if not self.session.status:
         return
     import time
     t = time.time()
     for i, circle in enumerate(self._circles):
         x = math.sin(i * 0.2 + t) * 0.3 + 0.5
         y = math.cos(i * 0.2 + t) * 0.3 + 0.5
         circle.pos = x, y
     app.call_later(0.03, self.tick)
コード例 #12
0
ファイル: chatroom.py プロジェクト: Konubinix/flexx
 def _update_participants(self):
     if not self.session.status:
         return  # and dont't invoke a new call
     sessions = app.manager.get_connections(self.session.app_name)
     names = [p._chatroom_name for p in sessions]  # _chatroom_name is what we set
     del sessions
     text = '<br />%i persons in this chat:<br /><br />' % len(names)
     text += '<br />'.join([name or 'anonymous' for name in sorted(names)])
     self.people.text = text
     app.call_later(3, self._update_participants)
コード例 #13
0
 def _update_participants(self):
     if not self.session.status:
         return  # and dont't invoke a new call
     proxies = app.manager.get_connections(self.__class__.__name__)
     names = [p.app.name.text for p in proxies]
     del proxies
     text = '<br />%i persons in this chat:<br /><br />' % len(names)
     text += '<br />'.join([name or 'anonymous' for name in sorted(names)])
     self.people.text = text
     app.call_later(3, self._update_participants)
コード例 #14
0
ファイル: chatroom.py プロジェクト: ajithpad/flexx
 def _update_participants(self):
     if not self.session.status:
         relay.disconnect('new_message:' + self.id)
         return  # and dont't invoke a new call
     proxies = app.manager.get_connections(self.__class__.__name__)
     names = [p.app.name.text for p in proxies]
     del proxies
     text = '<br />%i persons in this chat:<br /><br />' % len(names)
     text += '<br />'.join([name or 'anonymous' for name in sorted(names)])
     self.people.text = text
     app.call_later(3, self._update_participants)
コード例 #15
0
 def _update_participants(self):
     if not self.session.status:
         return  # and dont't invoke a new call
     sessions = app.manager.get_connections(self.session.app_name)
     names = [p._chatroom_name
              for p in sessions]  # _chatroom_name is what we set
     del sessions
     text = '<br />%i persons in this chat:<br /><br />' % len(names)
     text += '<br />'.join([name or 'anonymous' for name in sorted(names)])
     self.people.text = text
     app.call_later(3, self._update_participants)
コード例 #16
0
ファイル: test_funcs.py プロジェクト: Konubinix/flexx
 def main():
     # Create fresh ioloop and make flexx use it
     loop = IOLoop()
     loop.make_current()
     app.create_server()
     # Create model and manipulate prop
     model = MyModel1()
     model.foo = 3
     model.foo = 4
     # Run mainloop for one iterartion
     app.call_later(0, app.stop)
     app.start()
コード例 #17
0
ファイル: test_funcs.py プロジェクト: xyzonline/flexx
 def main():
     # Create fresh ioloop and make flexx use it
     loop = IOLoop()
     loop.make_current()
     app.create_server()
     # Create model and manipulate prop
     model = MyModel1()
     model.foo = 3
     model.foo = 4
     # Run mainloop for one iterartion
     app.call_later(0, app.stop)
     app.start()
コード例 #18
0
ファイル: test_funcs.py プロジェクト: Konubinix/flexx
def test_more_stopping():
    """ Test calling stop multiple times.
    """
    
    # This is why you want to create new IOLoop instances for each test
    
    # Create new ioloop and make Flexx use it
    loop = IOLoop()
    loop.make_current()
    server = app.create_server()
    
    app.stop()  # triggers event to stop
    app.start()
    
    app.stop()  # Extra stop - pending stop event
    
    # Which means the next stop does hardly block
    t0 = time.time()
    app.call_later(0.2, app.stop)
    app.start()
    assert time.time() - t0 < 0.1
    
    
    loop = IOLoop()
    loop.make_current()
    server = app.create_server()
    
    # But stops dont stack
    app.stop()
    app.stop()
    app.stop()
    app.stop()
    
    # Flush all stops ...
    app.stop()
    app.start()
    
    # ... so that we now have an expected loop
    t0 = time.time()
    app.call_later(0.2, app.stop)
    app.start()
    assert time.time() - t0 >= 0.1
コード例 #19
0
ファイル: test_funcs.py プロジェクト: xyzonline/flexx
def test_more_stopping():
    """ Test calling stop multiple times.
    """

    # This is why you want to create new IOLoop instances for each test

    # Create new ioloop and make Flexx use it
    loop = IOLoop()
    loop.make_current()
    server = app.create_server()

    app.stop()  # triggers event to stop
    app.start()

    app.stop()  # Extra stop - pending stop event

    # Which means the next stop does hardly block
    t0 = time.time()
    app.call_later(0.2, app.stop)
    app.start()
    assert time.time() - t0 < 0.1

    loop = IOLoop()
    loop.make_current()
    server = app.create_server()

    # But stops dont stack
    app.stop()
    app.stop()
    app.stop()
    app.stop()

    # Flush all stops ...
    app.stop()
    app.start()

    # ... so that we now have an expected loop
    t0 = time.time()
    app.call_later(0.2, app.stop)
    app.start()
    assert time.time() - t0 >= 0.1
コード例 #20
0
ファイル: test_live.py プロジェクト: Konubinix/flexx
def runner(cls):
    
    # Run with a fresh server
    server = app.create_server(port=0, new_loop=True)
    
    t = app.launch(cls, 'firefox-app')
    t.test_init()
    t.test_set_result()
    # Install failsafe. Use a closure so failsafe wont spoil a future test
    isrunning = True
    def stop():
        if isrunning:
            app.stop()
    app.call_later(TIMEOUT1, stop)
    # Enter main loop until we get out
    t0 = time.time()
    app.start()
    print('ran %f seconds' % (time.time()-t0))
    isrunning = False
    # Check result
    if True:  # not (ON_TRAVIS and ON_PYPY):  # has intermittent fails on pypy3
        t.test_check()
    # Shut down
    t.session.close()
コード例 #21
0
 def result(self, v=None):
     if v:
         #app.stop()
         print('stopping by ourselves', v)
         app.call_later(TIMEOUT2, app.stop)
     return v
コード例 #22
0
 def test_init(self):
     app.call_later(0.2, self._emit_foo)
     app.call_later(0.3, lambda:self.call_js('set_result()'))
コード例 #23
0
ファイル: test_funcs.py プロジェクト: Konubinix/flexx
def multiprocessing_func():
    import flexx
    app.create_server(port=0)  # Explicitly ask for unused port
    app.call_later(0.1, app.stop)
    app.start()
コード例 #24
0
ファイル: cpu_monitor.py プロジェクト: npk/flexx
def refresh():
    global_cpu_usage._set(psutil.cpu_percent())
    app.call_later(1, refresh)
コード例 #25
0
ファイル: cpu_monitor.py プロジェクト: sanen/flexx
def refresh():
    global_cpu_usage._set(psutil.cpu_percent())
    global_mem_usage._set(psutil.virtual_memory().percent)
    app.call_later(1, refresh)
コード例 #26
0
ファイル: test_live.py プロジェクト: silky/flexx
 def result(self, v=None):
     if not this_is_js():
         if v:
             print('stopping by ourselves', v)
             app.call_later(TIMEOUT2, app.stop)
     return v
コード例 #27
0
ファイル: test_funcs.py プロジェクト: xyzonline/flexx
def multiprocessing_func():
    import flexx
    app.create_server(port=0)  # Explicitly ask for unused port
    app.call_later(0.1, app.stop)
    app.start()
コード例 #28
0
ファイル: test_live.py プロジェクト: Konubinix/flexx
 def result(self, v=None):
     if not this_is_js():
         if v:
             print('stopping by ourselves', v)
             app.call_later(TIMEOUT2, app.stop)
     return v
コード例 #29
0
def refresh():
    global_cpu_usage._set(psutil.cpu_percent())
    app.call_later(1, refresh)
コード例 #30
0
ファイル: test_funcs.py プロジェクト: Konubinix/flexx
def test_restarting():
    """ Test stopping and starting the ioloop.
    """
    res = []
    def add_res(i):
        res.append(i)
    
    def try_start():
        try:
            app.start()
        except RuntimeError:
            res.append('RTE')
        
    # Create new ioloop always
    loop = IOLoop()
    loop.make_current()
    # Make Flexx use it
    server = app.create_server()
    
    app.call_later(0, add_res, 1)
    app.call_later(0, add_res, 2)
    app.call_later(0, app.stop)  # actually, just calling stop() would work as well
    app.start()
    assert server._running == False
    
    app.call_later(0, try_start)  # test that cannot start twice
    app.call_later(0, add_res, 3)
    app.call_later(0, add_res, 4)
    app.call_later(0, app.stop)
    app.start()
    assert server._running == False
    
    app.call_later(0, try_start)  # test that cannot start twice
    app.call_later(0, add_res, 5)
    app.call_later(0, add_res, 6)
    app.call_later(0, app.stop)
    app.start()
    assert server._running == False
    
    assert res == [1, 2, 'RTE', 3, 4, 'RTE', 5, 6]
コード例 #31
0
ファイル: test_funcs.py プロジェクト: xyzonline/flexx
def test_restarting():
    """ Test stopping and starting the ioloop.
    """
    res = []

    def add_res(i):
        res.append(i)

    def try_start():
        try:
            app.start()
        except RuntimeError:
            res.append('RTE')

    # Create new ioloop always
    loop = IOLoop()
    loop.make_current()
    # Make Flexx use it
    server = app.create_server()

    app.call_later(0, add_res, 1)
    app.call_later(0, add_res, 2)
    app.call_later(
        0, app.stop)  # actually, just calling stop() would work as well
    app.start()
    assert server._running == False

    app.call_later(0, try_start)  # test that cannot start twice
    app.call_later(0, add_res, 3)
    app.call_later(0, add_res, 4)
    app.call_later(0, app.stop)
    app.start()
    assert server._running == False

    app.call_later(0, try_start)  # test that cannot start twice
    app.call_later(0, add_res, 5)
    app.call_later(0, add_res, 6)
    app.call_later(0, app.stop)
    app.start()
    assert server._running == False

    assert res == [1, 2, 'RTE', 3, 4, 'RTE', 5, 6]
コード例 #32
0
 def refresh(self):
     self.system_info()
     app.call_later(1, self.refresh)