client/rhel/yum-rhn-plugin/rhnplugin.py | 13 ++++++
client/solaris/rhnclient/rhn/client/rhnUtils.py | 27 +++++--------
client/solaris/smartpm/smart/backends/solaris/loader.py | 11 ++---
client/solaris/smartpm/smart/backends/solaris/pm.py | 1
client/tools/osad/src/jabber_lib.py | 4 -
client/tools/rhn-kickstart/rhnkickstart/kickstart.py | 12 +++--
client/tools/rhncfg/actions/script.py | 2
client/tools/rhnpush/archive.py | 13 +++---
client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py | 11 ++---
9 files changed, 53 insertions(+), 41 deletions(-)
New commits:
commit 213b97e38dd75007281b37e3180dc68b736f2fac
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Jan 25 17:08:37 2010 +0100
on Fedora 12 yum-rhn-plugin end up with HTTP Error 401 Authorization Required
urlgrabber on Fedora 12 switched to use pycurl as a backend and it can't
handle empty X-RHN-Auth-User-Id header
diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py
b/client/rhel/yum-rhn-plugin/rhnplugin.py
index 3861b78..82f9474 100644
--- a/client/rhel/yum-rhn-plugin/rhnplugin.py
+++ b/client/rhel/yum-rhn-plugin/rhnplugin.py
@@ -16,6 +16,11 @@ import yum.Errors
from urlgrabber.grabber import URLGrabber
from urlgrabber.grabber import URLGrabError
+try:
+ from urlgrabber.grabber import pycurl
+except:
+ pycurl = None
+
from iniparse import INIConfig
import gettext
_ = gettext.gettext
@@ -339,6 +344,14 @@ class RhnRepo(YumRepository):
# return the path to the local file
self.setupRhnHttpHeaders()
+ if pycurl:
+ # pycurl/libcurl workaround: in libcurl setting an empty HTTP header means
+ # remove that header from the list
+ # but we have to send and empty X-RHN-Auth-User-Id ...
+ AuthUserH = 'X-RHN-Auth-User-Id'
+ if (AuthUserH in self.http_headers and not self.http_headers[AuthUserH]):
+ self.http_headers[AuthUserH] = "\nX-libcurl-Empty-Header-Workaround:
*"
+
# Turn our dict into a list of 2-tuples
headers = YumRepository._YumRepository__headersListFromDict(self)
commit 9afebed0e0c6fe742b3a40f73955022e71ecd3e0
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Sat Jan 23 15:28:32 2010 +0100
replaced popen2 with subprocess in client
diff --git a/client/solaris/rhnclient/rhn/client/rhnUtils.py
b/client/solaris/rhnclient/rhn/client/rhnUtils.py
index 58a692d..37b480d 100644
--- a/client/solaris/rhnclient/rhn/client/rhnUtils.py
+++ b/client/solaris/rhnclient/rhn/client/rhnUtils.py
@@ -13,7 +13,7 @@ import sys
import time
import string
import md5
-import popen2
+import subprocess
import select
import tempfile
import urlparse
@@ -207,35 +207,30 @@ def pprint_pkglist(pkglist):
def my_popen(cmd):
- c = popen2.Popen3(cmd, capturestderr=1, bufsize=0)
+ c = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True, bufsize=0)
# We don't write to the child process
- c.tochild.close()
+ c.stdin.close()
child_out = tempfile.TemporaryFile()
child_err = tempfile.TemporaryFile()
# Map the input file descriptor with the temporary (output) one
- fd_mappings = [(c.fromchild, child_out), (c.childerr, child_err)]
+ fd_mappings = [(c.stdout, child_out), (c.stderr, child_err)]
buffer_size = 16384
exitcode = None
while 1:
status = c.poll()
- if status != -1:
- if os.WIFEXITED(status):
+ if status is not None:
+ if status >= 0:
# Save the exit code, we still have to read from the pipes
- exitcode = os.WEXITSTATUS(status)
- elif os.WIFSIGNALED(status):
- # Some signal terminated this process
- sig = os.WTERMSIG(status)
- exitcode = -sig
- break
- elif os.WIFSTOPPED(status):
- # Some signal stopped this process
- sig = os.WSTOPSIG(status)
- exitcode = -sig
+ exitcode = status
+ else:
+ # Some signal sent to this process
+ exitcode = status
break
fd_set = map(lambda x: x[0], fd_mappings)
diff --git a/client/solaris/smartpm/smart/backends/solaris/loader.py
b/client/solaris/smartpm/smart/backends/solaris/loader.py
index 2e65886..11be85d 100644
--- a/client/solaris/smartpm/smart/backends/solaris/loader.py
+++ b/client/solaris/smartpm/smart/backends/solaris/loader.py
@@ -595,13 +595,14 @@ def getPkgData(filename):
pkgdir = filename
else:
import tempfile
- import popen2
+ import subprocess
tdir = tempfile.mkdtemp()
- c = popen2.Popen3(("pkgtrans", filename, tdir, "all"),
- capturestderr=1)
+ c = subprocess.Popen(("pkgtrans", filename, tdir,
"all"),
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True)
ret = c.wait()
- if ret != 0: return (pkginfo, depend)
- m = PKGTRANSRE.match(c.childerr.read())
+ if ret: return (pkginfo, depend)
+ m = PKGTRANSRE.match(c.stderr.read())
if not m: return (pkginfo, depend)
pkgname = m.groups()[0]
pkgdir = os.path.join(tdir, pkgname)
diff --git a/client/solaris/smartpm/smart/backends/solaris/pm.py
b/client/solaris/smartpm/smart/backends/solaris/pm.py
index 5011700..df140fa 100644
--- a/client/solaris/smartpm/smart/backends/solaris/pm.py
+++ b/client/solaris/smartpm/smart/backends/solaris/pm.py
@@ -22,7 +22,6 @@
import commands
import os
-import popen2
import shutil
import tempfile
import zipfile
diff --git a/client/tools/osad/src/jabber_lib.py b/client/tools/osad/src/jabber_lib.py
index 344a91b..bbe2b4b 100644
--- a/client/tools/osad/src/jabber_lib.py
+++ b/client/tools/osad/src/jabber_lib.py
@@ -1385,8 +1385,8 @@ def push_to_background():
# close file descriptors
- #import popen2
- #for i in range(3, popen2.MAXFD):
+ # from subprocess import MAXFD
+ #for i in range(3, MAXFD):
# try:
# os.close(i)
# except:
diff --git a/client/tools/rhn-kickstart/rhnkickstart/kickstart.py
b/client/tools/rhn-kickstart/rhnkickstart/kickstart.py
index e21fe3c..414cbc8 100644
--- a/client/tools/rhn-kickstart/rhnkickstart/kickstart.py
+++ b/client/tools/rhn-kickstart/rhnkickstart/kickstart.py
@@ -23,7 +23,7 @@ import time
import types
import shutil
import string
-import popen2
+import subprocess
from rhnkickstart import lilo
from rhnkickstart import common
@@ -424,14 +424,16 @@ def _modify_s390(base, vmlinuz, initrd, append, error_messages):
def my_popen(cmd):
- c = popen2.Popen3(cmd, capturestderr=1, bufsize=-1)
- c.tochild.close()
+ c = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True,
+ bufsize=-1)
+ c.stdin.close()
while 1:
status = c.poll()
- if os.WIFEXITED(status):
+ if status is not None:
# Save the exit code, we still have to read from
# the pipes
- return os.WEXITSTATUS(status), c.fromchild, c.childerr
+ return status, c.stdout, c.stderr
def local_network_kickstart(extra_append, ks_data, static_device, initrd,
preserve_files=[]):
"""
diff --git a/client/tools/rhncfg/actions/script.py
b/client/tools/rhncfg/actions/script.py
index 365dac9..3857882 100644
--- a/client/tools/rhncfg/actions/script.py
+++ b/client/tools/rhncfg/actions/script.py
@@ -22,7 +22,7 @@ import select
import signal
import tempfile
import base64
-from popen2 import MAXFD
+from subprocess import MAXFD
# this is ugly, hopefully it will be natively supported in up2date
diff --git a/client/tools/rhnpush/archive.py b/client/tools/rhnpush/archive.py
index dd5c72f..9ab991c 100644
--- a/client/tools/rhnpush/archive.py
+++ b/client/tools/rhnpush/archive.py
@@ -20,7 +20,7 @@
# $Id$
import os
-import popen2
+import subprocess
import shutil
import sys
import tempfile
@@ -318,15 +318,16 @@ def _has_executable(exc):
def _my_popen(cmd):
"""Execute a command as a subprocess and return its exit
status"""
- popen = popen2.Popen3(cmd, capturestderr=1)
- popen.tochild.close()
+ popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True)
+ popen.stdin.close()
txt = ""
while 1:
- rd, wr, ex = select.select([ popen.fromchild, popen.childerr ], [], [
popen.fromchild, popen.childerr ], 5)
+ rd, wr, ex = select.select([ popen.stdout, popen.stderr ], [], [ popen.stdout,
popen.stderr ], 5)
if ex:
- txt += popen.fromchild.read()
- txt += popen.childerr.read()
+ txt += popen.stdout.read()
+ txt += popen.stderr.read()
break
if rd:
txt += rd[0].read()
diff --git a/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py
b/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py
index 0215b60..9e635be 100644
--- a/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py
+++ b/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py
@@ -22,7 +22,7 @@ import shutil
import sys
import types
import os
-import popen2
+import subprocess
import os.path
import tempfile
import xmlrpclib
@@ -271,14 +271,15 @@ def _remove_func(path):
def my_popen(cmd):
print "CMD: %s " % cmd
- c = popen2.Popen3(cmd, capturestderr=1, bufsize=-1)
- c.tochild.close()
+ c = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True, bufsize=-1)
+ c.stdin.close()
while 1:
status = c.poll()
- if os.WIFEXITED(status):
+ if status is not None:
# Save the exit code, we still have to read from
# the pipes
- return os.WEXITSTATUS(status), c.fromchild, c.childerr
+ return status, c.stdout, c.stderr
def _build_error(status, stdout, stderr):
params = {