How to use the circuits.Event function in circuits

To help you get started, we’ve selected a few circuits examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github circuits / circuits / tests / core / test_coroutine.py View on Github external
#!/usr/bin/env python
from __future__ import print_function

import pytest

from circuits import Component, Event

pytestmark = pytest.mark.skip("XXX: This test fails intermittently")


class test(Event):

    """test Event"""


class coroutine1(Event):

    """coroutine Event"""

    complete = True


class coroutine2(Event):

    """coroutine Event"""

    complete = True


class App(Component):

    returned = False
github circuits / circuits / tests / core / test_call_stop.py View on Github external
#!/usr/bin/env python

from __future__ import print_function

import pytest

from circuits import Component, Event, handler


class test(Event):
    """test Event"""

    success = True


class foo(Event):
    """foo Event"""


class App(Component):

    @handler("test", priority=1)
    def on_test(self, event):
        event.stop()
        yield

    @handler("test")
    def on_test_ignored(self):
        return "Hello World!"


@pytest.fixture
github circuits / circuits / tmp / test_pools2.py View on Github external
#!/usr/bin/env python

import sys
from time import sleep

from circuits import future, Component, Event

class Test(Event):
    """Test Event"""

class App(Component):

    def __init__(self, N):
        super(App, self).__init__()

        self.N = N
        self.n = 0

    def __tick__(self):
        if self.n == self.N:
            raise SystemExit, 0
        print "."

    def started(self, component, mode):
github circuits / circuits / tests / core / test_event.py View on Github external
def test_subclass_looses_properties():
    class hello(Event):
        success = True
    e = hello().child('success')
    assert e.success is False
github circuits / circuits / examples / primitives / call.py View on Github external
#!/usr/bin/env python
from circuits import Component, Event


class hello(Event):

    """hello Event"""


class foo(Event):

    """foo Event"""


class bar(Event):

    """bar Event"""


class App(Component):
github realXtend / tundra / src / Application / PythonScriptModule / pymodules_old / circuits / app / env.py View on Github external
fd.close()

###
### Events
###

class Create(Event):
    """Create(Event) -> Create Event"""

class Load(Event):
    """Load(Event) -> Load Event"""

class Verify(Event):
    """Verify(Event) -> Verify Event"""

class Upgrade(Event):
    """Upgrade(Event) -> Upgrade Event"""

class Created(Event):
    """Created(Event) -> Created Event"""

class Loaded(Event):
    """Loaded(Event) -> Loaded Event"""

class Invalid(Event):
    """Invalid(Event) -> Invalid Event

    args: path, msg
    """

class NeedsUpgrade(Event):
    """NeedsUpgrade(Event) -> NeedsUpgrade Event
github clixx-io / clixx.io / source / tools / serialports-monitor / serialports-monitor.py View on Github external
def started(self, component):
        """started Event handler

        """

        self.serial_ports = self.read_serial_ports()

        # Timer(seconds, event, persist=False)
        Timer(self.timer_interval, Event.create("timer"), persist=True).register(self)
github circuits / circuits / docs / source / tutorials / woof / 006.py View on Github external
#!/usr/bin/env python

from circuits import Component, Event


class woof(Event):

    """woof Event"""


class Pound(Component):

    def __init__(self):
        super(Pound, self).__init__()

        self.bob = Bob().register(self)
        self.fred = Fred().register(self)

    def started(self, *args):
        self.fire(woof())
github circuits / circuits / circuits / lib / ann.py View on Github external
# Module:   ann
# Date:     18th March 2006
# Author:   James Mills 

"""Artificial Neural Networking Library

...
"""

import math
from time import sleep

from circuits import Event, Component

class Signal(Event): pass

class Node(Component):

   def __init__(self, *args, **kwargs):
      super(Node, self).__init__(*args, **kwargs)

      self.start()

   def __repr__(self):
      return "" % (id(self), self.running)

   def fire(self, level=1.0):
      self.push(Signal(level), "signal", self.channel)

class Synapse(Node):
github circuits / circuits / examples / primes.py View on Github external
help="Wait for a node HELO before start. (Default: False)")

	opts, args = parser.parse_args()

	return opts, args

###
### Events
###

class Start(Event): pass
class Stop(Event): pass
class Term(Event): pass
class Query(Event): pass
class Busy(Event): pass
class Ready(Event): pass
class Task(Event): pass
class Run(Event): pass
class Done(Event): pass
class Task(Event): pass
class Prime(Event): pass

###
### Components
###

class PrimeFinder(Component):

	id = uuid()

	term = False
	busy = False