Ejemplo n.º 1
0
def to_relative(id, scope=None):
    if '#' not in id:
        (a, p) = (id, '')
    else:
        (a, p) = id.split('#')

    a2 = a[1:-1]
    cp = a2.find(':')

    if cp < 0:
        u = piw.tsd_scope()
        n = a2
    else:
        u = a2[:cp]
        n = a2[cp + 1:]

    s = scope or piw.tsd_scope()

    if u == s:
        if p:
            return '<%s>#%s' % (n, p)
        else:
            return '<%s>' % n
    else:
        if p:
            return '<%s:%s>#%s' % (u, n, p)
        else:
            return '<%s:%s>' % (u, n)
Ejemplo n.º 2
0
 def initialise(self, frontend, scope):
     self.__frontend = frontend
     self.__scope = piw.tsd_scope(
     ) + '.' + scope if scope else piw.tsd_scope()
     self.index_name = '<%s:main>' % self.__scope
     self.agent_name = '<%s:workbench>' % self.__scope
     print >> sys.__stdout__, 'workspace scope=', self.__scope, 'agent=', self.agent_name, 'index=', self.index_name
     self.__database.addListener(self.__frontend)
     self.__database.start(self.index_name)
     self.__agent.start()
Ejemplo n.º 3
0
 def __create_context(self, name):
     if self.frontend:
         logger = self.frontend.make_logger(name)
         return self.scaffold.bgcontext(piw.tsd_scope(),
                                        utils.statusify(None), logger, name)
     else:
         return None
Ejemplo n.º 4
0
    def __init__(self, address, ordinal):
        agent.Agent.__init__(self,
                             signature=version,
                             names='rig',
                             ordinal=ordinal,
                             protocols='rigouter')

        self.file_name = 'rig%d' % ordinal
        self.inner_name = '%s.%s' % (piw.tsd_scope(), self.file_name)
        self.__inner_agent = InnerAgent(self)
        self.__domain = piw.clockdomain_ctl()

        self.set_property_string('rig', self.file_name)

        self[2] = OutputList(None)
        self[3] = InputList(None, True)
        self[3].set_output_peer(self.__inner_agent[2])
        self.__inner_agent[3].set_output_peer(self[2])
        self[4] = OuterGroupList()
        self.__inner_agent[4].set_outer_peer(self[4])

        self.add_verb2(
            1,
            'create([],None,role(None,[abstract,matches([input])]),option(called,[abstract]))',
            self.__create_input)
        self.add_verb2(
            2,
            'create([],None,role(None,[abstract,matches([output])]),option(called,[abstract]))',
            self.__create_output)
Ejemplo n.º 5
0
    def __init__(self, backend, ordinal):
        self.__backend = backend
        self.__registry = workspace.get_registry()

        self.__foreground = piw.tsd_snapshot()

        agent.Agent.__init__(self,
                             signature=upgrade_agentd,
                             names='eigend',
                             protocols='agentfactory setupmanager set',
                             container=3,
                             ordinal=ordinal,
                             vocab=self.__registry.get_vocab())

        self.ordinal = ordinal
        self.uid = '<eigend%d>' % ordinal

        self.__workspace = workspace.Workspace(piw.tsd_scope(), self.__backend,
                                               self.__registry)

        self[2] = self.__workspace

        constraint = 'or([%s])' % ','.join([
            '[matches([%s],%s)]' % (m.replace('_', ','), m)
            for m in self.__registry.modules()
        ])
        self.add_verb2(
            1,
            'create([un],None,role(None,[concrete,issubject(create,[role(by,[instance(~self)])])]))',
            callback=self.__uncreateverb)
        self.add_verb2(2,
                       'create([],None,role(None,[abstract,%s]))' % constraint,
                       callback=self.__createverb)
        self.add_verb2(3, 'save([],None,role(None,[abstract]))',
                       self.__saveverb)
        self.add_verb2(4, 'load([],None,role(None,[abstract]))',
                       self.__loadverb)
        self.add_verb2(
            5,
            'set([],None,role(None,[abstract,matches([startup])]),role(to,[abstract]))',
            self.__set_startup)
        self.add_verb2(
            6,
            'create([],None,role(None,[abstract,%s]),role(in,[proto(rigouter)]))'
            % constraint,
            callback=self.__rigcreateverb)
        self.add_verb2(
            7,
            'create([un],None,role(None,[concrete,issubjectextended(create,by,[role(by,[proto(rigouter)])])]))',
            callback=self.__riguncreateverb)

        piw.tsd_server(self.uid, self)
Ejemplo n.º 6
0
def splitid(id, scope=None):
    if '#' not in id:
        (a, p) = (id, '')
    else:
        (a, p) = id.split('#')

    a2 = a[1:-1]
    cp = a2.find(':')

    s = scope or piw.tsd_scope()

    if cp < 0:
        return (s, a2, p)

    u = a2[:cp]
    n = a2[cp + 1:]

    return (u, n, p)
Ejemplo n.º 7
0
def to_absolute(id, scope=None):
    if '#' not in id:
        (a, p) = (id, '')
    else:
        (a, p) = id.split('#')

    if len(a) < 3 or a[0] != '<' or a[-1] != '>':
        return id

    a2 = a[1:-1]

    if a2.find(':') >= 0:
        return id

    s = scope or piw.tsd_scope()

    if p:
        aq = '<%s:%s>#%s' % (s, a2, p)
    else:
        aq = '<%s:%s>' % (s, a2)

    return aq
Ejemplo n.º 8
0
 def stop_database(self):
     if self.__db_started:
         self.__db_started = False
         print 'stopping database'
         self.database.stop(piw.tsd_scope())
Ejemplo n.º 9
0
 def start_database(self):
     if not self.__db_started:
         self.__db_started = True
         print 'starting database'
         self.database.start(piw.tsd_scope())