Esempio n. 1
0
 def doneGetContext(self, token, error, ctxs):
     if error:
         protocol.log("Error from StackTrace.getContext", error)
         return
     if ctxs:
         for ctx in ctxs:
             print ctx
Esempio n. 2
0
 def doneGet(self, token, error, mmap):
     if error:
         protocol.log("Error from PathMap.get", error)
     else:
         print(mmap)
     with lock:
         lock.notify()
Esempio n. 3
0
 def doneGet(self, token, error, mmap):
     if error:
         protocol.log("Error from PathMap.get", error)
     else:
         print mmap
     with lock:
         lock.notify()
Esempio n. 4
0
 def doneGetChildren(self, token, error, context_ids):
     if error:
         protocol.log("Error from Processes.GetChildren", error)
     else:
         print("Processes: " + str(context_ids))
     with lock:
         lock.notify()
Esempio n. 5
0
 def __init__(self, service, name, data):
     self.service = service
     self.name = name
     try:
         self.args = channel.fromJSONSequence(data)
     except Exception as x:
         protocol.log("Error decoding event data", x)
Esempio n. 6
0
 def _log(self, msg, x):
     if not self._alive: return
     # Don't report same error multiple times to avoid filling up the log file.
     with self._error_log_lock:
         if msg in self.error_log: return
         self.error_log.add(msg)
     protocol.log(msg, x)
Esempio n. 7
0
 def doneCommand(self, token, error):
     if error:
         protocol.log("Error from RunControl.resume", error)
     else:
         context.suspend(runcontrol.DoneCommand())
     with lock:
         lock.notify()
Esempio n. 8
0
 def doneGetContext(self, token, error, ctx):
     pending.remove(token)
     if error:
         protocol.log("Error from Registers.getContext", error)
     else:
         print ctx
         if ctx.isReadable() and not ctx.isReadOnce() and ctx.getSize() >= 2:
             locs = []
             locs.append(registers.Location(ctx.getID(), 0, 1))
             locs.append(registers.Location(ctx.getID(), 1, 1))
             class DoneGetM(registers.DoneGet):
                 def doneGet(self, token, error, value):
                     pending.remove(token)
                     if error:
                         protocol.log("Error from Registers.getm", error)
                     else:
                         print "getm", ctx.getID(), map(ord, value)
                     if not pending:
                         onDone()
             pending.append(regs.getm(locs, DoneGetM()))
         if ctx.isWriteable() and not ctx.isWriteOnce() and ctx.getSize() >= 2:
             locs = []
             locs.append(registers.Location(ctx.getID(), 0, 1))
             locs.append(registers.Location(ctx.getID(), 1, 1))
             class DoneSetM(registers.DoneSet):
                 def doneGet(self, token, error):
                     pending.remove(token)
                     if error:
                         protocol.log("Error from Registers.setm", error)
                     if not pending:
                         onDone()
             pending.append(regs.setm(locs, (255, 255), DoneSetM()))
     if not pending:
         onDone()
Esempio n. 9
0
            def doneGetContext(self, token, error, context):
                pending.remove(token)
                if error:
                    protocol.log("Error from RunControl.getContext", error)
                else:
                    print(context)

                class DoneGetState(runcontrol.DoneGetState):
                    def doneGetState(self, token, error, suspended, pc, reason,
                                     params):
                        pending.remove(token)
                        if error:
                            protocol.log("Error from RunControl.getState",
                                         error)
                        else:
                            print("suspended: " + str(suspended))
                            print("pc:        " + str(pc))
                            print("reason:    " + str(reason))
                            print("params:    " + str(params))
                        if suspended:
                            _suspended.append(context.getID())
                        if len(pending) == 0:
                            with lock:
                                lock.notify()

                if context and context.hasState():
                    pending.append(context.getState(DoneGetState()))
                if len(pending) == 0:
                    with lock:
                        lock.notify()
Esempio n. 10
0
 def doneGetChildren(self, token, error, context_ids):
     if error:
         protocol.log("Error from Processes.GetChildren", error)
     else:
         print "Processes:", context_ids
     with lock:
         lock.notify()
