Am 19.10.10 15:30, schrieb Stuart Henderson:
> On 2010/10/19 08:56, Jim Razmus wrote:
>> I recommend you submit your patch to the tentakel project.  We _could_
>> put it in the ports tree, but upstream is better in my opinion.
> 
> It's dead upstream, they recommend using gsh instead.
> 
> These warnings mean "this port will be broken with a future update
> to python" - the problems should be fixed rather than just hiding the
> warnings.
> 
> Tasmanian Devil wrote:
>>> Since the upgrade to Python 2.6 sysutils/tentakel shows these warnings
>>> above the usual output:
>>>
>>> /usr/local/lib/python2.6/site-packages/lekatnet/config.py:55:
>>> DeprecationWarning: The popen2 module is deprecated.  Use the
>>> subprocess module.
>>>   import popen2
>>> /usr/local/lib/python2.6/site-packages/lekatnet/plugins/rsh.py:29:
>>> DeprecationWarning: the md5 module is deprecated; use hashlib instead
>>>   import md5
> 
> Not sure how to adapt popen2, they are doing this:
> 
>  p = Popen3(cmd, capturestderr=True)
> 
> Maybe someone with time can look at the notes in "pydoc2.6 subprocess"
> and work it out.
> 
> For md5, since we don't have to worry about Python 2.4, we can
> just do this:
> 
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/sysutils/tentakel/Makefile,v
> retrieving revision 1.12
> diff -u -p -r1.12 Makefile
> --- Makefile  19 Oct 2010 07:43:03 -0000      1.12
> +++ Makefile  19 Oct 2010 13:15:41 -0000
> @@ -3,7 +3,7 @@
>  COMMENT=     distributed command execution
>  
>  DISTNAME=    tentakel-357
> -REVISION =   1
> +REVISION =   2
>  CATEGORIES=  sysutils
>  MAINTAINER=  Sebastian Stark <s...@todesplanet.de>
>  HOMEPAGE=    http://tentakel.biskalar.de/
> Index: patches/patch-py_lekatnet_plugins_rsh_py
> ===================================================================
> RCS file: patches/patch-py_lekatnet_plugins_rsh_py
> diff -N patches/patch-py_lekatnet_plugins_rsh_py
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-py_lekatnet_plugins_rsh_py  19 Oct 2010 13:15:46 -0000
> @@ -0,0 +1,12 @@
> +$OpenBSD$
> +--- py/lekatnet/plugins/rsh.py.orig  Tue Oct 19 14:14:38 2010
> ++++ py/lekatnet/plugins/rsh.py       Tue Oct 19 14:14:48 2010
> +@@ -26,7 +26,7 @@ from lekatnet.remote import registerRemoteCommandPlugi
> + from lekatnet.remote import RemoteCommand
> + import time
> + import random
> +-import md5
> ++from hashlib import md5
> + 
> + class RSHRemoteCommand(RemoteCommand):
> +     "RSH remote execution class"
> 


Ok, I tried to find out how to do this and how to make a proper
"all-in-one" patch. I have no idea if the changes I made are correct
Python, but the result seems to works fine for me so far. Please point
out any mistakes I made. Patch attached.

Tas.


Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/tentakel/Makefile,v
retrieving revision 1.12
diff -u -r1.12 Makefile
--- Makefile    19 Oct 2010 07:43:03 -0000      1.12
+++ Makefile    19 Oct 2010 18:12:42 -0000
@@ -3,7 +3,7 @@
 COMMENT=       distributed command execution
 
 DISTNAME=      tentakel-357
-REVISION =     1
+REVISION =     2
 CATEGORIES=    sysutils
 MAINTAINER=    Sebastian Stark <s...@todesplanet.de>
 HOMEPAGE=      http://tentakel.biskalar.de/
Index: patches/patch-py_lekatnet_config_py
===================================================================
RCS file: patches/patch-py_lekatnet_config_py
diff -N patches/patch-py_lekatnet_config_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-py_lekatnet_config_py 19 Oct 2010 18:12:42 -0000
@@ -0,0 +1,25 @@
+--- py/lekatnet/config.py.orig Sun Feb  8 13:16:38 2009
++++ py/lekatnet/config.py      Tue Oct 19 19:23:55 2010
+@@ -52,7 +52,7 @@ import pwd
+ import tempfile
+ import sys
+ import tpg
+-import popen2
++from subprocess import Popen, PIPE
+ 
+ PARAMS = {    'ssh_path': "/usr/bin/ssh",
+               'rsh_path': "/usr/bin/rsh",
+@@ -265,10 +265,9 @@ class ConfigBase(dict):
+               for dhost in dhosts:
+                       if not os.path.isabs(dhost):
+                               dhost = os.path.join(_user_dir, dhost)
+-                      p = popen2.Popen3(dhost, capturestderr=True)
+-                      p.tochild.close()
+-                      err = p.childerr.read()
+-                      out = p.fromchild.read()
++                      p = Popen(dhost, stderr=PIPE, stdin=PIPE, stdout=PIPE, 
close_fds=True, shell=True)
++                      err = p.stderr.read()
++                      out = p.stdout.read()
+                       status = p.wait() >> 8
+                       if err:
+                               for line in err.split('\n'):
Index: patches/patch-py_lekatnet_plugins_rsh_py
===================================================================
RCS file: patches/patch-py_lekatnet_plugins_rsh_py
diff -N patches/patch-py_lekatnet_plugins_rsh_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-py_lekatnet_plugins_rsh_py    19 Oct 2010 18:12:42 -0000
@@ -0,0 +1,11 @@
+--- py/lekatnet/plugins/rsh.py.orig    Sun Feb  8 13:16:38 2009
++++ py/lekatnet/plugins/rsh.py Tue Oct 19 19:23:55 2010
+@@ -26,7 +26,7 @@ from lekatnet.remote import registerRemoteCommandPlugi
+ from lekatnet.remote import RemoteCommand
+ import time
+ import random
+-import md5
++from hashlib import md5
+ 
+ class RSHRemoteCommand(RemoteCommand):
+       "RSH remote execution class"
Index: patches/patch-py_lekatnet_remote_py
===================================================================
RCS file: patches/patch-py_lekatnet_remote_py
diff -N patches/patch-py_lekatnet_remote_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-py_lekatnet_remote_py 19 Oct 2010 18:12:42 -0000
@@ -0,0 +1,29 @@
+--- py/lekatnet/remote.py.orig Sun Feb  8 13:16:38 2009
++++ py/lekatnet/remote.py      Tue Oct 19 19:23:55 2010
+@@ -45,7 +45,7 @@ import tpg
+ import time
+ import os
+ import config
+-from popen2 import Popen3
++from subprocess import Popen, PIPE
+ 
+ 
+ class FormatString(tpg.Parser):
+@@ -138,13 +138,10 @@ class RemoteCommand(threading.Thread):
+       #
+       def getstatusoutput(self, cmd):
+               """Return (status, output) of executing cmd in a shell."""
+-              p = Popen3(cmd, capturestderr=True)
+-              p.tochild.write(self.stdin)
+-              p.tochild.close()
+-              err = p.childerr.read()
+-              p.childerr.close()
+-              text = p.fromchild.read()
+-              p.fromchild.close()
++              p = Popen(cmd, stderr=PIPE, stdin=PIPE, stdout=PIPE, 
close_fds=True, shell=True)
++              p.stdin.write(self.stdin)
++              err = p.stderr.read()
++              text = p.stdout.read()
+               sts = p.wait()
+               if sts is None: sts = 0
+               if text[-1:] == '\n': text = text[:-1]

Reply via email to