Author: tack
Date: Tue Mar 11 13:20:40 2008
New Revision: 3180

Log:
Use kaa.tempfile in kaa.Socket if filename does not start with a slash
(previously only did it if the filename contained no slash).  Remove this
logic from kaa.rpc.


Modified:
   trunk/base/src/notifier/sockets.py
   trunk/base/src/rpc.py

Modified: trunk/base/src/notifier/sockets.py
==============================================================================
--- trunk/base/src/notifier/sockets.py  (original)
+++ trunk/base/src/notifier/sockets.py  Tue Mar 11 13:20:40 2008
@@ -223,12 +223,11 @@
 
     def _normalize_address(self, addr):
         """
-        Converts address strings in the form host:port into 2-tuples 
-        containing the hostname and integer port.  Strings not in that
-        form are assumed to represent unix socket paths.  If such a string
-        contains no /, a tempfile is used using kaa.tempfile().  If we can't
-        make sense of the given address, a ValueError exception will
-        be raised.
+        Converts address strings in the form host:port into 2-tuples containing
+        the hostname and integer port.  Strings not in that form are assumed to
+        represent unix socket paths.  If such a string does not start with /, a
+        tempfile is used using kaa.tempfile().  If we can't make sense of the
+        given address, a ValueError exception will be raised.
         """
         if isinstance(addr, basestring):
             if addr.count(':') == 1:
@@ -236,7 +235,7 @@
                 if not port.isdigit():
                     raise ValueError('Port specified is not an integer')
                 return addr, int(port)
-            elif '/' not in addr:
+            elif not addr.startswith('/'):
                 return tempfile(addr)
         elif not isinstance(addr, (tuple, list)) or len(addr) != 2:
             raise ValueError('Invalid address')
@@ -330,7 +329,7 @@
         Connects to the host specified in addr.  If addr is a string in the
         form host:port, or a tuple the form (host, port), a TCP socket is
         established.  Otherwise a Unix socket is established and addr is
-        treated as a filename.  In this case, if addr does not contain a /
+        treated as a filename.  In this case, if addr does not start with a /
         character, a kaa tempfile is created.
 
         This function is executed in a thread to avoid blocking.  It therefore
@@ -470,7 +469,7 @@
         self._queue_close = False
 
         self._socket.close()
-        if isinstance(self._addr, basestring) and '/' in self._addr:
+        if isinstance(self._addr, basestring) and self._addr.startswith('/'):
             # Remove unix socket if it exists.
             try:
                 os.unlink(self._addr)

Modified: trunk/base/src/rpc.py
==============================================================================
--- trunk/base/src/rpc.py       (original)
+++ trunk/base/src/rpc.py       Tue Mar 11 13:20:40 2008
@@ -687,8 +687,6 @@
     def __init__(self, address, auth_secret = '', buffer_size = None):
         sock = kaa.Socket(buffer_size)
         sock.buffer_size = buffer_size
-        if isinstance(address, str) and not address.startswith('/'):
-            address = kaa.tempfile(address)
         # FIXME: we block on connect for now; Channel.rpc() tests socket
         # connected and raises exception if it isn't, so if we do rpc() right
         # after connecting, it will fail.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to