Esempio n. 11
0
            def doneGetContext(self, token, error, context):
                pending.remove(token)
                if error:
                    protocol.log("Error from RunControl.getContext", error)
                else:
                    print context

                class DoneGetState(runcontrol.DoneGetState):

                    def doneGetState(self, token, error, suspended, pc, reason,
                                     params):
                        pending.remove(token)
                        if error:
                            protocol.log(
                                "Error from RunControl.getState", error)
                        else:
                            print "suspended: ", suspended
                            print "pc:        ", pc
                            print "reason:    ", reason
                            print "params:    ", params
                        if suspended:
                            _suspended.append(context.getID())
                        if len(pending) == 0:
                            with lock:
                                lock.notify()
                if context and context.hasState():
                    pending.append(context.getState(DoneGetState()))
                if len(pending) == 0:
                    with lock:
                        lock.notify()
Esempio n. 12
0
 def doneCommand(self, token, error):
     if error:
         protocol.log("Error from RunControl.resume", error)
     else:
         context.suspend(runcontrol.DoneCommand())
     with lock:
         lock.notify()
Esempio n. 13
0
 def doneGet(self, token, error, value):
     pending.remove(token)
     if error:
         protocol.log("Error from Registers.getm", error)
     else:
         print "getm", ctx.getID(), map(ord, value)
     if not pending:
         onDone()
Esempio n. 14
0
 def doneGet(self, token, error):
     pending.remove(token)
     if error:
         protocol.log(
             "Error from Registers.setm",
             error)
     if not pending:
         onDone()
Esempio n. 15
0
 def doneGet(self, token, error):
     pending.remove(token)
     if error:
         protocol.log(
             "Error from Registers.setm",
             error)
     if not pending:
         onDone()
Esempio n. 16
0
 def doneGetContext(self, token, error, ctxs):
     if error:
         protocol.log("Error from StackTrace.getContext",
                      error)
         return
     if ctxs:
         for ctx in ctxs:
             print(ctx)
Esempio n. 17
0
 def __traceMessageReceived(self, m):
     for l in self.trace_listeners:
         try:
             id = None
             if m.token is not None:
                 id = m.token.getID()
             l.onMessageReceived(m.type, id, m.service, m.name, m.data)
         except Exception as x:
             protocol.log("Exception in channel listener", x)
Esempio n. 18
0
 def doneGetContext(self, token, error, context):
     pending.remove(token)
     if error:
         protocol.log("Error from SysMonitor.getContext", error)
     else:
         processes.append(context)
     if not pending:
         with lock:
             lock.notify()
Esempio n. 19
0
 def doneGetContext(self, token, error, context):
     pending.remove(token)
     if error:
         protocol.log("Error from Memory.getContext", error)
     else:
         print context
     if len(pending) == 0:
         with lock:
             lock.notify()
Esempio n. 20
0
 def doneGetContext(self, token, error, context):
     pending.remove(token)
     if error:
         protocol.log("Error from Memory.getContext", error)
     else:
         print(context)
     if len(pending) == 0:
         with lock:
             lock.notify()
Esempio n. 21
0
            def doneCommand(self, token, error):
                """Called when run control command execution is complete.

                :param token: pending command handle.
                :param error: command execution error or **None**.
                """
                if error:
                    protocol.log("Error from RunContext.resume", error)
                with condition:
                    condition.notify()
Esempio n. 22
0
            def doneCommand(self, token, error):
                """Called when run control command execution is complete.

                :param token: pending command handle.
                :param error: command execution error or **None**.
                """
                if error:
                    protocol.log("Error from RunContext.resume", error)
                with condition:
                    condition.notify()
Esempio n. 23
0
 def doneGetChildren(self, token, error, context_ids):
     pending.remove(token)
     if error:
         protocol.log("Error from RunControl.GetChildren", error)
     else:
         for c in context_ids:
             contexts.append(c)
             pending.append(rc.getChildren(c, self))
     if len(pending) == 0:
         cache.set(None, None, contexts)
Esempio n. 24
0
 def doneGetContext(self, token, error, context):
     pending.remove(token)
     if error:
         protocol.log(
             "Error from SysMonitor.getContext", error)
     else:
         processes.append(context)
     if not pending:
         with lock:
             lock.notify()
