Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2012-01-23 04:28:01 -0500
committerAnton Leherbauer2012-01-23 04:28:01 -0500
commit6f047bf6a21dcc9be9bf444da123e8b32834da52 (patch)
tree22cc2972f8bfa7a3693aa514ecef25581dd2dd32 /python/src/tcf/shell.py
parenta1b540e1272eda3d1b09f3232512db9cc0f1d168 (diff)
downloadorg.eclipse.tcf-6f047bf6a21dcc9be9bf444da123e8b32834da52.tar.gz
org.eclipse.tcf-6f047bf6a21dcc9be9bf444da123e8b32834da52.tar.xz
org.eclipse.tcf-6f047bf6a21dcc9be9bf444da123e8b32834da52.zip
TCF Python: Unify line endings.
Diffstat (limited to 'python/src/tcf/shell.py')
-rw-r--r--python/src/tcf/shell.py202
1 files changed, 101 insertions, 101 deletions
diff --git a/python/src/tcf/shell.py b/python/src/tcf/shell.py
index 38942fe30..ea7f1f177 100644
--- a/python/src/tcf/shell.py
+++ b/python/src/tcf/shell.py
@@ -1,101 +1,101 @@
-# *******************************************************************************
-# * Copyright (c) 2011 Wind River Systems, Inc. and others.
-# * All rights reserved. This program and the accompanying materials
-# * are made available under the terms of the Eclipse Public License v1.0
-# * which accompanies this distribution, and is available at
-# * http://www.eclipse.org/legal/epl-v10.html
-# *
-# * Contributors:
-# * Wind River Systems - initial API and implementation
-# *******************************************************************************
-
-"""
-Simple interactive shell for TCF. This is basically a Python interpreter with a few
-TCF extensions.
-
-Usage:
- python -m tcf.shell
-
-Commands:
- peers - Print discovered peers
- connect(params) - Connect to TCF peer, params = "<protocol>:<host>:<port>"
- cmd.<service>.<command<(args)
- - Send command to remote service and return result
- disconnect - Disconnect from peer
- events.record(<service>)
- - Start recording events for service
- events - Print last recorded events
- events.stop([<service>])
- - Stop recording for service or for all services
-"""
-
-import code, sys, os
-try:
- import tcf
-except ImportError:
- # add current dir to path
- sys.path.insert(0, os.getcwd())
- import tcf
-from tcf.util import sync, event
-from tcf import protocol, channel
-
-class print_peers:
- "Print list of discovered peers"
- def __call__(self):
- return tcf.peers()
- def __repr__(self):
- peers = tcf.peers()
- return '\n'.join(map(lambda p: "%s, %s" % (p.getID(), p.getName()), peers.values()))
-
-class Shell(code.InteractiveConsole, protocol.ChannelOpenListener, channel.ChannelListener):
- def __init__(self):
- locals = {
- "connect" : tcf.connect,
- "peers" : print_peers()
- }
- protocol.startEventQueue()
- protocol.startDiscovery()
- protocol.invokeAndWait(protocol.addChannelOpenListener, self)
- code.InteractiveConsole.__init__(self, locals)
- 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()
- def onChannelOpen(self, channel):
- wrapper = sync.DispatchWrapper(channel)
- self.locals["channel"] = wrapper
- self.locals["disconnect"] = wrapper.close
- self.locals["cmd"] = sync.CommandControl(channel, interactive=True)
- self.locals["events"] = event.EventRecorder(channel)
- protocol.invokeAndWait(protocol.removeChannelOpenListener, self)
- wrapper.addChannelListener(self)
- def onChannelClosed(self, error):
- del self.locals["channel"]
- del self.locals["cmd"]
- del self.locals["disconnect"]
- del self.locals["events"]
- protocol.addChannelOpenListener(self)
-
-def interact():
- try:
- # enable commandline editing if available
- import readline #@UnusedImport
- except ImportError:
- pass
- shell = Shell()
- shell.interact("TCF Shell")
-
-if __name__ == "__main__":
- interact()
+# *******************************************************************************
+# * Copyright (c) 2011 Wind River Systems, Inc. and others.
+# * All rights reserved. This program and the accompanying materials
+# * are made available under the terms of the Eclipse Public License v1.0
+# * which accompanies this distribution, and is available at
+# * http://www.eclipse.org/legal/epl-v10.html
+# *
+# * Contributors:
+# * Wind River Systems - initial API and implementation
+# *******************************************************************************
+
+"""
+Simple interactive shell for TCF. This is basically a Python interpreter with a few
+TCF extensions.
+
+Usage:
+ python -m tcf.shell
+
+Commands:
+ peers - Print discovered peers
+ connect(params) - Connect to TCF peer, params = "<protocol>:<host>:<port>"
+ cmd.<service>.<command<(args)
+ - Send command to remote service and return result
+ disconnect - Disconnect from peer
+ events.record(<service>)
+ - Start recording events for service
+ events - Print last recorded events
+ events.stop([<service>])
+ - Stop recording for service or for all services
+"""
+
+import code, sys, os
+try:
+ import tcf
+except ImportError:
+ # add current dir to path
+ sys.path.insert(0, os.getcwd())
+ import tcf
+from tcf.util import sync, event
+from tcf import protocol, channel
+
+class print_peers:
+ "Print list of discovered peers"
+ def __call__(self):
+ return tcf.peers()
+ def __repr__(self):
+ peers = tcf.peers()
+ return '\n'.join(map(lambda p: "%s, %s" % (p.getID(), p.getName()), peers.values()))
+
+class Shell(code.InteractiveConsole, protocol.ChannelOpenListener, channel.ChannelListener):
+ def __init__(self):
+ locals = {
+ "connect" : tcf.connect,
+ "peers" : print_peers()
+ }
+ protocol.startEventQueue()
+ protocol.startDiscovery()
+ protocol.invokeAndWait(protocol.addChannelOpenListener, self)
+ code.InteractiveConsole.__init__(self, locals)
+ 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()
+ def onChannelOpen(self, channel):
+ wrapper = sync.DispatchWrapper(channel)
+ self.locals["channel"] = wrapper
+ self.locals["disconnect"] = wrapper.close
+ self.locals["cmd"] = sync.CommandControl(channel, interactive=True)
+ self.locals["events"] = event.EventRecorder(channel)
+ protocol.invokeAndWait(protocol.removeChannelOpenListener, self)
+ wrapper.addChannelListener(self)
+ def onChannelClosed(self, error):
+ del self.locals["channel"]
+ del self.locals["cmd"]
+ del self.locals["disconnect"]
+ del self.locals["events"]
+ protocol.addChannelOpenListener(self)
+
+def interact():
+ try:
+ # enable commandline editing if available
+ import readline #@UnusedImport
+ except ImportError:
+ pass
+ shell = Shell()
+ shell.interact("TCF Shell")
+
+if __name__ == "__main__":
+ interact()

Back to the top