Hi,

I noticed that on later distros (openSUSE 11.2 for example) I get this
warning:

>  DeprecationWarning: os.popen2 is deprecated.  Use the subprocess module.

It looks harmless and rdiff-backup still work as I'm used to, but it
caught my attention pretty much every day which started to get on my nerve.

So I searched for a solution or work-around and came up with this patch
(I'm no programmer though, so this might be a really bad way of 'fixing'
it):

---- START ---
diff -Nur rdiff-backup-1.2.8-orig//rdiff_backup/SetConnections.py
rdiff-backup-1.2.8//rdiff_backup/SetConnections.py
--- rdiff-backup-1.2.8-orig//rdiff_backup/SetConnections.py    
2009-03-16 15:36:21.000000000 +0100
+++ rdiff-backup-1.2.8//rdiff_backup/SetConnections.py  2010-03-24
13:57:32.000000000 +0100
@@ -145,7 +145,14 @@
                except OSError:
                        (stdin, stdout) = (None, None)
        else:
-               stdin, stdout = os.popen2(remote_cmd)
+               import subprocess
+               try:
+                       process = subprocess.Popen(remote_cmd,
shell=True, bufsize=0,
+                                                              
stdin=subprocess.PIPE,
+                                                              
stdout=subprocess.PIPE)
+                       (stdin, stdout) = (process.stdin, process.stdout)
+               except OSError:
+                       (stdin, stdout) = (None, None)
        conn_number = len(Globals.connections)
        conn = connection.PipeConnection(stdout, stdin, conn_number)
---- END ---

I noticed that the 'subprocess' module is already used for Windows ('if
os.name == "nt"), so I tried to use the same code instead 'os.popen2'. I
had to change 'shell=false' to 'shell=true' to make it work.

I did a couple of test runs and it seems to work, so I'll put it in use
on my systems and keep an eye on them. If anything comes up, I'll report.

 Regards, Danilo



-- 
Danilo Godec, sistemska podpora / system administration

Predlog! Obiscite prenovljeno spletno stran www.agenda.si 

ODPRTA KODA IN LINUX 
STORITVE : POSLOVNE RESITVE : UPRAVLJANJE IT : INFRASTRUKTURA IT : 
IZOBRAZEVANJE : PROGRAMSKA OPREMA 

Visit our updated web page at www.agenda.si 

OPEN SOURCE AND LINUX 
SERVICES : BUSINESS SOLUTIONS : IT MANAGEMENT : IT INFRASTRUCTURE : TRAINING : 
SOFTWARE 

<<attachment: danilo_godec.vcf>>

_______________________________________________
rdiff-backup-users mailing list at [email protected]
http://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki

Reply via email to