Esempio n. 25
0
            def doneSubscribe(self, token, error):
                """Called when stream subscription is done.

                :param token: pending command handle
                :param error: error description if operation failed, **None**
                              if succeeded.
                """
                if error:
                    protocol.log("Error from streams.subscribe()", error)
                with condition:
                    condition.notify()
Esempio n. 26
0
def trace(msg):
    """
    Trace hooks should use this method to log a message. It prepends the
    message with a timestamp and sends it to the TCF logger facility. The
    logger implementation may or may not inject its own timestamp. For
    tracing, we definitely need one, so we introduce a minimal, relative-time
    stamp.

    @param msg  the trace message
    """
    protocol.log('%s %s' % (getDebugTime(), msg))
Esempio n. 27
0
File: peer.py Progetto: eswartz/emul
 def sendPeerRemovedEvent(self):
     for l in protocol.getLocator().getListeners():
         try:
             l.peerRemoved(self.rw_attrs.get(ATTR_ID))
         except Exception as x:
             protocol.log("Unhandled exception in Locator listener", x)
     try:
         args = [self.rw_attrs.get(ATTR_ID)]
         protocol.sendEvent(locator.NAME, "peerRemoved", json.dumps(args))
     except IOError as x:
         protocol.log("Locator: failed to send 'peerRemoved' event", x)
Esempio n. 28
0
 def doneGetChildren(self, token, error, context_ids):
     pending.remove(token)
     if error:
         protocol.log("Error from RunControl.GetChildren", error)
     else:
         for c in context_ids:
             pending.append(rctrl.getContext(c, DoneGetContext()))
             pending.append(rctrl.getChildren(c, self))
     if len(pending) == 0:
         with lock:
             lock.notify()
Esempio n. 29
0
 def doneGetChildren(self, token, error, context_ids):
     pending.remove(token)
     if error:
         protocol.log("Error from RunControl.GetChildren", error)
     else:
         for c in context_ids:
             pending.append(rctrl.getContext(c, DoneGetContext()))
             pending.append(rctrl.getChildren(c, self))
     if len(pending) == 0:
         with lock:
             lock.notify()
Esempio n. 30
0
            def doneSubscribe(self, token, error):
                """Called when stream subscription is done.

                :param token: pending command handle
                :param error: error description if operation failed, **None**
                              if succeeded.
                """
                if error:
                    protocol.log("Error from streams.subscribe()", error)
                with condition:
                    condition.notify()
Esempio n. 31
0
 def doneGetChildren(self, token, error, context_ids):
     pending.remove(token)
     if error:
         protocol.log("Error from RunControl.GetChildren",
                      error)
     else:
         for c in context_ids:
             contexts.append(c)
             pending.append(rc.getChildren(c, self))
     if len(pending) == 0:
         cache.set(None, None, contexts)
Esempio n. 32
0
File: peer.py Progetto: eswartz/emul
 def sendPeerAddedEvent(self):
     for l in protocol.getLocator().getListeners():
         try:
             l.peerAdded(self)
         except Exception as x:
             protocol.log("Unhandled exception in Locator listener", x)
     try:
         args = [self.rw_attrs]
         protocol.sendEvent(locator.NAME, "peerAdded", json.dumps(args))
     except IOError as x:
         protocol.log("Locator: failed to send 'peerAdded' event", x)
     self.last_heart_beat_time = int(time.time() * 1000)
Esempio n. 33
0
 def doneGet(self, token, error, value):
     pending.remove(token)
     if error:
         protocol.log(
             "Error from Registers.getm",
             error)
     else:
         print("getm " + str(ctx.getID()) +
               " " +
               str(list(map(int, value))))
     if not pending:
         onDone()
Esempio n. 34
0
 def doneGet(self, token, error, value):
     pending.remove(token)
     if error:
         protocol.log(
             "Error from Registers.getm",
             error)
     else:
         print("getm " + str(ctx.getID()) +
               " " +
               str(list(map(int, value))))
     if not pending:
         onDone()
