diff options
author | Anton Leherbauer | 2012-01-23 09:28:01 +0000 |
---|---|---|
committer | Anton Leherbauer | 2012-01-23 09:28:01 +0000 |
commit | 6f047bf6a21dcc9be9bf444da123e8b32834da52 (patch) | |
tree | 22cc2972f8bfa7a3693aa514ecef25581dd2dd32 /python/src/tcf/__init__.py | |
parent | a1b540e1272eda3d1b09f3232512db9cc0f1d168 (diff) | |
download | org.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/__init__.py')
-rw-r--r-- | python/src/tcf/__init__.py | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/python/src/tcf/__init__.py b/python/src/tcf/__init__.py index 5918652db..9978c6234 100644 --- a/python/src/tcf/__init__.py +++ b/python/src/tcf/__init__.py @@ -1,63 +1,63 @@ -# *******************************************************************************
-# * 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
-# *******************************************************************************
-
-"""
-TCF - Target Communication Framework
-"""
-
-import types
-import protocol, peer, channel
-from util import task
-
-__all__ = ('connect')
-
-def connect(params, wait=True):
- """Connect to peer. Argument is a string of the form <transport>:<host>:<port>,
- e.g. "TCP:127.0.0.1:1534" """
- if type(params) is types.StringType:
- params = _parse_params(params)
- elif type(params) is not types.DictType:
- raise TypeError("Expected string or dict")
- p = peer.TransientPeer(params)
- if wait:
- c = task.Task(_openChannel, p).get()
- else:
- c = protocol.invokeAndWait(p.openChannel)
- return c
-
-def peers():
- "Return list of discovered remote peers"
- locator = protocol.getLocator()
- if locator:
- return protocol.invokeAndWait(locator.getPeers)
-
-def _openChannel(p, done=None):
- assert protocol.isDispatchThread()
- c = p.openChannel()
- if done is None: return
- class ChannelListener(channel.ChannelListener):
- def onChannelOpened(self):
- c.removeChannelListener(self)
- done(None, c)
- def onChannelClosed(self, error):
- done(error, None)
- c.addChannelListener(ChannelListener())
-
-def _parse_params(paramStr):
- args = paramStr.split(":")
- if len(args) != 3:
- raise ValueError("Expected format: <transport>:<host>:<port>")
- transp, host, port = args
- return {
- peer.ATTR_IP_HOST : host,
- peer.ATTR_IP_PORT : port,
- peer.ATTR_TRANSPORT_NAME : transp
- }
+# ******************************************************************************* +# * 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 +# ******************************************************************************* + +""" +TCF - Target Communication Framework +""" + +import types +import protocol, peer, channel +from util import task + +__all__ = ('connect') + +def connect(params, wait=True): + """Connect to peer. Argument is a string of the form <transport>:<host>:<port>, + e.g. "TCP:127.0.0.1:1534" """ + if type(params) is types.StringType: + params = _parse_params(params) + elif type(params) is not types.DictType: + raise TypeError("Expected string or dict") + p = peer.TransientPeer(params) + if wait: + c = task.Task(_openChannel, p).get() + else: + c = protocol.invokeAndWait(p.openChannel) + return c + +def peers(): + "Return list of discovered remote peers" + locator = protocol.getLocator() + if locator: + return protocol.invokeAndWait(locator.getPeers) + +def _openChannel(p, done=None): + assert protocol.isDispatchThread() + c = p.openChannel() + if done is None: return + class ChannelListener(channel.ChannelListener): + def onChannelOpened(self): + c.removeChannelListener(self) + done(None, c) + def onChannelClosed(self, error): + done(error, None) + c.addChannelListener(ChannelListener()) + +def _parse_params(paramStr): + args = paramStr.split(":") + if len(args) != 3: + raise ValueError("Expected format: <transport>:<host>:<port>") + transp, host, port = args + return { + peer.ATTR_IP_HOST : host, + peer.ATTR_IP_PORT : port, + peer.ATTR_TRANSPORT_NAME : transp + } |