Exemple #1
0
''' ut: universal tweener with asynch locks for python ~ gbdu'''

try:
    from helpers.getmylogger import silent_logger,loud_logger
    from multiprocessing import Lock
    import exceptions
except Exception as e:
    print "Could not load ut dependencies: "
    print e
    exit(1)
    
logger = loud_logger("gui_helpers")
    
llog = silent_logger("tweener")
DEFAULT_TWEEN_TO = 0
DEFAULT_TWEEN_MIN = 0
DEFAULT_TWEEN_VALUE = 0

class Ut:
    '''universal tweener for python -- with locks'''
    _itl = []

    def find_tweener(self, name):
        '''returns an internal dict if a tweener exists in internal list'''
        if len(self._itl) == 0:
            llog.warning("list not initd eyet and youre trying to find %s ", name)
            return False
        
        for i in self._itl :
            if i['name'] == name:
                llog.info("returning %s as found ", name)
Exemple #2
0
    import os,sys
except ImportError as e:
    print "Could not import from sid ... "
    exit(1)

try:
    from component import component
    from helpers import getmylogger

except ImportError as e:    
    print "could not import internal from sid"
    print e
    exit(1)
last_component_number = 0

log = getmylogger.loud_logger("sid")
qlog = getmylogger.silent_logger("sid_silent")

class Sid:
    '''create 256 components, then hang and print a message every 1 sec as
    the components run'''
    
    # locks, myname
    mystate = Value("d", 0) # 0 for dead, 1 for alive, set by creator
    components = [] # alist of tuples of form  (c, s, a, b, h, l)
    processes = []

    def add_component(self, component_hints):
        '''add a tuple of the form (component, state, parent_pipe, child_pipe,
        hints) and append it to list components
        
Exemple #3
0
def random_line(afile):
    line = next(afile)
    for num, aline in enumerate(afile):
        if random.randrange(num + 2):
            continue
        line = aline
    return line


def get_molecule_list():
    # todo: return real stuff from file

    return ["dopamine", "bacon", "tomato"]


log = loud_logger("neuron_stim")

# -class*
# -communicate with neighbours (?)

#       -in/out pipe


class Neuron:
    def __init__(self, n, parent_layer):
        """
        n is a dict of moleculename:molecule_concentration,molecule_lock
        parent_layer is a list of "friend" neurons (could include self!)
        """
        self.mymolecules = n
        self.myfriends = parent_layer