Esempio n. 35
0
    def _close(self, error):
        assert self.state != STATE_CLOSED
        self.state = STATE_CLOSED
        # Closing channel underlying streams can block for a long time,
        # so it needs to be done by a background thread.
        thread = threading.Thread(target=self.stop, name="TCF Channel Cleanup")
        thread.daemon = True
        thread.start()
        if error and isinstance(self.remote_peer, peer.AbstractPeer):
            self.remote_peer.onChannelTerminated()
        if self.registered_with_trasport:
            self.registered_with_trasport = False
            transport.channelClosed(self, error)
        if self.proxy:
            try:
                self.proxy.onChannelClosed(error)
            except Exception as x:
                protocol.log("Exception in channel listener", x)
        channel = self
        class Runnable(object):
            def __call__(self):
                if channel.out_tokens:
                    x = None
                    if isinstance(error, Exception): x = error
                    elif error: x = Exception(error)
                    else: x = IOError("Channel is closed")
                    for msg in channel.out_tokens.values():
                        try:
                            s = str(msg)
                            if len(s) > 72: s = s[:72] + "...]"
                            y = IOError("Command " + s + " aborted")
#                            y.initCause(x)
                            msg.token.getListener().terminated(msg.token, y)
                        except Exception as e:
                            protocol.log("Exception in command listener", e)
                    channel.out_tokens.clear()
                if channel.channel_listeners:
                    for l in channel.channel_listeners:
                        if not l: break
                        try:
                            l.onChannelClosed(error)
                        except Exception as x:
                            protocol.log("Exception in channel listener", x)
                elif error:
                    protocol.log("TCF channel terminated", error)
                if channel.trace_listeners:
                    for l in channel.trace_listeners:
                        try:
                            l.onChannelClosed(error)
                        except Exception as x:
                            protocol.log("Exception in channel listener", x)
        protocol.invokeLater(Runnable())
Esempio n. 36
0
                    def doneGetContext(self, token, error, ctx):
                        pending.remove(token)
                        if error:
                            protocol.log("Error from Registers.getContext",
                                         error)
                        else:
                            print(ctx)
                            if ctx.isReadable() and not ctx.isReadOnce() \
                                    and ctx.getSize() >= 2:
                                locs = []
                                locs.append(
                                    registers.Location(ctx.getID(), 0, 1))
                                locs.append(
                                    registers.Location(ctx.getID(), 1, 1))

                                class DoneGetM(registers.DoneGet):
                                    def doneGet(self, token, error, value):
                                        pending.remove(token)
                                        if error:
                                            protocol.log(
                                                "Error from Registers.getm",
                                                error)
                                        else:
                                            print("getm " + str(ctx.getID()) +
                                                  " " +
                                                  str(list(map(int, value))))
                                        if not pending:
                                            onDone()

                                pending.append(regs.getm(locs, DoneGetM()))
                            if ctx.isWriteable() and not ctx.isWriteOnce() \
                                    and ctx.getSize() >= 2:
                                locs = []
                                locs.append(
                                    registers.Location(ctx.getID(), 0, 1))
                                locs.append(
                                    registers.Location(ctx.getID(), 1, 1))

                                class DoneSetM(registers.DoneSet):
                                    def doneGet(self, token, error):
                                        pending.remove(token)
                                        if error:
                                            protocol.log(
                                                "Error from Registers.setm",
                                                error)
                                        if not pending:
                                            onDone()

                                pending.append(
                                    regs.setm(locs, (255, 255), DoneSetM()))
                        if not pending:
                            onDone()
