Example #1
0
 def interact(self, banner=None):
     try:
         try:
             ps1 = sys.ps1  # @UndefinedVariable
         except AttributeError:
             ps1 = None
         sys.ps1 = "tcf> "
         super(Shell, self).interact(banner)
     finally:
         if ps1:
             sys.ps1 = ps1
         else:
             del sys.ps1
         protocol.invokeLater(protocol.removeChannelOpenListener, self)
         protocol.shutdownDiscovery()
         protocol.getEventQueue().shutdown()
Example #2
0
File: shell.py Project: ppalaga/tcf
 def interact(self, banner=None):
     try:
         try:
             ps1 = sys.ps1  # @UndefinedVariable
         except AttributeError:
             ps1 = None
         sys.ps1 = "tcf> "
         super(Shell, self).interact(banner)
     finally:
         if ps1:
             sys.ps1 = ps1
         else:
             del sys.ps1
         protocol.invokeLater(protocol.removeChannelOpenListener, self)
         protocol.shutdownDiscovery()
         protocol.getEventQueue().shutdown()
Example #3
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 = protocol.invokeAndWait(c.getRemoteServices)
    print "services=", _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)
Example #4
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)
Example #5
0
def test():
    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.invokeLater(c.addTraceListener, TraceListener())
    def printServices():
        print "services=", c.getRemoteServices()
    protocol.invokeLater(printServices)

    try:
        testRunControl(c)
        testStackTrace(c)
        testDisassembly(c)
        testBreakpoints(c)
        testSymbols(c)
        testRegisters(c)
        testExpressions(c)
        testLineNumbers(c)
        testSyncCommands(c)
        testTasks(c)
        testEvents(c)
        testDataCache(c)
        testProcesses(c)
        testFileSystem(c)
        testMemory(c)
        testMemoryMap(c)
        testPathMap(c)
        testSysMonitor(c)
    except Exception as e:
        protocol.log(e)

    if c.state == channel.STATE_OPEN:
        time.sleep(5)
        protocol.invokeLater(c.close)
    time.sleep(2)
Example #6
0
    lock = threading.Condition()

    with lock:
        # TCF requests must be called by the dispatche thread, wait for a
        # maximum of 10 seconds
        protocol.invokeLater(callSubscribe, service=svc, streamType=streamType,
                             listener=listener, 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')
Example #7
0
        # maximum of 10 seconds
        protocol.invokeLater(callSubscribe,
                             service=svc,
                             streamType=streamType,
                             listener=listener,
                             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')