Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Yet another finite state machine with memory and callbacks.

Project description

alt logo
https://codecov.io/github/ourway/marmoolak/coverage.svg?branch=master

install

pip install marmoolak

Usage

import marmoolak
marmoolak.REDIS_HOST = '192.168.99.100'
marmoolak.REDIS_PORT = 6379
machine = marmoolak.Machine

def onpanic(e):
    print('panic! ' + e.msg)
def oncalm(e):
    print('thanks to ' + e.msg + ' done by ' + e.args[0])
def ongreen(e):
    print('green')
def onyellow(e):
    print('yellow')
def onred(e):
    print('red')


fsm = machine('myname', 'version1' , {'initial': 'green',
             'events': [
                 {'name': 'warn', 'src': 'green', 'dst': 'yellow'},
                 {'name': 'panic', 'src': 'yellow', 'dst': 'red'},
                 {'name': 'panic', 'src': 'green', 'dst': 'red'},
                 {'name': 'calm', 'src': 'red', 'dst': 'yellow'},
                 {'name': 'clear', 'src': 'yellow', 'dst': 'green'}],
             'callbacks': {
                 'onpanic': onpanic,
                 'oncalm': oncalm,
                 'ongreen': ongreen,
                 'onyellow': onyellow,
                 'onred': onred }})



fsm.panic(msg='killer bees', url="http://appido.ir/appido/api/getBooks.json")
fsm.calm('bob', msg='sedatives in the honey pots')

credits

I used fysom and redis for achiving this functionality. So most of the credit goes to redis and fysom developers.

Contact me

Feel free to drop me a mail at rodmena@me.com

Project details


Release history Release notifications

This version
History Node

1.0.8

History Node

1.0.7

History Node

1.0.6

History Node

1.0.5

History Node

1.0.4

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
marmoolak-1.0.8-py2-none-any.whl (4.7 kB) Copy SHA256 hash SHA256 Wheel 2.7 Oct 25, 2015
marmoolak-1.0.8-py3-none-any.whl (4.7 kB) Copy SHA256 hash SHA256 Wheel 3.5 Oct 25, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page