Esempio n. 37
0
 def event(self, name, data):
     try:
         args = channel.fromJSONSequence(data)
         if name == "peerAdded":
             assert len(args) == 1
             _peer = Peer(self.channel.getRemotePeer(), args[0])
             if self.proxy.peers.get(_peer.getID()):
                 protocol.log("Invalid peerAdded event", Exception())
                 return
             self.proxy.peers[_peer.getID()] = _peer
             for l in self.proxy.listeners:
                 try:
                     l.peerAdded(_peer)
                 except Exception as x:
                     protocol.log("Unhandled exception in Locator listener", x)
         elif name == "peerChanged":
             assert len(args) == 1
             m = args[0]
             if not m: raise Exception("Locator service: invalid peerChanged event - no peer ID")
             _peer = self.proxy.peers.get(m.get(peer.ATTR_ID))
             if not _peer: return
             self.proxy.peers[_peer.getID()] = _peer
             for l in self.proxy.listeners:
                 try:
                     l.peerChanged(_peer)
                 except Exception as x:
                     protocol.log("Unhandled exception in Locator listener", x)
         elif name == "peerRemoved":
             assert len(args) == 1
             id = args[0]
             _peer = self.proxy.peers.get(id)
             if not _peer: return
             del self.proxy.peers[id]
             for l in self.proxy.listeners:
                 try:
                     l.peerRemoved(id)
                 except Exception as x:
                     protocol.log("Unhandled exception in Locator listener", x)
         elif name == "peerHeartBeat":
             assert len(args) == 1
             id = args[0]
             _peer = self.proxy.peers.get(id)
             if not _peer: return
             for l in self.proxy.listeners:
                 try:
                     l.peerHeartBeat(id)
                 except Exception as x:
                     protocol.log("Unhandled exception in Locator listener", x)
         else:
             raise IOError("Locator service: unknown event: " + name)
     except Exception as x:
         self.channel.terminate(x)
Esempio n. 38
0
 def doneGetChildren(self, token, error, ctx_ids):
     if error:
         protocol.log("Error from StackTrace.getChildren", error)
         return
     class DoneGetContext(stacktrace.DoneGetContext):
         def doneGetContext(self, token, error, ctxs):
             if error:
                 protocol.log("Error from StackTrace.getContext", error)
                 return
             if ctxs:
                 for ctx in ctxs:
                     print ctx
     stack.getContext(ctx_ids, DoneGetContext())
Esempio n. 39
0
def onChannelOpened(channel, service_names, services_by_name):
    with _lock:
        for name in service_names:
            for provider in _providers:
                try:
                    service = provider.getServiceProxy(channel, name)
                    if not service: continue
                    services_by_name[name] = service
                    break
                except Exception as x:
                    protocol.log("Error calling TCF service provider", x)
            if name in services_by_name: continue
            services_by_name[name] = GenericProxy(channel, name)
Esempio n. 40
0
 def _onSocketConnected(self, x):
     if x:
         self.terminate(x)
         self.closed = True
     if self.closed:
         try:
             if self.socket:
                 self.socket.close()
         except socket.error as y:
             protocol.log("Cannot close socket", y)
     else:
         self.started = True
         self.start()
Esempio n. 41
0
 def doneList(self, token, error, ctx_ids):
     if error:
         protocol.log("Error from Symbols.list", error)
         return
     class DoneGetContext(symbols.DoneGetContext):
         def doneGetContext(self, token, error, ctx):
             if error:
                 protocol.log("Error from Symbols.getContext", error)
                 return
             print ctx
     if ctx_ids:
         for ctx_id in ctx_ids:
             syms.getContext(ctx_id, DoneGetContext())
Esempio n. 42
0
 def doneGetContext(self, token, error, context):
     if error:
         protocol.log("Error from RunControl.getContext", error)
         with lock: lock.notify()
         return
     class DoneResume(runcontrol.DoneCommand):
         def doneCommand(self, token, error):
             if error:
                 protocol.log("Error from RunControl.resume", error)
             else:
                 context.suspend(runcontrol.DoneCommand())
             with lock: lock.notify()
     context.resume(runcontrol.RM_RESUME, 1, None, DoneResume())
Esempio n. 43
0
def onChannelCreated(channel, services_by_name):
    with _lock:
        # TODO ZeroCopy support is incomplete
#        zero_copy = ZeroCopy()
#        services_by_name[zero_copy.getName()] = zero_copy
        for provider in _providers:
            try:
                arr = provider.getLocalService(channel)
                if not arr: continue
                for service in arr:
                    if service.getName() in services_by_name: continue
                    services_by_name[service.getName()] = service
            except Exception as x:
                protocol.log("Error calling TCF service provider", x);
