示例#1
0
    def rpc_createagent(self, plugin):
        plugin = '_'.join(plugin.split())
        factory = self.__registry.get_module(plugin)

        if not factory:
            return logic.render_term(
                action.error_return('no such agent', 'create', ENG))

        class DummyDelegate():
            def __init__(self):
                self.errors = []

            def add_error(self, msg):
                self.errors.append(msg)

        delegate = DummyDelegate()
        address = self.__workspace.create(factory, delegate)

        if not address:
            return logic.render_term([
                action.error_return(m, plugin, 'create', ENG)
                for m in delegate.errors
            ])

        return logic.render_term(
            action.concrete_return(paths.to_absolute(address, self.__name)))
示例#2
0
    def rpc_delinstance(self, arg):
        iid = paths.to_relative(paths.to_absolute(arg, scope=self.scope()))
        pid = None
        for v in self.values():
            if iid == v.id():
                pid = v.input().id()
                break

        if pid:
            r = self.__peer.rpc_delinstance(pid)
            yield r
            yield async .Coroutine.completion(r.status(), *r.args(),
                                              **r.kwds())
        else:
            yield async .Coroutine.failure('output not in use')
示例#3
0
    def property_change(self, key, value, delegate):
        if key != 'slave':
            return

        cur_slaves = set(self.get_property_termlist('slave'))
        old_slaves = set(self.__monitors.keys())

        dead_slaves = old_slaves.difference(cur_slaves)
        new_slaves = cur_slaves.difference(old_slaves)

        for s in dead_slaves:
            m = self.__monitors[s]
            del self.__monitors[s]
            m.disconnect()

        for s in new_slaves:
            id = paths.to_absolute(s, self.__scope)
            m = RigMonitor(self.__master, id)
            self.__monitors[s] = m
示例#4
0
    def make_filter(self, stream, slot):
        if logic.is_pred_arity(stream, 'conn', 5, 5):
            if stream.args[0] is not None:
                using = int(stream.args[0])
            else:
                using = 0

            if stream.args[1] is not None:
                tgt = int(stream.args[1])
            else:
                tgt = 0

            id = paths.to_absolute(stream.args[2], self.__scope)
            path = stream.args[3]

            ctl = True if stream.args[4] == 'ctl' else False

            if path is not None:
                return (id, piw.signal_dsc_filter(using, tgt, path), ctl)
            else:
                return (id, piw.signal_cnc_filter(using, tgt), ctl)

        return ('', piw.null_filter(), False)
示例#5
0
 def server_opened(self):
     agent.Agent.server_opened(self)
     piw.tsd_server(paths.to_absolute('<eigend1>', self.inner_name),
                    self.__inner_agent)
     self.__inner_agent.set_owner("'%s'" % paths.to_absolute(self.id()))
示例#6
0
 def rpc_delinstance(self, arg):
     iid = paths.to_relative(paths.to_absolute(arg, scope=self.scope()))
     r = collection.Collection.rpc_delinstance(self, iid)
     yield r
     yield async .Coroutine.completion(r.status(), *r.args(), **r.kwds())