[Idle-dev] [ idlefork-Patches-451088 ] RemoteInterpreter patch to run on win32

noreply@sourceforge.net noreply@sourceforge.net
Wed, 15 Aug 2001 00:01:03 -0700


Patches item #451088, was opened at 2001-08-15 00:01
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=309579&aid=451088&group_id=9579

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: RemoteInterpreter patch to run on win32

Initial Comment:
*** ../Tools/idlefork-0.8.1/RemoteInterp.py	Thu 
Jul 12 17:06:22 2001
--- ../Tools/idlenew/RemoteInterp.py	Wed Aug 15 
15:05:10 2001
***************
*** 121,127 ****
      def _decode_msg(self, msg):
          seqno = self.decode_seqno(msg
[:self.SEQNO_ENC_LEN])
          msg = msg[self.SEQNO_ENC_LEN:]
!         parts = msg.split(" ", 2)
          if len(parts) == 1:
              cmd = msg
              arg = ''
--- 121,131 ----
      def _decode_msg(self, msg):
          seqno = self.decode_seqno(msg
[:self.SEQNO_ENC_LEN])
          msg = msg[self.SEQNO_ENC_LEN:]
!         #
!         # split a message into two parts
!         # cmd <space> arg
!         #
!         parts = msg.split(" ", 1)
          if len(parts) == 1:
              cmd = msg
              arg = ''
***************
*** 263,280 ****
          self._cmd.reply()
          self._cmd.close()
  
  def startRemoteInterp(id):
      import os
      # UNIX domain sockets are simpler for starters
      sock = socket.socket(socket.AF_UNIX, 
socket.SOCK_STREAM)
!     sock.bind("/var/tmp/ri.%s" % id)
      try:
          sock.listen(1)
          cli, addr = sock.accept()
          rinterp = RemoteInterp(cli)
          rinterp.run()
      finally:
!         os.unlink("/var/tmp/ri.%s" % id)
  
  class RIClient:
      """Client of the remote interpreter"""
--- 267,299 ----
          self._cmd.reply()
          self._cmd.close()
  
+ def getAddress(id):
+     """returns a string representing the address of 
the
+     Unix domain socket for a particular id"""
+     import tempfile
+     import os
+     if tempfile.tempdir:
+         filename = os.path.join
(tempfile.tempdir, "rs.%s" % id)
+     else: 
+         #
+         # no temp dir defined in environment, use the
+         # current directory.
+         #
+         filename = "rs.%s" % id
+     return filename
+ 
  def startRemoteInterp(id):
      import os
      # UNIX domain sockets are simpler for starters
      sock = socket.socket(socket.AF_UNIX, 
socket.SOCK_STREAM)
!     sock.bind( getAddress(id) )
      try:
          sock.listen(1)
          cli, addr = sock.accept()
          rinterp = RemoteInterp(cli)
          rinterp.run()
      finally:
!         os.unlink( getAddress(id) )
  
  class RIClient:
      """Client of the remote interpreter"""
***************
*** 317,328 ****
  
  def riExec(id, file):
      sock = socket.socket(socket.AF_UNIX, 
socket.SOCK_STREAM)
!     sock.connect("/var/tmp/ri.%s" % id)
      cli = RIClient(sock)
      cli.execfile(file)
      cli.run()
  
  if __name__ == "__main__":
      import sys
      import getopt
  
--- 336,360 ----
  
  def riExec(id, file):
      sock = socket.socket(socket.AF_UNIX, 
socket.SOCK_STREAM)
!     sock.connect(getAddress(id))
      cli = RIClient(sock)
      cli.execfile(file)
      cli.run()
  
  if __name__ == "__main__":
+ 
+     # Usage:
+     #   python RemoteInterp.py [-c] [-v] id
+     # Options:
+     #   -c  run as a client. Otherwise, run as a 
server by default
+     #   -v  verbose mode
+     # Example:
+     #   This starts the server:
+     #   python RemoteInterp.py id123
+     #
+     #   This starts the client:
+     #   python RemoteInterp.py -c id123 test.py 
+     #
      import sys
      import getopt
  


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=309579&aid=451088&group_id=9579