Esempio n. 44
0
 def getServiceProxy(self, channel, service_name):
     service = None
     try:
         clsName = service_name + "Proxy"
         package = self.package_base + "." + clsName
         clsModule = __import__(package, fromlist=[clsName], globals=globals())
         cls = clsModule.__dict__.get(clsName)
         service = cls(channel)
         assert service_name == service.getName()
     except ImportError:
         pass
     except Exception as x:
         protocol.log("Cannot instantiate service proxy for "+service_name, x)
     return service
Esempio n. 45
0
            def doneStart(self, token, error, process):
                """Called when process start is done.

                :param token: pending command handle.
                :param error: error description if operation failed, **None**
                              if  succeeded.
                :param process: ProcessContext object representing the started
                                process.
                """
                if error:
                    protocol.log("Error from Processes.start", error)
                else:
                    val.setValue(process)
                with condition:
                    condition.notify()
Esempio n. 46
0
            def doneGetChildren(self, token, error, ctx_ids):
                if error:
                    protocol.log("Error from StackTrace.getChildren", error)
                    return

                class DoneGetContext(stacktrace.DoneGetContext):
                    def doneGetContext(self, token, error, ctxs):
                        if error:
                            protocol.log("Error from StackTrace.getContext",
                                         error)
                            return
                        if ctxs:
                            for ctx in ctxs:
                                print(ctx)

                stack.getContext(ctx_ids, DoneGetContext())
Esempio n. 47
0
            def doneList(self, token, error, ctx_ids):
                if error:
                    protocol.log("Error from Symbols.list", error)
                    return

                class DoneGetContext(symbols.DoneGetContext):
                    def doneGetContext(self, token, error, ctx):
                        if error:
                            protocol.log("Error from Symbols.getContext",
                                         error)
                            return
                        print(ctx)

                if ctx_ids:
                    for ctx_id in ctx_ids:
                        syms.getContext(ctx_id, DoneGetContext())
Esempio n. 48
0
            def doneGetChildren(self, token, error, ids):
                """Called when context list retrieval is done.

                :param token: pending command handle.
                :param error: error description if operation failed, **None**
                              if succeeded.
                :param context_ids: array of available context IDs.
                """
                if error:
                    protocol.log(
                        "Error from " + service.getName() + ".getContext()",
                        error)
                else:
                    val.setValue(ids)
                with condition:
                    condition.notify()
Esempio n. 49
0
            def doneGetContext(self, token, error, context):
                """Called when context data retrieval is done.

                :param token: pending command handle.
                :param error: error description if operation failed, **None**
                              if succeeded.
                :param context: context data.
                """
                if error:
                    protocol.log(
                        "Error from " + service.getName() + ".getContext()",
                        error)
                else:
                    val.setValue(context)
                with condition:
                    condition.notify()
Esempio n. 50
0
            def doneGetContext(self, token, error, context):
                if error:
                    protocol.log("Error from RunControl.getContext", error)
                    with lock:
                        lock.notify()
                    return

                class DoneResume(runcontrol.DoneCommand):
                    def doneCommand(self, token, error):
                        if error:
                            protocol.log("Error from RunControl.resume", error)
                        else:
                            context.suspend(runcontrol.DoneCommand())
                        with lock:
                            lock.notify()

                context.resume(runcontrol.RM_RESUME, 1, None, DoneResume())
Esempio n. 51
0
            def doneGetState(self, token, error, suspended, pc, reason,
                             params):
                """Called when RunControlContext.getState() command execution
                is complete.

                :param token: pending command handle.
                :param error: command execution error or None.
                :param suspended: true if the context is suspended
                :param pc: program counter of the context (if suspended).
                :param reason: suspend reason (if suspended), see REASON_*.
                :param params: additional target specific data about context
                               state, see STATE_*.
                """
                if error:
                    protocol.log("Error from runcontrol.getState()", error)
                else:
                    val.setValue((suspended, pc, reason, params))
                with condition:
                    condition.notify()
