backend/server/apacheRequest.py | 20 ++++----
client/rhel/rhn-client-tools/rhn-client-tools.spec | 6 ++
client/rhel/rhn-client-tools/src/up2date_client/config.py | 3 -
client/rhel/rhn-client-tools/src/up2date_client/hardware.py | 4 -
client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py | 8 ---
client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py | 27 ++---------
client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py | 7 --
client/rhel/rhn-client-tools/src/up2date_client/tui.py | 10 ----
rel-eng/packages/rhn-client-tools | 2
9 files changed, 29 insertions(+), 58 deletions(-)
New commits:
commit ca30aa1409cd6aa6fa73703f3109357fd005f46b
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 24 17:05:44 2011 +0100
Automatic commit of package [rhn-client-tools] release [1.4.8-1].
diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec
b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index b9b492d..875cd30 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -4,7 +4,7 @@ Group: System Environment/Base
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
URL:
https://fedorahosted.org/spacewalk
Name: rhn-client-tools
-Version: 1.4.7
+Version: 1.4.8
Release: 1%{?dist}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -292,6 +292,10 @@ make -f Makefile.rhn-client-tools test
%endif
%changelog
+* Thu Mar 24 2011 Miroslav Suchý <msuchy(a)redhat.com> 1.4.8-1
+- utilize config.getServerlURL()
+- atomic save of /etc/sysconfig/rhn/up2date
+
* Thu Mar 17 2011 Miroslav Suchý <msuchy(a)redhat.com> 1.4.7-1
- 680124 - do not count cpu from /proc/cpuinfo, but use /sys/devices/system/cpu
diff --git a/rel-eng/packages/rhn-client-tools b/rel-eng/packages/rhn-client-tools
index 0034b66..9d5766d 100644
--- a/rel-eng/packages/rhn-client-tools
+++ b/rel-eng/packages/rhn-client-tools
@@ -1 +1 @@
-1.4.7-1 client/rhel/rhn-client-tools/
+1.4.8-1 client/rhel/rhn-client-tools/
commit cfebfa679c3919e1d98db11d3272bf338d0cd3e5
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 24 17:04:12 2011 +0100
utilize config.getServerlURL()
instead of manualy handling list vs. one value in
up2dateConfig["serverURL"]
utilize config.getServerlURL() which do that for us
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
index 3e7b271..ca80e5b 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -402,9 +402,7 @@ def read_memory_2_6():
def findHostByRoute():
cfg = config.initUp2dateConfig()
- sl = cfg['serverURL']
- if type(sl) == type(""):
- sl = [sl]
+ sl = config.getServerlURL()
st = {'https':443, 'http':80}
hostname = None
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
index 9843ee6..3dc48ca 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
@@ -494,13 +494,7 @@ def getServerType(serverUrl=None):
"""
if serverUrl is None:
-
- # serverURL may be a list in the config file, so by default, grab the
- # first element.
- if type(cfg['serverURL']) == type([]):
- serverUrl = cfg['serverURL'][0]
- else:
- serverUrl = cfg['serverURL']
+ serverUrl = config.getServerlURL()[0]
serverUrl = makeNiceServerUrl(serverUrl)
protocol, host, path, parameters, query, fragmentIdentifier = \
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
index 686f521..edc9eb1 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
@@ -240,12 +240,7 @@ class ChooseServerPage:
self.customServerBox =
self.chooseServerXml.get_widget('customServerTable')
def chooseServerPagePrepare(self):
- # Prepopulate the server to use from the config
- up2dateConfig = config.initUp2dateConfig()
- self.server = up2dateConfig['serverURL']
-
- if type(self.server) == type([]):
- self.server = self.server[0]
+ self.server = config.getServerlURL()[0]
log.log_debug("server is %s" % self.server)
if "rhn.redhat.com/XMLRPC" in self.server:
@@ -331,10 +326,7 @@ class ChooseServerPage:
except up2dateErrors.CommunicationError:
setArrowCursor()
log.log_exception(*sys.exc_info())
- if isinstance(up2dateConfig['serverURL'], list):
- protocol, host, path, parameters, query, fragmentIdentifier =
urlparse.urlparse(up2dateConfig['serverURL'][0])
- else:
- protocol, host, path, parameters, query, fragmentIdentifier =
urlparse.urlparse(up2dateConfig['serverURL'])
+ protocol, host, path, parameters, query, fragmentIdentifier =
urlparse.urlparse(config.getServerlURL()[0])
dialog = messageWindow.BulletedOkDialog()
if serverType == 'hosted':
dialog.add_text(_("We could not contact Red Hat Network
(%s).")
@@ -395,17 +387,13 @@ class LoginPage:
is being used.
"""
- up2dateConfig = config.initUp2dateConfig()
assert serverType in ['hosted', 'satellite']
instructionsLabel = self.loginXml.get_widget('instructionsLabel')
forgotInfoHosted = self.loginXml.get_widget('forgotInfoHosted')
forgotInfoSatellite = self.loginXml.get_widget('forgotInfoSatellite')
tipIconHosted = self.loginXml.get_widget('tipIconHosted')
tipIconSatellite = self.loginXml.get_widget('tipIconSatellite')
- if isinstance(up2dateConfig['serverURL'], list):
- server = up2dateConfig['serverURL'][0]
- else:
- server = up2dateConfig['serverURL']
+ server = config.getServerlURL()[0]
if serverType == 'satellite':
protocol, host, path, parameters, query, fragmentIdentifier =
urlparse.urlparse(server)
satelliteText = _("Please enter your account information for the
<b>%s</b> Red Hat Network Satellite:") % host
@@ -947,7 +935,7 @@ class ProvideCertificatePage:
sets the security cert label's server url at runtime
"""
securityCertlabel =
self.provideCertificateXml.get_widget("SecurityCertLabel")
- securityCertlabel.set_text(self.orig_cert_label_template %
cfg['serverURL'])
+ securityCertlabel.set_text(self.orig_cert_label_template %
config.getServerlURL()[0] )
def provideCertificatePageApply(self):
"""If the 'I have a cert' radio button is selected, this
function will
@@ -1010,7 +998,7 @@ class ProvideCertificatePage:
try:
rhnreg.getCaps()
except up2dateErrors.SSLCertificateVerifyFailedError:
- server_url = up2dateConfig['serverURL']
+ server_url = config.getServerlURL()[0]
#TODO: we could point the user to grab the cert from /pub if its sat
#bz439383 - Handle error message for expired certificate
@@ -1090,14 +1078,11 @@ class AlreadyRegisteredDialog:
oldUsername = _('unknown')
systemId = _('unknown')
try:
- server = cfg['serverURL']
-
# If the serverURL config value is a list, we have no way of knowing
# for sure which one the machine registered against,
# so default to the
# first element.
- if type(server) == type([]):
- server = server[0]
+ server = config.getServerlURL()[0]
if server.endswith('/XMLRPC'):
server = server[:-7] # don't display trailing /XMLRPC
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
b/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
index 4e255b0..0af9a1c 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py
@@ -122,12 +122,7 @@ def getServer(refreshCallback=None):
else:
proxyHost = None
- serverUrls = cfg["serverURL"]
-
- # the standard is to be a string, so list-a-fy in that case
- if type(serverUrls) == type(""):
- serverUrls = [serverUrls]
-
+ serverUrls = config.getServerlURL()
serverList = ServerList(serverUrls)
proxyUser = None
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/tui.py
b/client/rhel/rhn-client-tools/src/up2date_client/tui.py
index 345ae37..d46be2f 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/tui.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/tui.py
@@ -80,7 +80,7 @@ def tui_call_wrapper(screen, func, *params):
try:
results = func(*params)
except up2dateErrors.CommunicationError, e:
- FatalErrorWindow(screen, HOSTED_CONNECTION_ERROR % cfg['serverURL'])
+ FatalErrorWindow(screen, HOSTED_CONNECTION_ERROR % config.getServerlURL()[0])
except up2dateErrors.SSLCertificateVerifyFailedError, e:
FatalErrorWindow(screen, e.errmsg)
except up2dateErrors.NoBaseChannelError, e:
@@ -1146,13 +1146,7 @@ class Tui:
ReviewWindow,
FinishWindow
]
-
- # if serverUrl is a list in the config, only reference the first one
- # when we need it
- if type(cfg['serverURL']) == type([]):
- self.serverURL = cfg['serverURL'][0]
- else:
- self.serverURL = cfg['serverURL']
+ self.serverURL = config.getServerlURL()[0]
if not cfg['sslCACert']:
# Always use the path from the cert if available, else set to
commit ec76ad0020625589b712a3744c6d96b5b5c80d14
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 24 15:37:53 2011 +0100
atomic save of /etc/sysconfig/rhn/up2date
if something bad happend during write to file (e.g. exceptions.UnicodeEncodeError) you
end up
with old file deleted and new is not created (or partialy created)
this will write config to /etc/sysconfig/rhn/up2date.new and only after successfull
write
it is renamed to /etc/sysconfig/rhn/up2date
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/config.py
b/client/rhel/rhn-client-tools/src/up2date_client/config.py
index 0c0330f..c4b78bd 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/config.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/config.py
@@ -140,7 +140,7 @@ class ConfigFile:
print _("%s was not found" % os.path.dirname(self.fileName))
return
- f = open(self.fileName, "w")
+ f = open(self.fileName+'.new', "w")
os.chmod(self.fileName, 0600)
f.write("# Automatically generated Red Hat Update Agent "\
@@ -156,6 +156,7 @@ class ConfigFile:
f.write("%s=%s\n" % (key, val[1]))
f.write("\n")
f.close()
+ os.rename(self.fileName+'.new', self.fileName)
# dictionary interface
def has_key(self, name):
commit 544e7f4d3f5afa0598fe8db72c165914e2beec1b
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Mar 22 23:09:43 2011 +0100
use xmlrpclib directly
diff --git a/backend/server/apacheRequest.py b/backend/server/apacheRequest.py
index 8888ddf..a2f288b 100644
--- a/backend/server/apacheRequest.py
+++ b/backend/server/apacheRequest.py
@@ -19,7 +19,7 @@
import sys
import base64
import string
-from rhn import rpclib
+import xmlrpclib
from rhn.rpclib import transports
# common modules
@@ -57,7 +57,7 @@ class apacheRequest:
# grab an Input object
self.input = transports.Input(req.headers_in)
# make sure we have a parser and a decoder available
- self.parser, self.decoder = rpclib.xmlrpclib.getparser()
+ self.parser, self.decoder = xmlrpclib.getparser()
# Make sure the decoder doesn't assume UTF-8 data, that would break if
# non-UTF-8 chars are sent (bug 139370)
self.decoder._encoding = None
@@ -99,7 +99,7 @@ class apacheRequest:
msg = open(CFG.MESSAGE_TO_ALL).read()
log_debug(3, "Sending message to all clients: %s" % msg)
# Send the message as a fault.
- response = rpclib.xmlrpclib.Fault(
+ response = xmlrpclib.Fault(
-1, _("IMPORTANT MESSAGE FOLLOWS:\n%s") % msg)
# and now send everything back
ret = self.response(response)
@@ -124,7 +124,7 @@ class apacheRequest:
if sys.exc_type == UnknownXML:
fault = -1
e_type, e_value = sys.exc_info()[:2]
- response = rpclib.xmlrpclib.Fault(fault, _(
+ response = xmlrpclib.Fault(fault, _(
"While running '%s': caught\n%s : %s\n") % (
method, e_type, e_value))
Traceback(method, self.req,
@@ -186,7 +186,7 @@ class apacheRequest:
# convert a response to the right type for passing back to
# rpclib.xmlrpclib.dumps
def normalize(self, response):
- if isinstance(response, rpclib.xmlrpclib.Fault):
+ if isinstance(response, xmlrpclib.Fault):
return response
return (response,)
@@ -307,7 +307,7 @@ class apacheRequest:
transfer=transports.lookupTransfer(self.input.transfer),
encoding=transports.lookupEncoding(self.input.encoding))
- if isinstance(response, rpclib.xmlrpclib.Fault):
+ if isinstance(response, xmlrpclib.Fault):
log_debug(4, "Return FAULT",
response.faultCode, response.faultString)
# No compression for faults because we'd like them to pop
@@ -330,7 +330,7 @@ class apacheRequest:
# Normalize the response
response = self.normalize(response)
try:
- response = rpclib.xmlrpclib.dumps(response, methodresponse = 1)
+ response = xmlrpclib.dumps(response, methodresponse = 1)
except TypeError, e:
log_debug(4, "Error \"%s\" encoding response = %s" %
(e, response))
Traceback("apacheHandler.response", self.req,
@@ -387,7 +387,7 @@ class apachePOST(apacheRequest):
self.parser.feed(data)
except IndexError:
# malformed XML data
- raise rpclib.xmlrpclib.ResponseError
+ raise xmlrpclib.ResponseError
self.parser.close()
# extract the method and arguments; we pass the exceptions through
@@ -461,7 +461,7 @@ class apachePOST(apacheRequest):
# Decode the request; avoid logging crappy responses
try:
params, method = self.decode(_body)
- except rpclib.xmlrpclib.ResponseError:
+ except xmlrpclib.ResponseError:
log_error("Got bad XML-RPC blob of len = %d" % len(_body))
return apache.HTTP_BAD_REQUEST
else:
@@ -569,7 +569,7 @@ class GetHandler(apacheRequest):
# since we have to stick the error message in the HTTP header,
# and to return an Apache error code
- if isinstance(response, rpclib.xmlrpclib.Fault):
+ if isinstance(response, xmlrpclib.Fault):
log_debug(4, "Return FAULT",
response.faultCode, response.faultString)
retcode = apache.HTTP_NOT_FOUND