[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[rdiff-backup-users] DeprecationWarning: os.popen2 is deprecated. Use th
From: |
Danilo Godec |
Subject: |
[rdiff-backup-users] DeprecationWarning: os.popen2 is deprecated. Use the subprocess module. + patch |
Date: |
Wed, 24 Mar 2010 14:34:36 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100228 SUSE/3.0.3-3.1 Thunderbird/3.0.3 |
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
danilo_godec.vcf
Description: Vcard
- [rdiff-backup-users] DeprecationWarning: os.popen2 is deprecated. Use the subprocess module. + patch,
Danilo Godec <=