Esempio n. 52
0
        def doneGetIDs(token, error, ids):
            if error:
                protocol.log("Error from Breakpoints.getIDs", error)
                return
            print("Breakpoints : " + str(ids))

            def doneGetProperties(token, error, props):
                if error:
                    protocol.log("Error from Breakpoints.getProperties", error)
                    return
                print("Breakpoint Properties: " + str(props))

            def doneGetStatus(token, error, props):
                if error:
                    protocol.log("Error from Breakpoints.getStatus", error)
                    return
                print("Breakpoint Status: " + str(props))

            for bpid in ids:
                bps.getProperties(bpid, doneGetProperties)
                bps.getStatus(bpid, doneGetStatus)
Esempio n. 53
0
            def doneGetChildren(self, token, error, context_ids):
                pending.remove(token)
                if error:
                    protocol.log("Error from SysMonitor.getChildren", error)
                else:

                    class DoneGetContext(sysmonitor.DoneGetContext):
                        def doneGetContext(self, token, error, context):
                            pending.remove(token)
                            if error:
                                protocol.log(
                                    "Error from SysMonitor.getContext", error)
                            else:
                                processes.append(context)
                            if not pending:
                                with lock:
                                    lock.notify()

                    for ctx_id in context_ids:
                        pending.append(sm.getContext(ctx_id, DoneGetContext()))
                if not pending:
                    with lock:
                        lock.notify()
Esempio n. 54
0
def test():
    global _services
    protocol.startEventQueue()
    atexit.register(protocol.getEventQueue().shutdown)
    # testTimer()
    try:
        c = tcf.connect("TCP:127.0.0.1:1534")
    except Exception as e:
        protocol.log(e)
        sys.exit()
    assert c.state == channel.STATE_OPEN
    if __TRACE:
        protocol.invokeAndWait(c.addTraceListener, TraceListener())
    _services = sorted(protocol.invokeAndWait(c.getRemoteServices))
    print("services=" + str(_services))

    if "RunControl" in _services:
        # RunControl must be first
        _services.remove("RunControl")
        _services.insert(0, "RunControl")
    for service in _services:
        testFct = globals().get("test" + service)
        if testFct:
            print("Testing service '%s'..." % service)
            try:
                testFct(c)
                print("Completed test of service '%s'." % service)
            except Exception as e:
                protocol.log("Exception testing %s" % service, e)
        else:
            print("No test for service '%s' found." % service)
    try:
        testSyncCommands(c)
        testTasks(c)
        testEvents(c)
        testDataCache(c)
    except Exception as e:
        protocol.log(e)

    if c.state == channel.STATE_OPEN:
        time.sleep(5)
        protocol.invokeLater(c.close)
    time.sleep(2)
Esempio n. 55
0
 def doneGetContext(self, token, error, ctx):
     if error:
         protocol.log("Error from Symbols.getContext",
                      error)
         return
     print(ctx)
Esempio n. 56
0
                             condition=lock)
        lock.wait(10)


# --------------------------------------------------------------------------- #

# TCF initialisation

protocol.startEventQueue()
protocol.setLogger(TcfProtocolLogger())
atexit.register(protocol.getEventQueue().shutdown)

try:
    c = tcf.connect("TCP:127.0.0.1:1534")
except Exception as e:
    protocol.log(e)
    sys.exit()

# If there is a streams service, listen to it

streamsSvc = getService(c, streams.NAME)
if streamsSvc:
    subscribe(streamsSvc, 'ProcessesV1', StreamsListener(streamsSvc))

p = start(c, '/bin/ls', '-l', '-a')

# this part is a bit tricky, the runcontrol contexts which accept a resume
# command are the contexts which have a state. Recursively try to find the
# runcontrol context which has a state, and resume it.

rcSvc = getService(c, runcontrol.NAME)
Esempio n. 57
0
 def doneSet(self, token, error):
     if error:
         protocol.log("Error from PathMap.set", error)
     with lock:
         lock.notify()
Esempio n. 58
0
 def doneSet(token, error):
     if error:
         protocol.log("Error from Breakpoints.set", error)
         return
Esempio n. 59
0
 def doneGetStatus(token, error, props):
     if error:
         protocol.log("Error from Breakpoints.getStatus", error)
         return
     print("Breakpoint Status: " + str(props))