backend/common/byterange.py | 3 backend/common/rhnCache.py | 7 + backend/common/rhnConfig.py | 6 - backend/common/rhnRepository.py | 3 backend/common/rhn_deb.py | 7 + backend/common/rhn_mpm.py | 14 +-- backend/satellite_exporter/handlers/non_auth_dumper.py | 13 +-- backend/satellite_exporter/satexport.py | 5 - backend/satellite_tools/disk_dumper/dumper.py | 5 - backend/satellite_tools/disk_dumper/iss.py | 40 +++++----- backend/satellite_tools/rhn_satellite_activate.py | 32 ++++---- backend/satellite_tools/satCerts.py | 9 +- backend/satellite_tools/satsync.py | 12 +-- backend/satellite_tools/syncLib.py | 2 backend/satellite_tools/sync_handlers.py | 3 backend/satellite_tools/xmlSource.py | 2 backend/satellite_tools/xmlWireSource.py | 3 backend/server/action/kickstart_guest.py | 7 + backend/server/action/kickstart_host.py | 8 +- backend/server/action/virt.py | 6 - backend/server/apacheRequest.py | 4 - backend/server/configFilesHandler.py | 15 ++- backend/server/handlers/app/packages.py | 9 +- backend/server/handlers/config_mgmt/rhn_config_management.py | 2 backend/server/handlers/xmlrpc/getMethod.py | 3 backend/server/handlers/xmlrpc/queue.py | 6 - backend/server/handlers/xmlrpc/registration.py | 18 ++-- backend/server/importlib/backend.py | 22 ++--- backend/server/importlib/userAuth.py | 4 - backend/server/rhnAuthPAM.py | 3 backend/server/rhnChannel.py | 25 +++--- backend/server/rhnPackage.py | 2 backend/server/rhnPackageUpload.py | 10 +- backend/server/rhnRepository.py | 7 + backend/server/rhnSQL/__init__.py | 2 backend/server/rhnSQL/driver_cx_Oracle.py | 36 ++++----- backend/server/rhnSQL/driver_postgresql.py | 7 + backend/server/rhnServer/satellite_cert.py | 3 backend/server/rhnServer/server_class.py | 7 + backend/server/rhnServer/server_hardware.py | 3 backend/server/rhnServer/server_packages.py | 3 backend/server/rhnServer/server_token.py | 13 +-- backend/server/rhnSession.py | 3 backend/server/rhnVirtualization.py | 5 - backend/server/test/TestServer.py | 4 - backend/spacewalk-backend.spec | 6 + client/rhel/rhn-client-tools/src/bin/rhn_check.py | 4 - client/rhel/rhn-client-tools/src/up2date_client/getMethod.py | 3 client/rhel/rhn-client-tools/src/up2date_client/rhncli.py | 2 client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py | 4 - client/rhel/rhn-client-tools/src/up2date_client/rhnserver.py | 6 - client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py | 20 ++--- client/rhel/rhnlib/rhn/rhnLockfile.py | 2 client/rhel/rhnlib/rhn/rpclib.py | 7 + client/rhel/yum-rhn-plugin/rhnplugin.py | 10 +- client/tools/osad/src/_ConfigParser.py | 17 +--- client/tools/osad/src/jabber_lib.py | 13 +-- client/tools/rhn-kickstart/rhnkickstart/common.py | 7 + client/tools/rhn-kickstart/rhnkickstart/kickstart_guest.py | 20 ++--- client/tools/rhn-virtualization/virtualization/domain_config.py | 9 +- client/tools/rhn-virtualization/virtualization/domain_control.py | 8 +- client/tools/rhn-virtualization/virtualization/localvdsm.py | 2 client/tools/rhn-virtualization/virtualization/poller.py | 2 client/tools/rhn-virtualization/virtualization/start_domain.py | 4 - client/tools/rhncfg/actions/ModeController.py | 3 client/tools/rhncfg/actions/Modes.py | 12 +-- client/tools/rhncfg/config_client/rpc_cli_repository.py | 4 - client/tools/rhncfg/config_common/repository.py | 4 - client/tools/rhncfg/config_common/rpc_wrapper.py | 5 - client/tools/rhncfg/config_common/transactions.py | 4 - client/tools/rhncfg/config_management/rhncfg_get.py | 9 +- client/tools/rhncfg/config_management/rhncfg_remove.py | 2 client/tools/rhncfg/config_management/rpc_repository.py | 35 ++++---- client/tools/rhnpush/connection.py | 5 - client/tools/rhnpush/rhnpush.py | 2 client/tools/rhnpush/rhnpush_cache.py | 3 client/tools/rhnpush/rhnpush_confmanager.py | 4 - client/tools/rhnpush/solaris2mpm.py | 4 - client/tools/rhnpush/test/testRhnpushCache.py | 3 client/tools/rhnpush/test/testUtils.py | 3 contrib/swapi.py | 2 proxy/proxy/broker/rhnRepository.py | 7 + proxy/proxy/pm/rhn_package_manager | 2 proxy/proxy/pm/uploadLib.py | 3 proxy/proxy/rhnAuthCacheClient.py | 9 +- proxy/proxy/rhnProxyAuth.py | 11 +- proxy/proxy/rhnShared.py | 7 + rel-eng/packages/spacewalk-backend | 2 rel-eng/packages/spacewalk-utils | 2 reporting/reports.py | 3 spacecmd/src/lib/misc.py | 2 utils/spacewalk-common-channels | 2 utils/spacewalk-utils.spec | 5 + 93 files changed, 361 insertions(+), 347 deletions(-)
New commits: commit cf3a67b6bbd65eaed8000661f0970efeebfb25dd Author: Miroslav Suchý msuchy@redhat.com Date: Thu Aug 11 13:50:23 2011 +0200
Automatic commit of package [spacewalk-backend] release [1.6.6-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec index e7c24c1..ae2c15f 100644 --- a/backend/spacewalk-backend.spec +++ b/backend/spacewalk-backend.spec @@ -11,7 +11,7 @@ Name: spacewalk-backend Summary: Common programs needed to be installed on the Spacewalk servers/proxies Group: Applications/Internet License: GPLv2 and Python -Version: 1.6.5 +Version: 1.6.6 Release: 1%{?dist} URL: https://fedorahosted.org/spacewalk Source0: https://fedorahosted.org/releases/s/p/spacewalk/%%7Bname%7D-%%7Bversion%7D.t... @@ -672,6 +672,10 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$ %changelog +* Thu Aug 11 2011 Miroslav Suchý 1.6.6-1 +- True and False constants are defined since python 2.4 +- do not mask original error by raise in execption + * Fri Aug 05 2011 Simon Lukasik slukasik@redhat.com 1.6.5-1 - 725637 - documentation should correspond with the behavior (slukasik@redhat.com) diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend index 31d714e..4089029 100644 --- a/rel-eng/packages/spacewalk-backend +++ b/rel-eng/packages/spacewalk-backend @@ -1 +1 @@ -1.6.5-1 backend/ +1.6.6-1 backend/
commit 3a22437953d956416347ac5fc941dd259d24ab18 Author: Miroslav Suchý msuchy@redhat.com Date: Thu Aug 11 13:50:03 2011 +0200
Automatic commit of package [spacewalk-utils] release [1.6.2-1].
diff --git a/rel-eng/packages/spacewalk-utils b/rel-eng/packages/spacewalk-utils index d2d2c35..f6b449f 100644 --- a/rel-eng/packages/spacewalk-utils +++ b/rel-eng/packages/spacewalk-utils @@ -1 +1 @@ -1.6.1-1 utils/ +1.6.2-1 utils/ diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec index ad2ad70..95289ca 100644 --- a/utils/spacewalk-utils.spec +++ b/utils/spacewalk-utils.spec @@ -1,7 +1,7 @@ %define rhnroot %{_prefix}/share/rhn
Name: spacewalk-utils -Version: 1.6.1 +Version: 1.6.2 Release: 1%{?dist} Summary: Utilities that may be run against a Spacewalk server.
@@ -69,6 +69,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog +* Thu Aug 11 2011 Miroslav Suchý 1.6.2-1 +- do not mask original error by raise in execption + * Thu Jul 21 2011 Jan Pazdziora 1.6.1-1 - Adding centos6 and fedora15 repos. (jonathan.hoser@helmholtz-muenchen.de)
commit 7143c8a131af1bd5150342b0d7332fddcc8cb7cd Author: Miroslav Suchý msuchy@redhat.com Date: Thu Aug 11 13:38:52 2011 +0200
True and False constants are defined since python 2.4
diff --git a/backend/server/test/TestServer.py b/backend/server/test/TestServer.py index 471a2ba..8f775e8 100644 --- a/backend/server/test/TestServer.py +++ b/backend/server/test/TestServer.py @@ -22,10 +22,6 @@ import server.xmlrpc.up2date from misc_functions import create_activation_key import misc_functions
-True = 1 -False = 0 - - #The Test Server class is a singleton. This allows us to avoid the long setup times between each test. class TestServer:
diff --git a/client/tools/osad/src/_ConfigParser.py b/client/tools/osad/src/_ConfigParser.py index 5b95106..04d2e90 100644 --- a/client/tools/osad/src/_ConfigParser.py +++ b/client/tools/osad/src/_ConfigParser.py @@ -104,10 +104,6 @@ import types import string import sys
-# Not available on python 1.5.2 -True = 1 -False = 0 - __all__ = ["NoSectionError","DuplicateSectionError","NoOptionError", "InterpolationError","InterpolationDepthError","ParsingError", "MissingSectionHeaderError","ConfigParser", diff --git a/client/tools/osad/src/jabber_lib.py b/client/tools/osad/src/jabber_lib.py index 324dde8..63514ef 100644 --- a/client/tools/osad/src/jabber_lib.py +++ b/client/tools/osad/src/jabber_lib.py @@ -29,11 +29,6 @@ from rhn import SSL
from rhn_log import log_debug, log_error
-try: - True, False -except NameError: - True, False = 1, 0 - NS_RHN = "http://jabber.rhn.redhat.com/jabber" NS_RHN_SIGNED = "%s/signed" % NS_RHN NS_RHN_PRESENCE_SUBSCRIBE = "%s/presence/subscribe" % NS_RHN diff --git a/client/tools/rhncfg/actions/ModeController.py b/client/tools/rhncfg/actions/ModeController.py index 1548175..ae6f7c1 100644 --- a/client/tools/rhncfg/actions/ModeController.py +++ b/client/tools/rhncfg/actions/ModeController.py @@ -16,9 +16,6 @@ import sys import string
-True = 1 -False = 0 - class ModeMissingException(Exception): pass
diff --git a/client/tools/rhncfg/actions/Modes.py b/client/tools/rhncfg/actions/Modes.py index eaae210..5d2dc81 100644 --- a/client/tools/rhncfg/actions/Modes.py +++ b/client/tools/rhncfg/actions/Modes.py @@ -15,10 +15,6 @@
import os
-#Forgot about AS 2.1. -True = 1 -False = 0 - #Base class for all modes. class BaseMode: def __init__(self): diff --git a/client/tools/rhnpush/rhnpush_cache.py b/client/tools/rhnpush/rhnpush_cache.py index 53e2136..608f340 100644 --- a/client/tools/rhnpush/rhnpush_cache.py +++ b/client/tools/rhnpush/rhnpush_cache.py @@ -25,9 +25,6 @@ import utils import os
-True = 1 -False = 0 - #This is the class that contains the session. class RHNPushSession: def __init__(self): diff --git a/client/tools/rhnpush/rhnpush_confmanager.py b/client/tools/rhnpush/rhnpush_confmanager.py index 9c72d82..2b9aa21 100644 --- a/client/tools/rhnpush/rhnpush_confmanager.py +++ b/client/tools/rhnpush/rhnpush_confmanager.py @@ -19,10 +19,6 @@ import string import sys import os
- -True = 1 -False = 0 - class ConfManager: def __init__(self, optionparser, store_true_list): sysdir = '/etc/sysconfig/rhn' diff --git a/client/tools/rhnpush/test/testRhnpushCache.py b/client/tools/rhnpush/test/testRhnpushCache.py index 4086212..7f46c10 100644 --- a/client/tools/rhnpush/test/testRhnpushCache.py +++ b/client/tools/rhnpush/test/testRhnpushCache.py @@ -17,9 +17,6 @@ import unittest import rhnpush_cache import time
-True = 1 -False = 0 - class UserInfoTestCase(unittest.TestCase): def setUp(self): self.userinfo = rhnpush_cache.UserInfo(5, username='wregglej', password='password') diff --git a/client/tools/rhnpush/test/testUtils.py b/client/tools/rhnpush/test/testUtils.py index d1cfbca..1d1bfa7 100644 --- a/client/tools/rhnpush/test/testUtils.py +++ b/client/tools/rhnpush/test/testUtils.py @@ -16,9 +16,6 @@ import unittest import utils
-True = 1 -False = 0 - class TestObj1: def __init__(self): self.a = 1
commit 86ec92b1c0221a9bb51e0f032f1800b349972036 Author: Miroslav Suchý msuchy@redhat.com Date: Thu Aug 11 13:30:52 2011 +0200
do not mask original error by raise in execption
From Jason email: In a nutshell, NEVER NEVER NEVER DO THIS:
try: .... # some work except: ... # possibly something else that doesn't include logging the traceback raise MyOwnExceptionClass('new message here')
We've pointed this out before, and I'm pointing it out again. THIS MASKS THE ORIGINAL ERROR! When trying to debug these, I usually feel like strangling someone.
We should either (1) log the current exception and traceback if we're actually handling the error (e.g. at the top level of the web services or in the pulp client), (2) re-raise the original error (e.g. useful for doing some local cleanup), or (3) concatenate the existing traceback to our new exception (e.g. when differentiating the error condition from an underlying standard library or third party exception).
Let me demonstrate the last two.
Re-raising the original error (2):
try: .... # some work except: .... # local clean up, logging, etc. raise
The last empty 'raise' statement will conveniently re-raise the caught exception.
Concatenating the existing traceback (3):
import sys
try: ... # some work except: ... # optional clean up, etc. raise PulpException('more meaningful error message'), None, sys.exc_info()[2]
The ', None, sys.exc_info()[2]' portion at the end of the new 'raise' statement will concatenate the exiting traceback to the traceback generated by the raise. This allows us to see the original point where something went wrong instead of hiding it beneath the new PulpException.
Note: it can be any exception, PulpException is just used as an example.
diff --git a/backend/common/byterange.py b/backend/common/byterange.py index dd4b3ef..0592020 100644 --- a/backend/common/byterange.py +++ b/backend/common/byterange.py @@ -15,6 +15,7 @@ #
import re +import sys
# common module from spacewalk.common.rhnLog import log_debug @@ -44,7 +45,7 @@ def parse_byteranges(byterange_header, file_size = None): start, end = map(_str2int, mo.groups()) except ValueError: # Invalid - raise InvalidByteRangeException + raise InvalidByteRangeException, None, sys.exc_info()[2] if start is not None: if start < 0: # Invalid diff --git a/backend/common/rhnCache.py b/backend/common/rhnCache.py index 73437c3..4370356 100644 --- a/backend/common/rhnCache.py +++ b/backend/common/rhnCache.py @@ -20,6 +20,7 @@ import os import gzip import cPickle import fcntl +import sys from struct import pack from stat import ST_MTIME from errno import EEXIST @@ -221,7 +222,7 @@ class WriteLockedFile(LockedFile): fd = _safe_create(self.fname, user, group, mode) except UnreadableFileError: raise OSError, "cache entry exists, but is not accessible: %s" % \ - name + name, sys.exc_info()[2]
# now we have the fd open, lock it _lock(fd) @@ -313,7 +314,7 @@ class CompressedCache: # Some gzip error # poking at gzip.zlib may not be such a good idea fd.close() - raise KeyError(name) + raise KeyError(name), None, sys.exc_info()[2] fd.close()
return value @@ -353,7 +354,7 @@ class ObjectCache: try: return cPickle.loads(pickled) except cPickle.UnpicklingError: - raise KeyError(name) + raise KeyError(name), None, sys.exc_info()[2]
def set(self, name, value, modified = None, user='root', group='root', \ mode=0755): diff --git a/backend/common/rhnConfig.py b/backend/common/rhnConfig.py index b948295..a8387a8 100644 --- a/backend/common/rhnConfig.py +++ b/backend/common/rhnConfig.py @@ -100,7 +100,7 @@ class RHNOptions: si = os.stat(self.filename) except OSError, e: raise ConfigParserError("config file read error", - self.filename, e.args[1]) + self.filename, e.args[1]), None, sys.exc_info()[2] lm = si[stat.ST_MTIME] # should always be positive, but a non-zero result is still # indication that the file has changed. @@ -571,7 +571,7 @@ def parse_file(filename, single_key = 0): (keys, values) = parse_line(line) except: raise ConfigParserError("Parse Error: <%s:%s>: '%s'" % ( - filename, lineno, line)) + filename, lineno, line)), None, sys.exc_info()[2] if keys is None: # We don't care about this line continue # now process the parsed line @@ -612,7 +612,7 @@ def read_file(filename): combined = combined + line.replace('\\n', ' ') return new_lines except (IOError, OSError), e: - raise ConfigParserError("Can not read config file", filename, e.args[1]) + raise ConfigParserError("Can not read config file", filename, e.args[1]), None, sys.exc_info()[2]
def getAllComponents_tree(defaultDir=None): diff --git a/backend/common/rhnRepository.py b/backend/common/rhnRepository.py index e8bcf84..704590c 100644 --- a/backend/common/rhnRepository.py +++ b/backend/common/rhnRepository.py @@ -18,6 +18,7 @@ import os import stat import types import cStringIO +import sys from rhn import rpclib
from spacewalk.common import rhn_rpm @@ -168,7 +169,7 @@ class Repository(RPC_Base): s = os.stat(filePath) except: raise rhnFault(17, "Unable to read package %s" - % os.path.basename(filePath)) + % os.path.basename(filePath)), None, sys.exc_info()[2]
lastModified = s[stat.ST_MTIME] del s # XXX: not neccessary? diff --git a/backend/common/rhn_deb.py b/backend/common/rhn_deb.py index c460d1c..7daea15 100644 --- a/backend/common/rhn_deb.py +++ b/backend/common/rhn_deb.py @@ -21,6 +21,7 @@
import os import gzip +import sys
from debian import debfile
@@ -61,7 +62,7 @@ def load_deb(stream, filename): #header = rhn_deb.get_package_header(file=stream) header = deb_Header(filename) except: - raise InvalidPackageError + raise InvalidPackageError, None, sys.exc_info()[2] stream.seek(0, 0)
return header, stream @@ -82,7 +83,7 @@ class deb_Header: try: self.deb = debfile.DebFile(name) except Exception, e: - raise InvalidPackageError(e) + raise InvalidPackageError(e), None, sys.exc_info()[2]
try: # Fill info about package @@ -97,7 +98,7 @@ class deb_Header: self.version = version_tmpArr[0] self.release = version_tmpArr[1] except Exception, e: - raise InvalidPackageError(e) + raise InvalidPackageError(e), None, sys.exc_info()[2]
def checksum_type(self): return DEB_CHECKSUM_TYPE diff --git a/backend/common/rhn_mpm.py b/backend/common/rhn_mpm.py index e2ef742..cb06f5f 100644 --- a/backend/common/rhn_mpm.py +++ b/backend/common/rhn_mpm.py @@ -18,8 +18,8 @@ import gzip import cStringIO import tempfile import xmlrpclib - import struct +import sys
from types import ListType, TupleType
@@ -57,9 +57,9 @@ def load(filename=None, file=None, fd=None): try: return load_rpm(f) except InvalidPackageError: - raise e + raise e, None, sys.exc_info()[2] except: - raise e + raise e, None, sys.exc_info()[2]
return p.header, p.payload_stream
@@ -69,7 +69,7 @@ def load_rpm(stream): try: import rhn_rpm except ImportError: - raise InvalidPackageError + raise InvalidPackageError, None, sys.exc_info()[2]
# Dup the file descriptor, we don't want it to get closed before we read # the payload @@ -82,11 +82,11 @@ def load_rpm(stream): try: header = rhn_rpm.get_package_header(file=stream) except rhn_rpm.InvalidPackageError, e: - raise apply(InvalidPackageError, e.args) + raise InvalidPackageError(*e.args), None, sys.exc_info()[2] except rhn_rpm.error, e: - raise InvalidPackageError(e) + raise InvalidPackageError(e), None, sys.exc_info()[2] except: - raise InvalidPackageError + raise InvalidPackageError, None, sys.exc_info()[2] stream.seek(0, 0)
return header, stream diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py b/backend/satellite_exporter/handlers/non_auth_dumper.py index 9f53cbf..0205c74 100644 --- a/backend/satellite_exporter/handlers/non_auth_dumper.py +++ b/backend/satellite_exporter/handlers/non_auth_dumper.py @@ -19,6 +19,7 @@ Non-authenticated dumper import os import xmlrpclib import gzip +import sys
from rhn.UserDictCase import UserDictCase from spacewalk.common.rhnLog import log_debug, log_error @@ -131,7 +132,7 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_Dumper): except IOError: log_error("Client appears to have closed connection") self.close() - raise dumper.ClosedConnectionError + raise dumper.ClosedConnectionError, None, sys.exc_info()[2] log_debug(5, "Bytes sent", len(data))
write = send @@ -417,15 +418,15 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_Dumper): return _get_path_from_cursor(h) except InvalidPackageError: log_debug(4, "Error", "Non-existent package requested", fileName) - raise rhnFault(17, _("Invalid RPM package %s requested") % fileName) + raise rhnFault(17, _("Invalid RPM package %s requested") % fileName), None, sys.exc_info()[2] except NullPathPackageError, e: package_id = e[0] log_error("Package path null for package id", package_id) - raise rhnFault(17, _("Invalid RPM package %s requested") % fileName) + raise rhnFault(17, _("Invalid RPM package %s requested") % fileName), None, sys.exc_info()[2] except MissingPackageError, e: filePath = e[0] log_error("Package not found", filePath) - raise rhnFault(17, _("Package not found")) + raise rhnFault(17, _("Package not found")), None, sys.exc_info()[2]
@@ -435,7 +436,7 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_Dumper): stream = open(path) except IOError, e: if e.errno == 2: - raise rhnFault(3007, "Missing file %s" % path) + raise rhnFault(3007, "Missing file %s" % path), None, sys.exc_info()[2] # Let it flow so we can find it later raise
@@ -462,7 +463,7 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_Dumper): # client closed the connection? log_error("Client appears to have closed connection") self.close_rpm() - raise dumper.ClosedConnectionError + raise dumper.ClosedConnectionError, None, sys.exc_info()[2] self.close_rpm()
def close_rpm(self): diff --git a/backend/satellite_exporter/satexport.py b/backend/satellite_exporter/satexport.py index f83ecfa..0f7faf1 100644 --- a/backend/satellite_exporter/satexport.py +++ b/backend/satellite_exporter/satexport.py @@ -15,6 +15,7 @@ # Server-side uploading code
import time +import sys import xmlrpclib from spacewalk.common import apache
@@ -223,14 +224,14 @@ class ApacheServer(BaseApacheServer): client_major = int(client_major) client_minor = int(client_minor) except ValueError: - raise rhnFault(3011, "Invalid version string %s" % client_version) + raise rhnFault(3011, "Invalid version string %s" % client_version), None, sys.exc_info()[2]
try: server_major = int(server_major) server_minor = int(server_minor) except ValueError: raise rhnException("Invalid server version string %s" - % server_version) + % server_version), None, sys.exc_info()[2]
if client_major != server_major: raise rhnFault(3012, "Client version %s does not match" diff --git a/backend/satellite_tools/disk_dumper/dumper.py b/backend/satellite_tools/disk_dumper/dumper.py index a7eaeea..7927bbd 100644 --- a/backend/satellite_tools/disk_dumper/dumper.py +++ b/backend/satellite_tools/disk_dumper/dumper.py @@ -15,6 +15,7 @@
import time import gzip +import sys import tempfile from types import ListType from cStringIO import StringIO @@ -263,7 +264,7 @@ class XML_Dumper: except IOError: log_error("Client disconnected prematurely") self.close() - raise ClosedConnectionError + raise ClosedConnectionError, None, sys.exc_info()[2] # We're done if open_stream: self._raw_stream.close() @@ -342,7 +343,7 @@ class XML_Dumper: try: id = int(name[prefix_len:]) except ValueError: - raise rhnFault(errnum, errmsg % name) + raise rhnFault(errnum, errmsg % name), None, sys.exc_info()[2] return id
def _packages(self, packages, prefix, dump_class, sources=0, diff --git a/backend/satellite_tools/disk_dumper/iss.py b/backend/satellite_tools/disk_dumper/iss.py index 429d062..22aac29 100644 --- a/backend/satellite_tools/disk_dumper/iss.py +++ b/backend/satellite_tools/disk_dumper/iss.py @@ -237,7 +237,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting channel info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting channel info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
###BINARY RPM INFO### try: @@ -272,7 +272,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting binary rpm info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting binary rpm info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
###PACKAGE INFO### #This will grab channel package information for a given channel. @@ -316,7 +316,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting package info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting package info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
###SOURCE PACKAGE INFO### try: @@ -351,7 +351,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting source package info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting source package info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
###ERRATA INFO### try: @@ -390,7 +390,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting errata info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting errata info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
###KICKSTART DATA/TREES INFO### try: @@ -427,7 +427,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting kickstart data info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting kickstart data info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
###KICKSTART FILES INFO### try: @@ -469,7 +469,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught while getting kickstart files info." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught while getting kickstart files info." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
#The close method overrides the parent classes close method. This implementation #closes the self.outstream, which is an addition defined in this subclass. @@ -516,7 +516,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError(exceptmsg % e.__class__.__name__, tbout.getvalue()) + raise ISSError(exceptmsg % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_arches(self): self._dump_simple(self.fm.getArchesFile(), dumper.XML_Dumper.dump_arches, @@ -585,7 +585,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_channels." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_channels." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_channel_packages_short(self): try: @@ -598,7 +598,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_channel_packages_short." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_channel_packages_short." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_packages(self): try: @@ -627,7 +627,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_packages." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_packages." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_packages_short(self): try: @@ -654,7 +654,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_packages_short." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_packages_short." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_source_packages(self): try: @@ -666,7 +666,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_source_packages." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_source_packages." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_errata(self): try: @@ -694,7 +694,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_errata." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_errata." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_kickstart_data(self): try: @@ -720,7 +720,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_kickstart_data." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_kickstart_data." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def dump_kickstart_files(self): try: @@ -765,7 +765,7 @@ class Dumper(dumper.XML_Dumper): except IOError, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("Error: Error copying file: %s: %s" % (path_to_files, e.__class__.__name__), tbout.getvalue()) + raise ISSError("Error: Error copying file: %s: %s" % (path_to_files, e.__class__.__name__), tbout.getvalue()), None, sys.exc_info()[2]
log2email(5, "Kickstart File: %s" % os.path.join(kickstart_file['base-path'], kickstart_file['relative-path']))
@@ -779,7 +779,7 @@ class Dumper(dumper.XML_Dumper): except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_kickstart_files." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_kickstart_files." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
#RPM and SRPM dumping code def dump_rpms(self): @@ -822,12 +822,12 @@ class Dumper(dumper.XML_Dumper): except IOError, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("Error: Error copying file %s: %s" % (os.path.join(CFG.MOUNT_POINT, rpm['path']), e.__class__.__name__), tbout.getvalue()) + raise ISSError("Error: Error copying file %s: %s" % (os.path.join(CFG.MOUNT_POINT, rpm['path']), e.__class__.__name__), tbout.getvalue()), None, sys.exc_info()[2] except OSError, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) raise ISSError("Error: Could not make hard link %s: %s (different filesystems?)" % (os.path.join(CFG.MOUNT_POINT, rpm['path']), -e.__class__.__name__), tbout.getvalue()) +e.__class__.__name__), tbout.getvalue()), None, sys.exc_info()[2] log2email(5, "RPM: %s" % rpm['path'])
pb.addTo(1) @@ -840,7 +840,7 @@ e.__class__.__name__), tbout.getvalue()) except Exception, e: tbout = cStringIO.StringIO() Traceback(mail=0, ostream=tbout, with_locals=1) - raise ISSError("%s caught in dump_rpms." % e.__class__.__name__, tbout.getvalue()) + raise ISSError("%s caught in dump_rpms." % e.__class__.__name__, tbout.getvalue()), None, sys.exc_info()[2]
def get_report(): body = dumpEMAIL_LOG() diff --git a/backend/satellite_tools/rhn_satellite_activate.py b/backend/satellite_tools/rhn_satellite_activate.py index eee7910..2547be8 100644 --- a/backend/satellite_tools/rhn_satellite_activate.py +++ b/backend/satellite_tools/rhn_satellite_activate.py @@ -200,25 +200,25 @@ def activateSatellite_local(options): except satellite_cert.ParseException: raise RHNCertLocalActivationException( 'RHN Entitlement Certificate failed to validate - ' - 'failed sanity parse.') + 'failed sanity parse.'), None, sys.exc_info()[2] except satCerts.CertGenerationMismatchError: raise RHNCertLocalActivationException( 'RHN Entitlement Certificate cannot be imported - ' - 'mismatching generation.') + 'mismatching generation.'), None, sys.exc_info()[2] except satCerts.CertVersionMismatchError, e: raise RHNCertLocalActivationException( 'RHN Entitlement Certificate cannot be imported - ' + str(e) \ + '\nIf you are trying to upgrade the Satellite server, please see the upgrade documentation ' + \ 'located here /etc/sysconfig/rhn/satellite-upgrade/README (as part of the rhn-upgrade package). ' + \ 'WARNING: If you want to skip this check, please use --ignore-version-mismatch, but doing so may cause issues ' + \ - '(including malfunction of the Satellite software). Only skip the test if instructed to do so by a support technician.') + '(including malfunction of the Satellite software). Only skip the test if instructed to do so by a support technician.'), None, sys.exc_info()[2] except satCerts.NoFreeEntitlementsError, e: sys.stderr.write(e.message + '\n') sys.exit(1) except Exception: raise RHNCertLocalActivationException( 'RHN Entitlement Certificate failed to validate: \n' - '%s' % rhnTB.fetchTraceback()) + '%s' % rhnTB.fetchTraceback()), None, sys.exc_info()[2]
return 0
@@ -293,7 +293,7 @@ def activateSatellite_remote(options): if abs(f.faultCode) != 1025: sys.stderr.write('ERROR: unhandled XMLRPC fault upon ' 'remote deactivation (reraising): %s\n' % f) - raise RHNCertRemoteActivationException('%s' % f) + raise RHNCertRemoteActivationException('%s' % f), None, sys.exc_info()[2]
no_sat_chan_for_version = 'no_sat_for_version' no_sat_chan_for_version1 = "Unhandled exception 'no_sat_chan_for_version' (unhandled_named_exception)" @@ -313,7 +313,7 @@ def activateSatellite_remote(options): sys.stderr.write( 'ERROR: error upon attempt to activate this %s\n' 'against the RHN hosted service.\n\n%s\n' % (PRODUCT_NAME, f)) - raise RHNCertRemoteActivationException('%s' % f) + raise RHNCertRemoteActivationException('%s' % f), None, sys.exc_info()[2]
if not oldApiYN \ and (abs(f.faultCode) in range(1020, 1039+1) @@ -322,54 +322,54 @@ def activateSatellite_remote(options): if abs(f.faultCode) == 1020: # 1020 results in "no_management_slots" print "NOTE: no management slots found on the hosted account." - raise RHNCertRemoteNoManagementSlotsException('%s' % f) + raise RHNCertRemoteNoManagementSlotsException('%s' % f), None, sys.exc_info()[2] elif abs(f.faultCode) == 1021: # 1021 results in "satellite_already_activated" # This shouldn't happen anymore (we deactivate prior to this step). print "NOTE: this %s is already activated - deactivate on the website and try again." % PRODUCT_NAME - raise RHNCertRemoteSatelliteAlreadyActivatedException('%s' % f) + raise RHNCertRemoteSatelliteAlreadyActivatedException('%s' % f), None, sys.exc_info()[2] elif abs(f.faultCode) == 1022: # 1022 results in "no_access_to_sat_channel" print "NOTE: hosted RHN reports 'no_access_to_sat_channel'." - raise RHNCertRemoteNoAccessToSatChannelException('%s' % f) + raise RHNCertRemoteNoAccessToSatChannelException('%s' % f), None, sys.exc_info()[2] elif abs(f.faultCode) == 1023: # 1023 results in "insufficient_channel_entitlements" print "NOTE: hosted RHN reports 'insufficient_channel_entitlements'." - raise RHNCertRemoteInsufficientChannelEntitlementsException('%s' % f) + raise RHNCertRemoteInsufficientChannelEntitlementsException('%s' % f), None, sys.exc_info()[2] elif abs(f.faultCode) == 1024: # 1024 results in "invalid_sat_certificate" print "NOTE: hosted RHN reports 'invalid_sat_certificate'." - raise RHNCertRemoteInvalidSatCertificateException('%s' % f) + raise RHNCertRemoteInvalidSatCertificateException('%s' % f), None, sys.exc_info()[2] elif abs(f.faultCode) == 1025: # 1025 results in "satellite_not_activated" print """\ NOTE: hosted RHN reports 'satellite_not_activated'. This is an odd fault that indicates an odd state - deactivate on the website and try again.""" - raise RHNCertRemoteSatelliteNotActivatedException('%s' % f) + raise RHNCertRemoteSatelliteNotActivatedException('%s' % f), None, sys.exc_info()[2] elif abs(f.faultCode) == 1026: # 1026 results in "satellite_no_base_channel" print """\ NOTE: hosted RHN reports 'satellite_no_base_channel'. This system is not entitled to a base channel in your RHN account.""" - raise RHNCertRemoteSatelliteNoBaseChannelException('%s' % f) + raise RHNCertRemoteSatelliteNoBaseChannelException('%s' % f), None, sys.exc_info()[2] elif f.faultString in (no_sat_chan_for_version, no_sat_chan_for_version1): print """\ NOTE: hosted RHN reports 'no_sat_chan_for_version'. This system does not have access to a channel that corresponds to the version of RHN certificate used to attempted activation.""" - raise RHNCertNoSatChanForVersion('%s' % f) + raise RHNCertNoSatChanForVersion('%s' % f), None, sys.exc_info()[2]
# other errors [1027, ..., 1039]: sys.stderr.write( 'ERROR: error upon attempt to activate this %s\n' 'against the RHN hosted service.\n\n%s\n' % (PRODUCT_NAME, f)) - raise RHNCertRemoteActivationException('%s' % f) + raise RHNCertRemoteActivationException('%s' % f), None, sys.exc_info()[2]
# still in except: section. Need to raise unhandled. sys.stderr.write('ERROR: unhandled XMLRPC fault upon ' 'remote activation: %s\n' % f) - raise RHNCertRemoteActivationException('%s' % f) + raise RHNCertRemoteActivationException('%s' % f), None, sys.exc_info()[2]
return ret
diff --git a/backend/satellite_tools/satCerts.py b/backend/satellite_tools/satCerts.py index 2a61f81..2a66d34 100644 --- a/backend/satellite_tools/satCerts.py +++ b/backend/satellite_tools/satCerts.py @@ -21,6 +21,7 @@ from string import strip from time import strftime, strptime import os +import sys
## other rhn imports from spacewalk.server import rhnSQL @@ -196,7 +197,7 @@ def set_slots_from_cert(cert): except rhnSQL.sql_base.SQLSchemaError, e: if e[0] == 20290: free_count = sys_ent_counts[(db_label, 1)] - quantity - raise NoFreeEntitlementsError(db_label, free_count) + raise NoFreeEntitlementsError(db_label, free_count), None, sys.exc_info()[2] else: raise
@@ -461,7 +462,7 @@ def _lobUpdate_rhnCryptoKey(rhn_cryptokey_id, caCert): except: # didn't go in! raise CaCertInsertionError("ERROR: CA certificate failed to be " - "inserted into the database") + "inserted into the database"), None, sys.exc_info()[2]
def store_rhnCryptoKey(description, caCert, verbosity=0): @@ -493,7 +494,7 @@ def store_rhnCryptoKey(description, caCert, verbosity=0): rhnSQL.commit() except rhnSQL.sql_base.SQLError: raise CaCertInsertionError( - "...the traceback: %s" % fetchTraceback()) + "...the traceback: %s" % fetchTraceback()), None, sys.exc_info()[2]
_querySelectCryptoCertInfo = rhnSQL.Statement(""" @@ -550,7 +551,7 @@ def create_first_private_chan_family(): org=1, url='First Org Created') except rhnSQL.SQLError, e: # if we're here that means we're voilating something - raise e + raise
def verify_family_permissions(orgid=1): diff --git a/backend/satellite_tools/satsync.py b/backend/satellite_tools/satsync.py index 206b4e2..d6ba3a7 100644 --- a/backend/satellite_tools/satsync.py +++ b/backend/satellite_tools/satsync.py @@ -453,7 +453,7 @@ class Syncer: and os.access(self._systemidPath, os.R_OK)): self.systemid = open(self._systemidPath, 'rb').read() else: - raise RhnSyncException, _('ERROR: this server must be registered with RHN.') + raise RhnSyncException, _('ERROR: this server must be registered with RHN.'), sys.exc_info()[2] # authorization check of the satellite auth = xmlWireSource.AuthWireSource(self.systemid, self.sslYN, self.xml_dump_version) @@ -525,7 +525,7 @@ class Syncer: cert = open(self.rhn_cert).read() except IOError, e: raise RhnSyncException(_("Unable to open file %s: %s") % ( - self.rhn_cert, e)) + self.rhn_cert, e)), None, sys.exc_info()[2] cert = string.strip(cert) else: # Try to retrieve the certificate from the database @@ -553,7 +553,7 @@ class Syncer: sat_cert.load(cert) except satellite_cert.ParseException: # XXX figure out what to do - raise RhnSyncException(_("Error parsing the satellite cert")) + raise RhnSyncException(_("Error parsing the satellite cert")), None, sys.exc_info()[2]
# Compare certificate generation - should match the stream's generation = rhnFlags.get('stream-generation') @@ -682,7 +682,7 @@ Please contact your RHN representative""") % (generation, sat_cert.generation))
except InvalidChannelFamilyError: raise RhnSyncException(messages.invalid_channel_family_error % - string.join(requested_channels)) + string.join(requested_channels)), None, sys.exc_info()[2] except MissingParentChannelError: raise
@@ -2187,7 +2187,7 @@ def processCommandline(): try: debugLevel = int(OPTIONS.debug_level) if not (0 <= debugLevel <= debugRange): - raise RhnSyncException, "exception will be caught" + raise RhnSyncException, "exception will be caught", sys.exc_info()[2] except KeyboardInterrupt, e: raise except: @@ -2321,7 +2321,7 @@ def processCommandline(): except (ValueError, TypeError): # int(None) --> TypeError # int('a') --> ValueError - raise ValueError(_("ERROR: --batch-size must have a value within the range: 1..50")) + raise ValueError(_("ERROR: --batch-size must have a value within the range: 1..50")), None, sys.exc_info()[2]
OPTIONS.mount_point = fileutils.cleanupAbsPath(OPTIONS.mount_point) OPTIONS.rhn_cert = fileutils.cleanupAbsPath(OPTIONS.rhn_cert) diff --git a/backend/satellite_tools/syncLib.py b/backend/satellite_tools/syncLib.py index b5a15ff..b60fc97 100644 --- a/backend/satellite_tools/syncLib.py +++ b/backend/satellite_tools/syncLib.py @@ -214,7 +214,7 @@ class FileManip: os.unlink(self.full_path) except: pass - raise FileCreationError(msg) + raise FileCreationError(msg), None, sys.exc_info()[2] l_file_size = fout.tell() fout.close()
diff --git a/backend/satellite_tools/sync_handlers.py b/backend/satellite_tools/sync_handlers.py index 55bddd6..d7dc709 100644 --- a/backend/satellite_tools/sync_handlers.py +++ b/backend/satellite_tools/sync_handlers.py @@ -16,6 +16,7 @@
import types import string +import sys
from spacewalk.server import rhnSQL from spacewalk.server.importlib import channelImport, packageImport, errataImport, \ @@ -198,7 +199,7 @@ def import_channels(channels, orgid=None): try: timestamp = collection.get_channel_timestamp(c) except KeyError: - raise Exception, "Could not find channel %s" % c + raise Exception, "Could not find channel %s" % c, sys.exc_info()[2] c_obj = collection.get_channel(c, timestamp) if c_obj is None: raise Exception, "Channel not found in cache: %s" % c diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py index cac68ba..a7e07a7 100644 --- a/backend/satellite_tools/xmlSource.py +++ b/backend/satellite_tools/xmlSource.py @@ -153,7 +153,7 @@ class BaseDispatchHandler(ContentHandler, ErrorHandler): raise except Exception, e: log_debug(-1, 'ERROR (odd) upon container.batch=[] cleanup: %s' % e) - raise e + raise
# Interface with containers def set_container(self, obj): diff --git a/backend/satellite_tools/xmlWireSource.py b/backend/satellite_tools/xmlWireSource.py index 0eb6565..1cff3c7 100644 --- a/backend/satellite_tools/xmlWireSource.py +++ b/backend/satellite_tools/xmlWireSource.py @@ -173,7 +173,8 @@ class BaseWireSource: break # do not reraise this exception! if lastErrorMsg: - raise RhnSyncException, lastErrorMsg + raise RhnSyncException, lastErrorMsg, sys.exc_info()[2] + # Returns a stream # Should never be reached return stream
diff --git a/backend/server/action/kickstart_guest.py b/backend/server/action/kickstart_guest.py index 70358f9..2f84e06 100644 --- a/backend/server/action/kickstart_guest.py +++ b/backend/server/action/kickstart_guest.py @@ -12,6 +12,7 @@ # granted to use or replicate Red Hat trademarks that are incorporated # in this software or its documentation. # +import sys from spacewalk.common.rhnLog import log_debug from spacewalk.server import rhnSQL from spacewalk.server.rhnLib import InvalidAction, ShadowAction @@ -65,11 +66,11 @@ def schedule_virt_guest_pkg_install(server_id, action_id, dry_run=0): else: log_debug(4, "dry run requested") except NoActionInfo, nai: - raise InvalidAction(str(nai)) + raise InvalidAction(str(nai)), None, sys.exc_info()[2] except PackageNotFound, pnf: - raise InvalidAction(str(pnf)) + raise InvalidAction(str(pnf)), None, sys.exc_info()[2] except Exception, e: - raise InvalidAction(str(e)) + raise InvalidAction(str(e)), None, sys.exc_info()[2]
log_debug(3, "Completed scheduling install of rhn-virtualization-guest!") raise ShadowAction("Scheduled installation of RHN Virtualization Guest packages.") diff --git a/backend/server/action/kickstart_host.py b/backend/server/action/kickstart_host.py index b03cf43..6c926e3 100644 --- a/backend/server/action/kickstart_host.py +++ b/backend/server/action/kickstart_host.py @@ -13,7 +13,7 @@ # in this software or its documentation. #
- +import sys from spacewalk.common.rhnLog import log_debug from spacewalk.server.rhnLib import InvalidAction, ShadowAction from spacewalk.server.action.utils import SubscribedChannel,\ @@ -67,11 +67,11 @@ def schedule_virt_host_pkg_install(server_id, action_id, dry_run=0): else: log_debug(4, "dry run requested") except NoActionInfo, nai: - raise InvalidAction(str(nai)) + raise InvalidAction(str(nai)), None, sys.exc_info()[2] except PackageNotFound, pnf: - raise InvalidAction(str(pnf)) + raise InvalidAction(str(pnf)), None, sys.exc_info()[2] except Exception, e: - raise InvalidAction(str(e)) + raise InvalidAction(str(e)), None, sys.exc_info()[2]
log_debug(3, "Completed scheduling install of rhn-virtualization-host and osad!") raise ShadowAction("Scheduled installation of RHN Virtualization Host packages.") diff --git a/backend/server/action/virt.py b/backend/server/action/virt.py index d938cba..9d65141 100644 --- a/backend/server/action/virt.py +++ b/backend/server/action/virt.py @@ -13,7 +13,7 @@ # in this software or its documentation. #
- +import sys from spacewalk.common.rhnLog import log_debug from spacewalk.server import rhnSQL from spacewalk.server.rhnLib import InvalidAction @@ -160,9 +160,9 @@ def action(action_name, query, server_id, action_id, dry_run=0): try: uuid = _get_uuid(query, action_id) except NoRowFoundException: - raise InvalidAction("No %s actions found." % action_name.lower()) + raise InvalidAction("No %s actions found." % action_name.lower()), None, sys.exc_info()[2] except NoUUIDException: - raise InvalidAction("%s action %s has no uuid associated with it." % (action_name, str(action_id))) + raise InvalidAction("%s action %s has no uuid associated with it." % (action_name, str(action_id))), None, sys.exc_info()[2] return (uuid,)
def start(server_id, action_id, dry_run=0): diff --git a/backend/server/apacheRequest.py b/backend/server/apacheRequest.py index 218ac38..d396746 100644 --- a/backend/server/apacheRequest.py +++ b/backend/server/apacheRequest.py @@ -392,7 +392,7 @@ class apachePOST(apacheRequest): self.parser.feed(data) except IndexError: # malformed XML data - raise xmlrpclib.ResponseError + raise xmlrpclib.ResponseError, None, sys.exc_info()[2]
self.parser.close() # extract the method and arguments; we pass the exceptions through @@ -422,7 +422,7 @@ class apachePOST(apacheRequest): classname, funcname = string.split(method, '.', 1) except: raise UnknownXML("method '%s' doesn't have a class and function" % - (method,)) + (method,)), None, sys.exc_info()[2] if not classname or not funcname: raise UnknownXML(method)
diff --git a/backend/server/configFilesHandler.py b/backend/server/configFilesHandler.py index 739804e..f393a1d 100644 --- a/backend/server/configFilesHandler.py +++ b/backend/server/configFilesHandler.py @@ -19,6 +19,7 @@ import base64 import os import xmlrpclib +import sys
from spacewalk.common import rhnFlags from spacewalk.common.rhnLog import log_debug @@ -233,27 +234,27 @@ class ConfigFilesHandler(rhnHandler): except ConfigFilePathIncomplete, e: raise rhnFault(4015, "Full path of file '%s' must be specified" % e.file.get('path'), - explain=0) + explain=0), None, sys.exc_info()[2] except ConfigFileExistsError, e: raise rhnFault(4013, "File %s already uploaded" % e.file.get('path'), - explain=0) + explain=0), None, sys.exc_info()[2] except ConfigFileVersionMismatchError, e: raise rhnFault(4012, "File %s uploaded with a different " - "version" % e.file.get('path'), explain=0) + "version" % e.file.get('path'), explain=0), None, sys.exc_info()[2] except ConfigFileMissingDelimError, e: raise rhnFault(4008, "Delimiter not specified for file %s" % - e.file.get('path'), explain=0) + e.file.get('path'), explain=0), None, sys.exc_info()[2] except ConfigFileMissingContentError, e: raise rhnFault(4007, "No content sent for file %s" % - e.file.get('path'), explain=0) + e.file.get('path'), explain=0), None, sys.exc_info()[2] except ConfigFileExceedsQuota, e: raise rhnFault(4014, "File size of %s exceeds free quota space" % - e.file.get('path'), explain=0) + e.file.get('path'), explain=0), None, sys.exc_info()[2] except ConfigFileTooLargeError, e: raise rhnFault(4003, "File size of %s larger than %s bytes" % (e.file.get('path'), self._get_maximum_file_size()), - explain=0) + explain=0), None, sys.exc_info()[2]
rhnSQL.commit() diff --git a/backend/server/handlers/app/packages.py b/backend/server/handlers/app/packages.py index 6e15f59..b897c57 100644 --- a/backend/server/handlers/app/packages.py +++ b/backend/server/handlers/app/packages.py @@ -19,6 +19,7 @@
import os import string +import sys import tempfile from types import TupleType
@@ -393,9 +394,9 @@ class Packages(RPC_Base): try: importer.run() except IncompatibleArchError, e: - raise rhnFault(50, string.join(e.args), explain=0) + raise rhnFault(50, string.join(e.args), explain=0), None, sys.exc_info()[2] except InvalidChannelError, e: - raise rhnFault(50, str(e), explain=0) + raise rhnFault(50, str(e), explain=0), None, sys.exc_info()[2]
affected_channels = importer.affected_channels
@@ -433,9 +434,9 @@ class Packages(RPC_Base): org_id, force = rhnPackageUpload.authenticate_session( session, channels=channels, null_org=null_org, force=force) except rhnSession.InvalidSessionError: - raise rhnFault(33) + raise rhnFault(33), None, sys.exc_info()[2] except rhnSession.ExpiredSessionError: - raise rhnFault(34) + raise rhnFault(34), None, sys.exc_info()[2]
if is_source: ret = self._getSourcePackageChecksum(org_id, pkg_infos) diff --git a/backend/server/handlers/config_mgmt/rhn_config_management.py b/backend/server/handlers/config_mgmt/rhn_config_management.py index ae82c1a..b52a5ff 100644 --- a/backend/server/handlers/config_mgmt/rhn_config_management.py +++ b/backend/server/handlers/config_mgmt/rhn_config_management.py @@ -129,7 +129,7 @@ class ConfigManagement(configFilesHandler.ConfigFilesHandler): errno = e.args[0] if errno == 2292: raise rhnFault(4005, "Cannot remove non-empty channel %s" % - config_channel, explain=0) + config_channel, explain=0), None, sys.exc_info()[2] raise
log_debug(5, "Removed:", config_channel) diff --git a/backend/server/handlers/xmlrpc/getMethod.py b/backend/server/handlers/xmlrpc/getMethod.py index c17abdd..7a5eb20 100644 --- a/backend/server/handlers/xmlrpc/getMethod.py +++ b/backend/server/handlers/xmlrpc/getMethod.py @@ -22,6 +22,7 @@
import os import string +import sys from types import ClassType from distutils.sysconfig import get_python_lib
@@ -86,7 +87,7 @@ def getMethod(methodName, baseClass): try: actions = __import__(modulename) except ImportError: - raise GetMethodException("Could not import module %s" % modulename) + raise GetMethodException("Could not import module %s" % modulename), None, sys.exc_info()[2]
className = actions # Iterate through the list of components and try to load that specific diff --git a/backend/server/handlers/xmlrpc/queue.py b/backend/server/handlers/xmlrpc/queue.py index c28f011..4240d92 100644 --- a/backend/server/handlers/xmlrpc/queue.py +++ b/backend/server/handlers/xmlrpc/queue.py @@ -82,7 +82,7 @@ class Queue(rhnHandler): except getMethod.GetMethodException: Traceback("queue.get V2") raise EmptyAction("Could not get a valid method for %s" % ( - action['method'],)) + action['method'],)), None, sys.exc_info()[2] # Call the method result = method(self.server_id, action['id'], dry_run) if result is None: @@ -397,7 +397,7 @@ class Queue(rhnHandler): except ValueError: log_error("Invalid action_id", action_id) raise rhnFault(30, _("Invalid action value type %s (%s)") % - (action_id, type(action_id))) + (action_id, type(action_id))), None, sys.exc_info()[2] # Authenticate the system certificate self.auth_system(system_id) log_debug(1, self.server_id, action_id, result) @@ -510,7 +510,7 @@ class Queue(rhnHandler): except getMethod.GetMethodException: Traceback("queue.get V2") raise EmptyAction("Could not get a valid method for %s" % - action_type) + action_type), None, sys.exc_info()[2] # Call the method result = method(self.server_id, action_id, data=data) return result diff --git a/backend/server/handlers/xmlrpc/registration.py b/backend/server/handlers/xmlrpc/registration.py index 6f7f2e9..76a5b3d 100644 --- a/backend/server/handlers/xmlrpc/registration.py +++ b/backend/server/handlers/xmlrpc/registration.py @@ -165,7 +165,7 @@ class Registration(rhnHandler): try: org_id = int(str(org_id)) except ValueError: - raise rhnFault(30, _faultValueString(org_id, "org_id")) + raise rhnFault(30, _faultValueString(org_id, "org_id")), None, sys.exc_info()[2] else: org_id = org_password = None username, password = rhnUser.check_user_password(username, password) @@ -381,11 +381,11 @@ class Registration(rhnHandler): newserv.save(0, channel) except (rhnChannel.SubscriptionCountExceeded, rhnChannel.NoBaseChannelError), channel_error: - raise rhnFault(70) + raise rhnFault(70), None, sys.exc_info()[2] except rhnChannel.BaseChannelDeniedError, channel_error: - raise rhnFault(71) + raise rhnFault(71), None, sys.exc_info()[2] except server_lib.rhnSystemEntitlementException, e: - raise rhnFault(90) + raise rhnFault(90), None, sys.exc_info()[2]
# Process any kickstart data associated with this server # Do this before using/processing the token, as the @@ -420,12 +420,12 @@ class Registration(rhnHandler): newserv.save(1, channel) except (rhnChannel.SubscriptionCountExceeded, rhnChannel.NoBaseChannelError), channel_error: - raise rhnFault(70) + raise rhnFault(70), None, sys.exc_info()[2] except rhnChannel.BaseChannelDeniedError, channel_error: - raise rhnFault(71) + raise rhnFault(71), None, sys.exc_info()[2] except server_lib.rhnSystemEntitlementException, e: # right now, don't differentiate between general ent issues & rhnNoSystemEntitlementsException - raise rhnFault(90) + raise rhnFault(90), None, sys.exc_info()[2]
@@ -1339,11 +1339,11 @@ class Registration(rhnHandler): org_id=user.contact['org_id'], user_id=user.getid()) except rhnChannel.NoBaseChannelError: # ?? Invalid arch+release ?? - raise rhnFault(19) + raise rhnFault(19), None, sys.exc_info()[2] except rhnChannel.BaseChannelDeniedError: raise rhnFault(71, _("Insufficient subscription permissions for release, arch (%s, %s)") - % (release, arch)) + % (release, arch)), None, sys.exc_info()[2]
# we'll always have the info from the base channel, otherwise there diff --git a/backend/server/importlib/backend.py b/backend/server/importlib/backend.py index 06b094e..29e4f0f 100644 --- a/backend/server/importlib/backend.py +++ b/backend/server/importlib/backend.py @@ -18,6 +18,7 @@
import copy import string +import sys
from spacewalk.common import rhn_rpm from spacewalk.common.rhnConfig import CFG @@ -479,7 +480,6 @@ class Backend: raise TypeError("Expected an IncompletePackage instance, found %s" % \ str(type(package))) for package in packages: - exception = None for type, chksum in package['checksums'].iteritems(): package['checksum_type'] = type package['checksum'] = chksum @@ -489,10 +489,10 @@ class Backend: exception = None break except InvalidPackageError, e: - exception = e - if exception and not ignore_missing: - raise exception - + if ignore_missing: + pass + else: + raise
def lookupSolarisPackages(self, packages, ignore_missing=0): for pkg in packages: @@ -993,8 +993,8 @@ class Backend: activate_channel_entitlements(cfp['org_id'], cfp['channel_family'], cfp['max_members'], cfp['max_flex']) except rhnSQL.SQLError, e: - raise rhnFault(23, str(e[1]) + ": org_id [%s] family [%s] max [%s]" % \ - (cfp['org_id'], cfp['channel_family'], cfp['max_members']), explain=0) + raise rhnFault(23, str(e[1]) + ": org_id [%s] family [%s] max [%s]" % \ + (cfp['org_id'], cfp['channel_family'], cfp['max_members']), explain=0), None, sys.exc_info()[2]
# The way we constructed the list of channel family permissions, we # should have (at least) all of the permissions from the database in @@ -1255,7 +1255,7 @@ class Backend: try: refresh_newest_package(channel_id, caller) except rhnSQL.SQLError, e: - raise rhnFault(23, str(e[1]), explain=0) + raise rhnFault(23, str(e[1]), explain=0), None, sys.exc_info()[2] if deleted_packages_list: invalidate_ss = 1 else: @@ -1316,9 +1316,9 @@ class Backend: h.executemany(id=ids, value=values) except rhnSQL.SQLSchemaError, e: if e.errno == 01401: - raise ValueError, e.errmsg + raise ValueError, e.errmsg, sys.exc_info()[2] else: - raise rhnFault(30, e.errmsg, explain=0) + raise rhnFault(30, e.errmsg, explain=0), None, sys.exc_info()[2]
def __buildQueries(self, childTables): childTableLookups = {} @@ -1629,7 +1629,7 @@ class Backend: try: self.__doInsertTable(tname, dict) except rhnSQL.SQLError, e: - raise rhnFault(54, str(e[1]), explain=0) + raise rhnFault(54, str(e[1]), explain=0), None, sys.exc_info()[2]
def __doInsertTable(self, table, hash): if not hash: diff --git a/backend/server/importlib/userAuth.py b/backend/server/importlib/userAuth.py index 566fb17..fecd877 100644 --- a/backend/server/importlib/userAuth.py +++ b/backend/server/importlib/userAuth.py @@ -39,7 +39,7 @@ class UserAuth: # invalid login/password; set timeout to baffle # brute force password guessing attacks (BZ 672163) time.sleep(2) - raise e + raise
log_debug(4, "Groups: %s; org_id: %s; user_id: %s" % ( self.groups, self.org_id, self.user_id)) @@ -53,7 +53,7 @@ class UserAuth: # invalid login/password; set timeout to baffle # brute force password guessing attacks (BZ 672163) time.sleep(2) - raise e + raise
log_debug(4, "Groups: %s; org_id: %s; user_id: %s" % ( self.groups, self.org_id, self.user_id)) diff --git a/backend/server/rhnAuthPAM.py b/backend/server/rhnAuthPAM.py index 6c92cb0..fb54602 100644 --- a/backend/server/rhnAuthPAM.py +++ b/backend/server/rhnAuthPAM.py @@ -14,6 +14,7 @@ #
import PAM +import sys
from spacewalk.common.rhnLog import log_error from spacewalk.common.rhnException import rhnException @@ -61,7 +62,7 @@ def check_password(username, password, service): log_error("Password check failed (%s): %s" % (code, resp)) return 0 except: - raise rhnException('Internal PAM error') + raise rhnException('Internal PAM error'), None, sys.exc_info()[2] else: # Good password return 1 diff --git a/backend/server/rhnChannel.py b/backend/server/rhnChannel.py index d660731..d3bb81f 100644 --- a/backend/server/rhnChannel.py +++ b/backend/server/rhnChannel.py @@ -17,6 +17,7 @@ import time import string import rpm +import sys import xmlrpclib
from types import IntType, ListType, DictType @@ -102,7 +103,7 @@ class BaseDatabaseObject: try: self._row.save(with_updates=with_updates) except rhnSQL.ModifiedRowError: - raise ModifiedError(self._row['id']) + raise ModifiedError(self._row['id']), None, sys.exc_info()[2]
class BaseChannelObject(BaseDatabaseObject): @@ -626,7 +627,7 @@ def channels_for_server(server_id): try: server_id = int(server_id) except: - raise rhnFault(8, server_id) # Invalid rhnServer.id + raise rhnFault(8, server_id), None, sys.exc_info()[2] # Invalid rhnServer.id # XXX: need to return unsubsubcribed channels and a way to indicate # they arent already subscribed
@@ -724,14 +725,14 @@ def base_channel_for_rel_arch(release, server_arch, org_id=-1, if e.errno == 20263: # Insufficient permissions for subscription log_debug(4,'BaseChannelDeniedError') - raise BaseChannelDeniedError() + raise BaseChannelDeniedError(), None, sys.exc_info()[2] if e.errno == 20244: # Server architecture could not be found log_debug(4,'InvalidServerArchError') - raise InvalidServerArchError(str(server_arch)) + raise InvalidServerArchError(str(server_arch)), None, sys.exc_info()[2] # Re-raise unknown eceptions log_debug(4,'unkown exception') - raise e + raise
log_debug(4, 'got past exceptions') return h.fetchone_dict() @@ -1477,18 +1478,18 @@ def _subscribe_sql(server_id, channel_id, commit = 1): subscribe_channel(server_id, channel_id, 0) except rhnSQL.SQLSchemaError, e: if e.errno == 20235: # channel_family_no_subscriptions - raise SubscriptionCountExceeded(channel_id=channel_id) + raise SubscriptionCountExceeded(channel_id=channel_id), None, sys.exc_info()[2] if e.errno == 20102: # channel_server_one_base log_error("Channel subscribe failed, "\ "%s already subscribed to %s (?)" % (server_id, channel_id)) - raise rhnFault(38, "Server already subscribed to %s" % channel_id) + raise rhnFault(38, "Server already subscribed to %s" % channel_id), None, sys.exc_info()[2] # If we got here, it's an unknown error; ISE (for now) log_error("SQLSchemaError", e) - raise rhnException(e) + raise rhnException(e), None, sys.exc_info()[2] except rhnSQL.SQLError, e: # If we got here, it's an unknown error; ISE (for now) log_error("SQLError", e) - raise rhnException(e) + raise rhnException(e), None, sys.exc_info()[2] if commit: rhnSQL.commit() return 1 @@ -1502,7 +1503,7 @@ def subscribe_sql(server_id, channel_id, commit=1): except SubscriptionCountExceeded: log_error("Subscription count exceeded for channel id %s" % channel_id) - raise rhnFault(70, "Subscription count for the target channel exceeded") + raise rhnFault(70, "Subscription count for the target channel exceeded"), None, sys.exc_info()[2]
_query_can_subscribe = rhnSQL.Statement(""" @@ -1717,14 +1718,14 @@ def guess_channels_for_server(server, user_id=None, none_ok=0, "registration number, please register with it first at " "http://www.redhat.com/apps/activate/ and then try again.\n\n")
- raise rhnFault(19, msg % error_strings) + raise rhnFault(19, msg % error_strings), None, sys.exc_info()[2] except BaseChannelDeniedError: if none_ok: return []
raise rhnFault(71, _("Insufficient subscription permissions for release (%s, %s") - % (server.release, server.arch)) + % (server.release, server.arch)), None, sys.exc_info()[2]
# Subscribes the server to channels # can raise SubscriptionCountExceeded, BaseChannelDeniedError, NoBaseChannelError diff --git a/backend/server/rhnPackage.py b/backend/server/rhnPackage.py index 3413a86..db6e098 100644 --- a/backend/server/rhnPackage.py +++ b/backend/server/rhnPackage.py @@ -119,7 +119,7 @@ def unlink_package_file(path): if e.errno == 39: #OSError: [Errno 39] Directory not empty break else: - raise e + raise dirname = os.path.dirname(dirname)
# Old client diff --git a/backend/server/rhnPackageUpload.py b/backend/server/rhnPackageUpload.py index 5661287..c274fd5 100644 --- a/backend/server/rhnPackageUpload.py +++ b/backend/server/rhnPackageUpload.py @@ -140,11 +140,11 @@ def push_package(header, payload_stream, checksum_type, checksum, org_id=None, f importLib.copy_package(payload_stream.fileno(), basedir=CFG.MOUNT_POINT, relpath=relative_path, checksum_type=checksum_type, checksum=checksum, force=1) except OSError, e: - raise rhnFault(50, "Package upload failed: %s" % e) + raise rhnFault(50, "Package upload failed: %s" % e), None, sys.exc_info()[2] except importLib.FileConflictError: - raise rhnFault(50, "File already exists") + raise rhnFault(50, "File already exists"), None, sys.exc_info()[2] except: - raise rhnFault(50, "File error") + raise rhnFault(50, "File error"), None, sys.exc_info()[2]
pkg = mpmSource.create_package(header, size=payload_size, checksum_type=checksum_type, checksum=checksum, @@ -289,12 +289,12 @@ def load_package(package_stream): try: header, payload_stream = rhn_deb.load(filename=package_stream.name) except: - raise rhnFault(50, "Unable to load package", explain=0) + raise rhnFault(50, "Unable to load package", explain=0), None, sys.exc_info()[2] else: try: header, payload_stream = rhn_mpm.load(file=package_stream) except: - raise rhnFault(50, "Unable to load package", explain=0) + raise rhnFault(50, "Unable to load package", explain=0), None, sys.exc_info()[2]
payload_stream.seek(0, 0) if header.packaging == "mpm" or header.packaging == "deb": diff --git a/backend/server/rhnRepository.py b/backend/server/rhnRepository.py index a4868e0..81715cf 100644 --- a/backend/server/rhnRepository.py +++ b/backend/server/rhnRepository.py @@ -17,6 +17,7 @@ # system module imports import os import stat +import sys
from rhn import rpclib
@@ -231,8 +232,8 @@ class Repository(rhnRepository.Repository): "repodata request", file_name, bypass_filters=True) rhnSQL.commit() # This returns 404 to the client - raise rhnFault(6) - raise e + raise rhnFault(6), None, sys.exc_info()[2] + raise
def repodata(self, file_name): # By default we're using taskomatic's repomd. But if the config @@ -347,7 +348,7 @@ class Repository(rhnRepository.Repository): stat_info = os.stat(filePath) except: raise rhnFault(17, "Unable to read package %s" - % os.path.basename(filePath)) + % os.path.basename(filePath)), None, sys.exc_info()[2] lastModified = stat_info[stat.ST_MTIME]
# OK, file exists, check the cache diff --git a/backend/server/rhnSQL/__init__.py b/backend/server/rhnSQL/__init__.py index 8a56dff..6178e40 100644 --- a/backend/server/rhnSQL/__init__.py +++ b/backend/server/rhnSQL/__init__.py @@ -153,7 +153,7 @@ def __test_DB(): try: return __DB except NameError: - raise SystemError, "Not connected to any database!" + raise SystemError, "Not connected to any database!", sys.exc_info()[2]
# wrapper for a Procedure callable class def Procedure(name): diff --git a/backend/server/rhnSQL/driver_cx_Oracle.py b/backend/server/rhnSQL/driver_cx_Oracle.py index cf8b929..cce647a 100644 --- a/backend/server/rhnSQL/driver_cx_Oracle.py +++ b/backend/server/rhnSQL/driver_cx_Oracle.py @@ -62,8 +62,7 @@ class Cursor(sql_base.Cursor): (errno, errmsg) = e.errno, e.errmsg if 900 <= errno <= 999: # Per Oracle's documentation, SQL parsing error - args = (self.dbh, errmsg, self.sql) - raise apply(sql_base.SQLStatementPrepareError, args) + raise sql_base.SQLStatementPrepareError(self.dbh, errmsg, self.sql), None, sys.exc_info()[2] # XXX: we should be handling the lost connection cases # in here too, but we don't get that many of these and # besides, this is much harder to get right @@ -72,13 +71,13 @@ class Cursor(sql_base.Cursor): # the SQL code we just passed in since we're dealing with # an OracleError. I hope this is always the case, of not, # we'll have to log the sql code here - raise rhnException("Can not prepare statement", e.args) + raise rhnException("Can not prepare statement", e.args), None, sys.exc_info()[2]
def _prepare(self, force=None): try: return sql_base.Cursor._prepare(self, force) except self.OracleError, e: - raise self._build_exception(e) + raise self._build_exception(e), None, sys.exc_info()[2]
def _prepare_sql(self): cursor = self.dbh.cursor() @@ -110,23 +109,22 @@ class Cursor(sql_base.Cursor): except self.OracleError, e: ret = self._get_oracle_error_info(e) if isinstance(ret, types.StringType): - raise sql_base.SQLError(self.sql, p, kw, ret) + raise sql_base.SQLError(self.sql, p, kw, ret), None, sys.exc_info()[2] (errno, errmsg) = ret[:2] if 900 <= errno <= 999: # Per Oracle's documentation, SQL parsing error - args = (errno, errmsg, self.sql) - raise apply(sql_base.SQLStatementPrepareError, args) + raise sql_base.SQLStatementPrepareError(errno, errmsg, self.sql), None, sys.exc_info()[2] if errno == 1475: # statement needs to be reparsed; force a prepare again if self.reparsed: # useless, tried that already. give up log_error("Reparsing cursor did not fix it", self.sql) args = ("Reparsing tried and still got this",) + tuple(ret) - raise apply(sql_base.SQLError, args) + raise sql_base.SQLError(*args), None, sys.exc_info()[2] self._real_cursor = self.dbh.prepare(self.sql) self.reparsed = 1 apply(self._execute_wrapper, (function, ) + p, kw) elif 20000 <= errno <= 20999: # error codes we know we raise as schema errors - raise apply(sql_base.SQLSchemaError, ret) - raise apply(sql_base.SQLError, ret) + raise sql_base.SQLSchemaError(*ret), None, sys.exc_info()[2] + raise apply(sql_base.SQLError, ret), None, sys.exc_info()[2] except ValueError: # this is not good.Let the user know raise @@ -294,13 +292,13 @@ class Procedure(sql_base.Procedure): retval = self._call_proc(args) except cx_Oracle.DatabaseError, e: if not hasattr(e, "args"): - raise sql_base.SQLError(self.name, args) + raise sql_base.SQLError(self.name, args), None, sys.exc_info()[2] elif 20000 <= e[0].code <= 20999: # error codes we know we raise as schema errors
- raise apply(sql_base.SQLSchemaError, [e[0].code, str(e[0])]) - raise apply(sql_base.SQLError, [e[0].code, str(e[0])]) + raise sql_base.SQLSchemaError(e[0].code, str(e[0])), None, sys.exc_info()[2] + raise sql_base.SQLError(e[0].code, str(e[0])), None, sys.exc_info()[2] except cx_Oracle.NotSupportedError, error: - raise apply(sql_base.SQLError, error.args) + raise sql_base.SQLError(*error.args), None, sys.exc_info()[2] return retval
def _munge_args(self, args): @@ -392,7 +390,7 @@ class Database(sql_base.Database): ret = self._get_oracle_error_info(e) if isinstance(ret, types.StringType): raise sql_base.SQLConnectError(self.dbtxt, -1, - "Unable to connect to database", ret) + "Unable to connect to database", ret), None, sys.exc_info()[2] (errno, errmsg) = ret[:2] log_error("Connection attempt failed", errno, errmsg) if reconnect: @@ -403,11 +401,11 @@ class Database(sql_base.Database): return self.connect(reconnect=0) err_args = [self.dbtxt, errno, errmsg] err_args.extend(list(ret[2:])) - raise apply(sql_base.SQLConnectError, err_args) + raise sql_base.SQLConnectError(*err_args), None, sys.exc_info()[2] # else, this is a reconnect attempt raise apply(sql_base.SQLConnectError, [self.dbtxt, errno, errmsg, - "Attempting Re-Connect to the database failed", ] + ret[2:]) + "Attempting Re-Connect to the database failed", ] + ret[2:]), None, sys.exc_info()[2] dbh_id = id(self.dbh) # Reset the statement cache for this database connection self._cursor_class._cursor_cache[dbh_id] = {} @@ -475,7 +473,7 @@ class Database(sql_base.Database): c = self.dbh.cursor() except cx_Oracle.DatabaseError, error: e = error[0] - raise sql_base.SQLSchemaError(e.code, e.message, e.context) + raise sql_base.SQLSchemaError(e.code, e.message, e.context), None, sys.exc_info()[2] # Pass the cursor in so we can close it after execute() return self._procedure_class(name, c)
@@ -484,7 +482,7 @@ class Database(sql_base.Database): c = self.dbh.cursor() except cx_Oracle.DatabaseError, error: e = error[0] - raise sql_base.SQLSchemaError(e.code, e.message, e.context) + raise sql_base.SQLSchemaError(e.code, e.message, e.context), None, sys.exc_info()[2] return Function(name, c, ret_type)
# why would anybody need this?! diff --git a/backend/server/rhnSQL/driver_postgresql.py b/backend/server/rhnSQL/driver_postgresql.py index 1dfddea..b1fa2c4 100644 --- a/backend/server/rhnSQL/driver_postgresql.py +++ b/backend/server/rhnSQL/driver_postgresql.py @@ -163,8 +163,9 @@ class Database(sql_base.Database): return self.connect(reconnect=0)
# Failed reconnect, time to error out: - raise apply(sql_base.SQLConnectError, - [self.database, e.pgcode, e.pgerror, "Attempting Re-Connect to the database failed",]) + raise sql_base.SQLConnectError( + self.database, e.pgcode, e.pgerror, + "Attempting Re-Connect to the database failed"), None, sys.exc_info()[2]
def is_connected_to(self, backend, host, port, username, password, database): @@ -266,7 +267,7 @@ class Cursor(sql_base.Cursor): # TODO: Constructor for this exception expects a first arg of db, # and yet the Oracle driver passes it an errno? Suspect it's not # even used. - raise rhnSQL.SQLStatementPrepareError(0, str(e), self.sql) + raise rhnSQL.SQLStatementPrepareError(0, str(e), self.sql), None, sys.exc_info()[2] return retval
def _execute_(self, args, kwargs): diff --git a/backend/server/rhnServer/satellite_cert.py b/backend/server/rhnServer/satellite_cert.py index 90202b5..85bf6b3 100644 --- a/backend/server/rhnServer/satellite_cert.py +++ b/backend/server/rhnServer/satellite_cert.py @@ -18,6 +18,7 @@ #
import string +import sys from xml.dom.minidom import parseString from xml.sax import SAXParseException
@@ -129,7 +130,7 @@ class SatelliteCert: try: self._load(s) except SAXParseException: - raise ParseException + raise ParseException, None, sys.exc_info()[2] # Now represent the slots in a more meaningful way self._slots.clear() for slot_name, (slot_attr, factory) in self._slot_maps.items(): diff --git a/backend/server/rhnServer/server_class.py b/backend/server/rhnServer/server_class.py index bd9cc84..f07c49b 100644 --- a/backend/server/rhnServer/server_class.py +++ b/backend/server/rhnServer/server_class.py @@ -18,6 +18,7 @@ # system modules import time import string +import sys
from spacewalk.common import rhnFlags from spacewalk.common.rhnConfig import CFG @@ -426,17 +427,17 @@ class Server(ServerWrapper): # Should not normally happen log_error("Failed to entitle", self.server["id"], entitlement, e.errmsg) - raise server_lib.rhnSystemEntitlementException("Unable to entitle") + raise server_lib.rhnSystemEntitlementException("Unable to entitle"), None, sys.exc_info()[2] except rhnSQL.SQLError, e: log_error("Failed to entitle", self.server["id"], entitlement, str(e)) - raise server_lib.rhnSystemEntitlementException("Unable to entitle") + raise server_lib.rhnSystemEntitlementException("Unable to entitle"), None, sys.exc_info()[2] else: if any_base_entitlements: # All is fine return else: - raise server_lib.rhnNoSystemEntitlementsException + raise server_lib.rhnNoSystemEntitlementsException, None, sys.exc_info()[2]
def _entitle(self, entitlement): entitle_server = rhnSQL.Procedure("rhn_entitlements.entitle_server") diff --git a/backend/server/rhnServer/server_hardware.py b/backend/server/rhnServer/server_hardware.py index 4f69558..422a5d0 100644 --- a/backend/server/rhnServer/server_hardware.py +++ b/backend/server/rhnServer/server_hardware.py @@ -18,6 +18,7 @@ #
import string +import sys
from rhn.UserDictCase import UserDictCase from spacewalk.common.rhnLog import log_debug, log_error @@ -304,7 +305,7 @@ class Device(GenericDevice): self.data[k] = self.data[k][1:-1] except IndexError: raise IndexError, "Can not process data = %s, key = %s" % ( - repr(self.data), k) + repr(self.data), k), sys.exc_info()[2]
class HardwareDevice(Device): diff --git a/backend/server/rhnServer/server_packages.py b/backend/server/rhnServer/server_packages.py index 0d71a00..a738f34 100644 --- a/backend/server/rhnServer/server_packages.py +++ b/backend/server/rhnServer/server_packages.py @@ -18,6 +18,7 @@ #
import string +import sys import time from types import DictType
@@ -227,7 +228,7 @@ class Packages: # LOOKUP_PACKAGE_ARCH failed if e.errno == 20243: log_debug(2, "Unknown package arch found", e) - raise rhnFault(45, "Unknown package arch found") + raise rhnFault(45, "Unknown package arch found"), None, sys.exc_info()[2]
commits = commits + len(alist) del alist diff --git a/backend/server/rhnServer/server_token.py b/backend/server/rhnServer/server_token.py index c585601..29bbcb0 100644 --- a/backend/server/rhnServer/server_token.py +++ b/backend/server/rhnServer/server_token.py @@ -16,6 +16,7 @@ #
import string +import sys
from cStringIO import StringIO
@@ -203,7 +204,7 @@ def token_server_groups(server_id, tokens_obj): log_error("Failed to add server to group", server_id, server_group_id, sg["name"]) raise rhnFault(80, _("Failed to add server to group %s") % - sg["name"]) + sg["name"]), None, sys.exc_info()[2] else: ret.append("Subscribed to server group '%s'" % sg["name"]) return ret @@ -641,13 +642,13 @@ class ActivationTokens: #ORA-20220: (servergroup_max_members) - Server group membership #cannot exceed maximum membership raise rhnFault(91, - _("Registration failed: RHN Software Management service entitlements exhausted")) + _("Registration failed: RHN Software Management service entitlements exhausted")), None, sys.exc_info()[2] #No idea what error may be here... - raise rhnFault(90, e.errmsg) + raise rhnFault(90, e.errmsg), None, sys.exc_info()[2] except rhnSQL.SQLError, e: log_error("Token failed to entitle server", server_id, self.get_names(), entitlement[0], e.args) - raise rhnFault(90, str(e)) + raise rhnFault(90, str(e)), None, sys.exc_info()[2] else: history["entitlement"] = "Entitled as a %s member" % entitlement[1]
@@ -685,11 +686,11 @@ class ReRegistrationActivationToken(ReRegistrationToken): except rhnSQL.SQLSchemaError, e: log_error("Failed to unentitle server", server_id, ent, e.errmsg) - raise rhnFault(90, e.errmsg) + raise rhnFault(90, e.errmsg), None, sys.exc_info()[2] except rhnSQL.SQLError, e: log_error("Failed to unentitle server", server_id, ent, e.args) - raise rhnFault(90, str(e)) + raise rhnFault(90, str(e)), None, sys.exc_info()[2]
# Call parent method: ReRegistrationToken.entitle(self, server_id, history, virt_type) diff --git a/backend/server/rhnSession.py b/backend/server/rhnSession.py index dbca60b..300b5fa 100644 --- a/backend/server/rhnSession.py +++ b/backend/server/rhnSession.py @@ -20,6 +20,7 @@ import hashlib import time import string +import sys
from spacewalk.common.rhnConfig import CFG
@@ -90,7 +91,7 @@ class Session: try: self.session_id = int(arr[0]) except ValueError: - raise InvalidSessionError("Invalid session identifier") + raise InvalidSessionError("Invalid session identifier"), None, sys.exc_info()[2]
if digest != self.digest(): raise InvalidSessionError("Bad session checksum") diff --git a/backend/server/rhnVirtualization.py b/backend/server/rhnVirtualization.py index ba79b91..0383589 100644 --- a/backend/server/rhnVirtualization.py +++ b/backend/server/rhnVirtualization.py @@ -20,6 +20,7 @@
import string import time +import sys
from spacewalk.common.rhnLog import log_debug, log_error from spacewalk.server import rhnSQL @@ -189,7 +190,7 @@ class VirtualizationEventHandler: handler = getattr(self, self.HANDLERS[event]) except KeyError, ke: raise VirtualizationEventError( - "Don't know how to handle virt event:", event) + "Don't know how to handle virt event:", event), None, sys.exc_info()[2]
# Ensure that the event has any required properties before calling the # handler. @@ -612,7 +613,7 @@ class VirtualizationEventHandler: query.execute(**bindings) except rhnSQL.SQLError, e: log_error(str(e)) - raise VirtualizationEventError, str(e) + raise VirtualizationEventError, str(e), sys.exc_info()[2]
# Now update the rhnVirtualInstanceInfo table.
diff --git a/client/rhel/rhn-client-tools/src/bin/rhn_check.py b/client/rhel/rhn-client-tools/src/bin/rhn_check.py index 36e7ea9..da2d07d 100755 --- a/client/rhel/rhn-client-tools/src/bin/rhn_check.py +++ b/client/rhel/rhn-client-tools/src/bin/rhn_check.py @@ -85,7 +85,7 @@ class CheckCli(rhncli.RhnCli): return action except xmlrpclib.Fault, f: if f.faultCode == -31: - raise up2dateErrors.InsuffMgmntEntsError(f.faultString) + raise up2dateErrors.InsuffMgmntEntsError(f.faultString), None, sys.exc_info()[2] else: print "Could not retrieve action item from server %s" % self.server print "Error code: %d%s" % (f.faultCode, f.faultString) @@ -118,7 +118,7 @@ class CheckCli(rhncli.RhnCli): return actions except xmlrpclib.Fault, f: if f.faultCode == -31: - raise up2dateErrors.InsuffMgmntEntsError(f.faultString) + raise up2dateErrors.InsuffMgmntEntsError(f.faultString), None, sys.exc_info()[2] else: print "Could not retrieve action item from server %s" % self.server print "Error code: %d%s" % (f.faultCode, f.faultString) diff --git a/client/rhel/rhn-client-tools/src/up2date_client/getMethod.py b/client/rhel/rhn-client-tools/src/up2date_client/getMethod.py index 63ed7f8..423ca35 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/getMethod.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/getMethod.py @@ -10,6 +10,7 @@
import os import string +import sys from types import ClassType
@@ -77,7 +78,7 @@ def getMethod(methodName, abspath, baseClass): try: actions = __import__(modulename) except ImportError: - raise GetMethodException("Could not import module %s" % modulename) + raise GetMethodException("Could not import module %s" % modulename), None, sys.exc_info()[2]
className = actions # Iterate through the list of components and try to load that specific diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py b/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py index f8b53a7..55d09b3 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/rhncli.py @@ -97,7 +97,7 @@ class RhnCli(object): except crypto.Error, e: sys.stderr.write(_("There was a SSL crypto error: %s\n") % e) except SystemExit, e: - raise e + raise except up2dateErrors.AuthenticationError, e: sys.stderr.write(_("There was an authentication error: %s\n") % e) sys.exit(1) 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 a64858c..1fe2d45 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py @@ -75,7 +75,7 @@ def getOemInfo(): try: (key, value) = i.split(':') except ValueError: - raise up2dateErrors.OemInfoFileError(i) + raise up2dateErrors.OemInfoFileError(i), None, sys.exc_info()[2]
info[key] = value.strip()
@@ -361,7 +361,7 @@ def getAvailableChannels(username, password): server_release) except xmlrpclib.Fault, f: if f.faultCode == 99: - raise up2dateErrors.DelayError(f.faultString) + raise up2dateErrors.DelayError(f.faultString), None, sys.exc_info()[2] else: raise
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnserver.py b/client/rhel/rhn-client-tools/src/up2date_client/rhnserver.py index ca259da..1c4c140 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/rhnserver.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnserver.py @@ -21,7 +21,7 @@ import rpcServer import up2dateErrors import capabilities - +import sys import xmlrpclib import OpenSSL
@@ -49,7 +49,7 @@ class _DoCallWrapper(object): try: return rpcServer.doCall(method, *args, **kwargs) except xmlrpclib.Fault, f: - raise self.__exception_from_fault(f) + raise self.__exception_from_fault(f), None, sys.exc_info()[2] except OpenSSL.SSL.Error, e: # TODO This should probably be moved to rhnlib and raise an # exception that subclasses OpenSSL.SSL.Error @@ -61,7 +61,7 @@ class _DoCallWrapper(object): if len(pieces) > 2: message = pieces[2].strip(" '") if message == 'certificate verify failed': - raise up2dateErrors.SSLCertificateVerifyFailedError() + raise up2dateErrors.SSLCertificateVerifyFailedError(), None, sys.exc_info()[2] else: raise
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 946d474..413c731 100644 --- a/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py +++ b/client/rhel/rhn-client-tools/src/up2date_client/rpcServer.py @@ -65,7 +65,7 @@ class RetryServer(rpclib.Server): typ = typ.lower() if typ not in ("http", "https"): raise InvalidRedirectionError( - "Redirected to unsupported protocol %s" % typ) + "Redirected to unsupported protocol %s" % typ), None, sys.exc_info()[2]
self._host, self._handler = urllib.splithost(uri) self._orig_handler = self._handler @@ -195,21 +195,21 @@ def doCall(method, *args, **kwargs): ret = method(*args, **kwargs) except KeyboardInterrupt: raise up2dateErrors.CommunicationError(_( - "Connection aborted by the user")) + "Connection aborted by the user")), None, sys.exc_info()[2] # if we get a socket error, keep tryingx2 except (socket.error, socket.sslerror), e: log.log_me("A socket error occurred: %s, attempt #%s" % ( e, attempt_count)) if attempt_count >= attempts: if len(e.args) > 1: - raise up2dateErrors.CommunicationError(e.args[1]) + raise up2dateErrors.CommunicationError(e.args[1]), None, sys.exc_info()[2] else: - raise up2dateErrors.CommunicationError(e.args[0]) + raise up2dateErrors.CommunicationError(e.args[0]), None, sys.exc_info()[2] else: failure = 1 except httplib.IncompleteRead: print "httplib.IncompleteRead" - raise up2dateErrors.CommunicationError("httplib.IncompleteRead") + raise up2dateErrors.CommunicationError("httplib.IncompleteRead"), None, sys.exc_info()[2]
except urllib2.HTTPError, e: msg = "\nAn HTTP error occurred:\n" @@ -217,7 +217,7 @@ def doCall(method, *args, **kwargs): msg = msg + "Status Code: %s\n" % e.code msg = msg + "Error Message: %s\n" % e.msg log.log_me(msg) - raise up2dateErrors.CommunicationError(msg) + raise up2dateErrors.CommunicationError(msg), None, sys.exc_info()[2]
except xmlrpclib.ProtocolError, e:
@@ -241,7 +241,7 @@ def doCall(method, *args, **kwargs): # exceptions and display a nice error message if abs(errCode) == 51: log.log_me(_("Server has refused connection due to high load")) - raise up2dateErrors.CommunicationError(e.errmsg) + raise up2dateErrors.CommunicationError(e.errmsg), None, sys.exc_info()[2] # if we get a 404 from our server, thats pretty # fatal... no point in retrying over and over. Note that # errCode == 17 is specific to our servers, if the @@ -261,17 +261,17 @@ def doCall(method, *args, **kwargs): pkgName = pkg msg = "File Not Found: %s\n%s" % (pkgName, errMsg) log.log_me(msg) - raise up2dateErrors.FileNotFoundError(msg) + raise up2dateErrors.FileNotFoundError(msg), None, sys.exc_info()[2]
if not reset: if attempt_count >= attempts: - raise up2dateErrors.CommunicationError(e.errmsg) + raise up2dateErrors.CommunicationError(e.errmsg), None, sys.exc_info()[2] else: failure = 1
except xmlrpclib.ResponseError: raise up2dateErrors.CommunicationError( - "Broken response from the server.") + "Broken response from the server."), None, sys.exc_info()[2]
if ret != None: break diff --git a/client/rhel/rhnlib/rhn/rhnLockfile.py b/client/rhel/rhnlib/rhn/rhnLockfile.py index 582defc..0c61367 100644 --- a/client/rhel/rhnlib/rhn/rhnLockfile.py +++ b/client/rhel/rhnlib/rhn/rhnLockfile.py @@ -72,7 +72,7 @@ class Lockfile: except IOError, e: if e.errno == EWOULDBLOCK: raise LockfileLockedException( - "cannot acquire lock on %s." % self.lockfile) + "cannot acquire lock on %s." % self.lockfile), None, sys.exc_info()[2] else: raise # unlock upon exit diff --git a/client/rhel/rhnlib/rhn/rpclib.py b/client/rhel/rhnlib/rhn/rpclib.py index 66a184b..9e684a1 100644 --- a/client/rhel/rhnlib/rhn/rpclib.py +++ b/client/rhel/rhnlib/rhn/rpclib.py @@ -21,6 +21,7 @@ import transports import urllib import socket import re +import sys
from types import ListType, TupleType, StringType, UnicodeType, DictType, DictionaryType
@@ -381,7 +382,7 @@ class Server: save_response = self._transport.response_status except xmlrpclib.ProtocolError, pe: if self.use_handler_path: - raise pe + raise else: save_response = pe.errcode
@@ -624,14 +625,14 @@ class GETServer(Server): offset = int(offset) except ValueError: # Error - raise RangeError("Invalid value `%s' for offset" % offset) + raise RangeError("Invalid value `%s' for offset" % offset), None, sys.exc_info()[2]
if amount is not None: try: amount = int(amount) except ValueError: # Error - raise RangeError("Invalid value `%s' for amount" % amount) + raise RangeError("Invalid value `%s' for amount" % amount), None, sys.exc_info()[2]
if amount <= 0: raise RangeError("Invalid value `%s' for amount" % amount) diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py b/client/rhel/yum-rhn-plugin/rhnplugin.py index 331d79a..d933de7 100644 --- a/client/rhel/yum-rhn-plugin/rhnplugin.py +++ b/client/rhel/yum-rhn-plugin/rhnplugin.py @@ -309,7 +309,7 @@ class RhnRepo(YumRepository): try: li = up2dateAuth.getLoginInfo() except up2dateErrors.RhnServerException, e: - raise yum.Errors.RepoError(unicode(e)) + raise yum.Errors.RepoError(unicode(e)), None, sys.exc_info()[2]
# TODO: do evalution on li auth times to see if we need to obtain a # new session... @@ -336,7 +336,7 @@ class RhnRepo(YumRepository): try: up2dateAuth.updateLoginInfo() except up2dateErrors.RhnServerException, e: - raise yum.Errors.RepoError(unicode(e)) + raise yum.Errors.RepoError(unicode(e)), None, sys.exc_info()[2]
return self._noExceptionWrappingGet(url, relative, local, start, end, copy_local, checkfunc, text, reget, cache, size) @@ -344,11 +344,11 @@ class RhnRepo(YumRepository): except URLGrabError, e: raise yum.Errors.RepoError, \ "failed to retrieve %s from %s\nerror was %s" % (relative, - self.id, e) + self.id, e), sys.exc_info()[2] except SSLError, e: - raise yum.Errors.RepoError(unicode(e)) + raise yum.Errors.RepoError(unicode(e)), None, sys.exc_info()[2] except up2dateErrors.InvalidRedirectionError, e: - raise up2dateErrors.InvalidRedirectionError(e) + raise up2dateErrors.InvalidRedirectionError(e), None, sys.exc_info()[2] _YumRepository__get = _getFile
# This code is copied from yum, we should get the original code to diff --git a/client/tools/osad/src/_ConfigParser.py b/client/tools/osad/src/_ConfigParser.py index 1c6ff37..5b95106 100644 --- a/client/tools/osad/src/_ConfigParser.py +++ b/client/tools/osad/src/_ConfigParser.py @@ -102,6 +102,7 @@ ConfigParser -- responsible for for parsing a list of import re import types import string +import sys
# Not available on python 1.5.2 True = 1 @@ -228,7 +229,7 @@ class ConfigParser: try: opts = self.__sections[section].copy() except KeyError: - raise NoSectionError(section) + raise NoSectionError(section), None, sys.exc_info()[2] opts.update(self.__defaults) if opts.has_key('__name__'): del opts['__name__'] @@ -286,7 +287,7 @@ class ConfigParser: d.update(self.__sections[section]) except KeyError: if section != DEFAULTSECT: - raise NoSectionError(section) + raise NoSectionError(section), None, sys.exc_info()[2] # Update with the entry specific variables if vars is not None: d.update(vars) @@ -294,7 +295,7 @@ class ConfigParser: try: value = d[option] except KeyError: - raise NoOptionError(option, section) + raise NoOptionError(option, section), None, sys.exc_info()[2]
if raw: return value @@ -310,7 +311,7 @@ class ConfigParser: try: value = value % vars except KeyError, key: - raise InterpolationError(key, option, section, rawval) + raise InterpolationError(key, option, section, rawval), None, sys.exc_info()[2] else: break if string.find(value, "%(") != -1: @@ -359,7 +360,7 @@ class ConfigParser: try: sectdict = self.__sections[section] except KeyError: - raise NoSectionError(section) + raise NoSectionError(section), None, sys.exc_info()[2] sectdict[self.optionxform(option)] = value
def write(self, fp): @@ -385,7 +386,7 @@ class ConfigParser: try: sectdict = self.__sections[section] except KeyError: - raise NoSectionError(section) + raise NoSectionError(section), None, sys.exc_info()[2] option = self.optionxform(option) existed = sectdict.has_key(option) if existed: diff --git a/client/tools/osad/src/jabber_lib.py b/client/tools/osad/src/jabber_lib.py index e8a7dbd..324dde8 100644 --- a/client/tools/osad/src/jabber_lib.py +++ b/client/tools/osad/src/jabber_lib.py @@ -318,11 +318,11 @@ def check_cert(cert_path): try: cert = open(cert_path).read() except IOError: - raise InvalidCertError("Unable to read file", cert_path) + raise InvalidCertError("Unable to read file", cert_path), None, sys.exc_info()[2] try: x509 = SSL.crypto.load_certificate(SSL.crypto.FILETYPE_PEM, cert) except SSL.crypto.Error: - raise InvalidCertError("Unable to open certificate", cert_path) + raise InvalidCertError("Unable to open certificate", cert_path), None, sys.exc_info()[2] log_debug(4, "Loading cert", x509.get_subject()) if x509.has_expired(): raise InvalidCertError("Expired certificate", cert_path) @@ -610,7 +610,7 @@ class JabberClient(jabber.Client): # Error in the SSL handshake - most likely mismatching CA cert log_error("Traceback caught:") log_error(extract_traceback()) - raise SSLHandshakeError + raise SSLHandshakeError, None, sys.exc_info()[2]
# Re-init the parsers jabber.xmlstream.Stream.connect(self) @@ -1032,7 +1032,7 @@ class JabberClient(jabber.Client): except SSL.SSL.SysCallError, e: log_debug(5, "Closing socket") self._non_ssl_sock.close() - raise SSLError("OpenSSL error; will retry", str(e)) + raise SSLError("OpenSSL error; will retry", str(e)), None, sys.exc_info()[2] log_debug(5, "Read %s bytes" % len(data)) if not data: raise JabberError("Premature EOF") diff --git a/client/tools/rhn-kickstart/rhnkickstart/common.py b/client/tools/rhn-kickstart/rhnkickstart/common.py index c545a5a..144954c 100644 --- a/client/tools/rhn-kickstart/rhnkickstart/common.py +++ b/client/tools/rhn-kickstart/rhnkickstart/common.py @@ -17,6 +17,7 @@ import os import re import tempfile import urllib +import sys
from rhnkickstart.kickstart_exceptions import \ MalformedKickstartFileException, MalformedKickstartURLException, \ @@ -63,7 +64,7 @@ def download_kickstart_file(extra_append): except urllib.HTTPError, e: raise KickstartDownloadException, \ "Error downloading kickstart file from '%s': %s" % \ - (ks_url, str(e)) + (ks_url, str(e)), sys.exc_info()[2]
# Sanity check to make sure we actually received a kickstart file. _ensure_valid_kickstart_file(ks_url, ks_data) @@ -113,14 +114,14 @@ def _download_install_images(tree_location, remote_path, local_path): except urllib.HTTPError, e: raise ImageDownloadException, \ "Error downloading kernel from '%s': %s" % \ - (kernel_url, str(e)) + (kernel_url, str(e)), sys.exc_info()[2]
try: initrd = urllib.urlopen(initrd_url) except urllib.HTTPError, e: raise ImageDownloadException, \ "Error downloading initrd from '%s': %s" % \ - (initrd_url, str(e)) + (initrd_url, str(e)), sys.exc_info()[2]
if not os.path.isdir(local_path): os.makedirs(local_path) diff --git a/client/tools/rhn-kickstart/rhnkickstart/kickstart_guest.py b/client/tools/rhn-kickstart/rhnkickstart/kickstart_guest.py index c036893..d87f9e4 100644 --- a/client/tools/rhn-kickstart/rhnkickstart/kickstart_guest.py +++ b/client/tools/rhn-kickstart/rhnkickstart/kickstart_guest.py @@ -246,7 +246,7 @@ def _create_disk_image(guest_name, img_size_gb, base_dir = XEN_DISK_IMAGE_DIR): os.mkdir(base_dir) except Exception, e: raise DiskImageCreationException, \ - "Could not create %s: %s" % (base_dir, str(e)) + "Could not create %s: %s" % (base_dir, str(e)), sys.exc_info()[2]
# Construct the path of the disk image. image_path = os.path.join(base_dir, "%s.disk" % guest_name) @@ -254,7 +254,7 @@ def _create_disk_image(guest_name, img_size_gb, base_dir = XEN_DISK_IMAGE_DIR): # If the disk already exists, we will fail. if os.path.exists(image_path): raise DiskImageCreationException, \ - "Disk image %s already exists." % image_path + "Disk image %s already exists." % image_path, sys.exc_info()[2]
# Attempt to create an image file and fill it with nulls. fd = None @@ -267,7 +267,7 @@ def _create_disk_image(guest_name, img_size_gb, base_dir = XEN_DISK_IMAGE_DIR): except Exception, e: raise DiskImageCreationException, \ "Error while creating image file %s of size %s GB: %s" % \ - (image_path, str(img_size_gb), str(e)) + (image_path, str(img_size_gb), str(e)), sys.exc_info()[2] finally: if fd: os.close(fd)
@@ -284,7 +284,7 @@ def _connect_to_hypervisor(): import libvirt except ImportError, ie: raise VirtLibNotFoundException, \ - "Unable to locate libvirt: %s" % str(ie) + "Unable to locate libvirt: %s" % str(ie), sys.exc_info()[2]
# Attempt to connect to the hypervisor. connection = None @@ -292,7 +292,7 @@ def _connect_to_hypervisor(): connection = libvirt.open(None) except Exception, e: raise VirtualizationKickstartException, \ - "Could not connect to hypervisor: %s" % str(e) + "Could not connect to hypervisor: %s" % str(e), sys.exc_info()[2]
return connection
@@ -336,7 +336,7 @@ def _begin_domain_installation(connection, except Exception, e: raise VirtualizationKickstartException, \ "Error occurred while attempting to create domain %s: %s" % \ - (name, str(e)) + (name, str(e)), sys.exc_info()[2]
# Wait a bit for the instance to start and then ensure that the domain is # still around. If it isn't we will assume that it crashed. @@ -346,7 +346,7 @@ def _begin_domain_installation(connection, except Exception, e: raise VirtualizationKickstartException, \ "Domain '%s' exited too quickly. It probably crashed: %s" % \ - (name, str(e)) + (name, str(e)), sys.exc_info()[2]
return domain
@@ -418,7 +418,7 @@ def _check_guest_mbr(diskPath): except Exception, e: raise VirtualizationKickstartException, \ "Error checking for guest disk MBR, install may have failed: %s" % \ - diskPath + diskPath, sys.exc_info()[2]
def _create_boot_config_file(name, mem_kb, @@ -446,7 +446,7 @@ def _create_boot_config_file(name, except Exception, e: raise VirtualizationKickstartException, \ "Error occurred while attempting to store config file %s: %s" % \ - (str(uuid), str(e)) + (str(uuid), str(e)), sys.exc_info()[2]
return domain_dir.get_config_path(uuid)
@@ -463,7 +463,7 @@ def _boot_domain(uuid): raise VirtualizationKickstartException, \ "Error occurred while rebooting domain '%s' (%s). " \ "Traceback: %s" % \ - (uuid, str(ve), stack_trace_str) + (uuid, str(ve), stack_trace_str), sys.exc_info()[2]
def syslog_listener(host, port, log_notify_handler): """ diff --git a/client/tools/rhn-virtualization/virtualization/domain_config.py b/client/tools/rhn-virtualization/virtualization/domain_config.py index bb0d406..79c07dc 100644 --- a/client/tools/rhn-virtualization/virtualization/domain_config.py +++ b/client/tools/rhn-virtualization/virtualization/domain_config.py @@ -16,6 +16,7 @@ from xml.dom.minidom import parse import string import os +import sys
############################################################################### # Exceptions @@ -73,7 +74,8 @@ class DomainConfig: self.__dom_tree = parse(self.__file_name).documentElement except Exception, e: raise DomainConfigError("Error reading config file '%s': %s" % \ - (self.__file_name, str(e))) + (self.__file_name, str(e))), None, sys.exc_info()[2] +
def save(self): """Saves any changes made to this configuration.""" @@ -84,7 +86,8 @@ class DomainConfig: file.write(self.__dom_tree.toxml()) except IOError, ioe: raise DomainConfigError("Error saving config file '%s': %s" % \ - (self.__file_name, str(ioe))) + (self.__file_name, str(ioe))), None, sys.exc_info()[2] + finally: if file is not None: file.close() @@ -242,7 +245,7 @@ class DomainConfig: except IndexError, ie: raise DomainConfigError( "Error writing %s tag in '%s'." % \ - (string.join(tag_path, '/'), self.__file_name)) + (string.join(tag_path, '/'), self.__file_name)), None, sys.exc_info()[2]
def __setElementAttribute(self, start_tree, value, *tag_path): attribute_name = tag_path[-1] diff --git a/client/tools/rhn-virtualization/virtualization/domain_control.py b/client/tools/rhn-virtualization/virtualization/domain_control.py index a028313..aa98238 100755 --- a/client/tools/rhn-virtualization/virtualization/domain_control.py +++ b/client/tools/rhn-virtualization/virtualization/domain_control.py @@ -117,7 +117,7 @@ def _get_domain(uuid): domain = conn.lookupByUUIDString(hyphenized_uuid) except libvirt.libvirtError, lve: raise VirtualizationException, \ - "Domain UUID '%s' not found: %s", (hyphenized_uuid, str(lve)) + "Domain UUID '%s' not found: %s", (hyphenized_uuid, str(lve)), None, sys.exc_info()[2] return (conn, domain)
def _call_domain_control_routine(uuid, routine_name, *args): @@ -136,7 +136,7 @@ def _call_domain_control_routine(uuid, routine_name, *args): try: ctrl_func = getattr(domain, routine_name) except AttributeError: - raise VirtualizationException, "Unknown function: %s" % routine_name + raise VirtualizationException, "Unknown function: %s" % routine_name, sys.exc_info()[2]
result = 0 try: @@ -144,11 +144,11 @@ def _call_domain_control_routine(uuid, routine_name, *args): except TypeError, te: raise VirtualizationException, \ "Invalid arguments (%s) to %s: %s" % \ - (str(args), routine_name, str(te)) + (str(args), routine_name, str(te)), sys.exc_info()[2]
# Handle the return code. Anything non-zero is an error. if result != 0: raise VirtualizationException, \ "Could not perform function '%s' on domain %s. Error: %s" % \ - (routine_name, uuid, str(result)) + (routine_name, uuid, str(result)), sys.exc_info()[2]
diff --git a/client/tools/rhn-virtualization/virtualization/localvdsm.py b/client/tools/rhn-virtualization/virtualization/localvdsm.py index d1688fe..87a394e 100755 --- a/client/tools/rhn-virtualization/virtualization/localvdsm.py +++ b/client/tools/rhn-virtualization/virtualization/localvdsm.py @@ -32,7 +32,7 @@ try: config.read(VDSM_CONF) except: # VDSM not available - raise ImportError('local vdsm not found') + raise ImportError('local vdsm not found'), None, sys.exc_info()[2]
def getTrustStorePath(): tsPath = None diff --git a/client/tools/rhn-virtualization/virtualization/poller.py b/client/tools/rhn-virtualization/virtualization/poller.py index f9682f2..5bde130 100644 --- a/client/tools/rhn-virtualization/virtualization/poller.py +++ b/client/tools/rhn-virtualization/virtualization/poller.py @@ -92,7 +92,7 @@ def poll_hypervisor(): except libvirt.libvirtError, lve: raise VirtualizationException, \ "Failed to obtain handle to domain %d: %s" % \ - (domainID, repr(lve)) + (domainID, repr(lve)), None, sys.exc_info()[2]
uuid = binascii.hexlify(domain.UUID()) # SEE: http://libvirt.org/html/libvirt-libvirt.html#virDomainInfo diff --git a/client/tools/rhn-virtualization/virtualization/start_domain.py b/client/tools/rhn-virtualization/virtualization/start_domain.py index 844ff64..941cd71 100644 --- a/client/tools/rhn-virtualization/virtualization/start_domain.py +++ b/client/tools/rhn-virtualization/virtualization/start_domain.py @@ -64,7 +64,7 @@ def start_domain(uuid): except Exception, e: raise VirtualizationException, \ "Error occurred while attempting to recreate domain %s: %s" % \ - (uuid, str(e)) + (uuid, str(e)), sys.exc_info()[2]
############################################################################### # Helper Methods @@ -100,7 +100,7 @@ def _prepare_guest_kernel_and_ramdisk(config): os.rename(pygrub_initrd_path, runtime_initrd_path) except OSError, oe: raise VirtualizationException, \ - "Error occurred while renaming runtime image paths: %s" % str(oe) + "Error occurred while renaming runtime image paths: %s" % str(oe), sys.exc_info()[2]
def _extract_image_paths_from_pygrub_output(output): diff --git a/client/tools/rhncfg/actions/Modes.py b/client/tools/rhncfg/actions/Modes.py index fefeda74..eaae210 100644 --- a/client/tools/rhncfg/actions/Modes.py +++ b/client/tools/rhncfg/actions/Modes.py @@ -70,8 +70,8 @@ class PathHandler: try: f = open(os.path.join(self.rhn_root, filename), "w") f.close() - except Exception, e: - raise e + except Exception: + raise
#remove the file if it's present. def remove_file(self, filename): @@ -79,8 +79,8 @@ class PathHandler: if self.check_for_file(filename): try: os.remove(os.path.join(self.rhn_root, filename)) - except Exception, e: - raise e + except Exception: + raise
#Returns True if filename exists in /etc/sysconfig/rhn/allowed-actions/configfiles def check_for_file(self, filename): diff --git a/client/tools/rhncfg/config_client/rpc_cli_repository.py b/client/tools/rhncfg/config_client/rpc_cli_repository.py index 06653a7..9f632b6 100644 --- a/client/tools/rhncfg/config_client/rpc_cli_repository.py +++ b/client/tools/rhncfg/config_client/rpc_cli_repository.py @@ -53,7 +53,7 @@ class ClientRepository(repository.RPC_Repository): if e.faultCode == -9: # System not subscribed raise cfg_exceptions.AuthenticationError( - "Invalid digital server certificate%s" % e.faultString) + "Invalid digital server certificate%s" % e.faultString), None, sys.exc_info()[2] raise return result
@@ -131,7 +131,7 @@ class ClientRepository(repository.RPC_Repository): failed_due_to_quota.append(file) else: raise cfg_exceptions.RepositoryFilePushError(fault_code, - fault_string) + fault_string), None, sys.exc_info()[2] except Exception: traceback.print_exc() raise diff --git a/client/tools/rhncfg/config_common/repository.py b/client/tools/rhncfg/config_common/repository.py index 3cdb67e..37f3f2c 100644 --- a/client/tools/rhncfg/config_common/repository.py +++ b/client/tools/rhncfg/config_common/repository.py @@ -159,7 +159,7 @@ class Repository: file_stat = os.lstat(local_path) except OSError, e: raise cfg_exceptions.RepositoryLocalFileError( - "Error lstat()-ing local file: %s" % e) + "Error lstat()-ing local file: %s" % e), None, sys.exc_info()[2]
# Dlimiters if delim_start or delim_end: @@ -193,7 +193,7 @@ class Repository: file_contents = open(local_path, "r").read() except IOError, e: raise cfg_exceptions.RepositoryLocalFileError( - "Error opening local file: %s" % e) + "Error opening local file: %s" % e), None, sys.exc_info()[2]
self._add_content(file_contents, params)
diff --git a/client/tools/rhncfg/config_common/rpc_wrapper.py b/client/tools/rhncfg/config_common/rpc_wrapper.py index 07a9916..685d6a5 100644 --- a/client/tools/rhncfg/config_common/rpc_wrapper.py +++ b/client/tools/rhncfg/config_common/rpc_wrapper.py @@ -162,16 +162,17 @@ class Server(rpclib.Server): except rpclib.InvalidRedirectionError: raise except xmlrpclib.Fault, e: + save_traceback = sys.exc_info()[2] try: self._failover() except NoMoreServers, f: - raise e #Don't raise the NoMoreServers error, raise the error that triggered the failover. + raise e, None, save_traceback #Don't raise the NoMoreServers error, raise the error that triggered the failover. continue except (error, sslerror, herror, gaierror, timeout), e: try: self._failover() except NoMoreServers, f: - raise e + raise e, None, save_traceback continue succeed = 1 #If we get here then the function call eventually succeeded and we don't need to try again. return ret diff --git a/client/tools/rhncfg/config_common/transactions.py b/client/tools/rhncfg/config_common/transactions.py index 44ffc60..0a90ba0 100644 --- a/client/tools/rhncfg/config_common/transactions.py +++ b/client/tools/rhncfg/config_common/transactions.py @@ -117,7 +117,7 @@ class DeployTransaction: try: user_record = pwd.getpwnam(file_info['username']) except Exception, e: - raise cfg_exceptions.UserNotFound(file_info['username']) + raise cfg_exceptions.UserNotFound(file_info['username']), None, sys.exc_info()[2]
uid = user_record[2] else: @@ -131,7 +131,7 @@ class DeployTransaction: try: group_record = grp.getgrnam(file_info['groupname']) except Exception, e: - raise cfg_exceptions.GroupNotFound(file_info['groupname']) + raise cfg_exceptions.GroupNotFound(file_info['groupname']), None, sys.exc_info()[2]
gid = group_record[2] else: diff --git a/client/tools/rhncfg/config_management/rhncfg_get.py b/client/tools/rhncfg/config_management/rhncfg_get.py index 83d9937..5c6f9a0 100644 --- a/client/tools/rhncfg/config_management/rhncfg_get.py +++ b/client/tools/rhncfg/config_management/rhncfg_get.py @@ -14,6 +14,7 @@ #
import os +import sys import tempfile
from config_common import handler_base, utils, cfg_exceptions @@ -107,14 +108,14 @@ class Handler(handler_base.HandlerBase): try: dep_trans.rollback() except FailedRollback, e2: - raise "FAILED ROLLBACK: ", e2 + raise e2, "FAILED ROLLBACK: ", sys.exc_info()[2] #5/3/05 wregglej - 136415 Added exception stuff for missing user info. except cfg_exceptions.UserNotFound, f: - raise f + raise #5/5/05 wregglej - 136415 Added exception handling for unknown group. except cfg_exceptions.GroupNotFound, f: - raise f + raise else: - raise "Deploy failed, rollback successful: ", e + raise e, "Deploy failed, rollback successful: ", sys.exc_info()[2]
diff --git a/client/tools/rhncfg/config_management/rhncfg_remove.py b/client/tools/rhncfg/config_management/rhncfg_remove.py index c4b190c..08d8289 100644 --- a/client/tools/rhncfg/config_management/rhncfg_remove.py +++ b/client/tools/rhncfg/config_management/rhncfg_remove.py @@ -72,6 +72,6 @@ class Handler(handler_base.HandlerBase): if e.faultCode == -4011: print "%s does not exist" % remote_file continue - raise e + raise else: print "%s removed" % remote_file diff --git a/client/tools/rhncfg/config_management/rpc_repository.py b/client/tools/rhncfg/config_management/rpc_repository.py index 095572f..2206db1 100644 --- a/client/tools/rhncfg/config_management/rpc_repository.py +++ b/client/tools/rhncfg/config_management/rpc_repository.py @@ -14,6 +14,7 @@ #
import os +import sys import tempfile import xmlrpclib
@@ -59,8 +60,8 @@ class Repository(repository.RPC_Repository): fault_code, fault_string = e.faultCode, e.faultString if fault_code == -2: raise cfg_exceptions.AuthenticationError( - "Invalid username or incorrect password") - raise cfg_exceptions.InvalidSession(fault_code, fault_string) + "Invalid username or incorrect password"), None, sys.exc_info()[2] + raise cfg_exceptions.InvalidSession(fault_code, fault_string), None, sys.exc_info()[2]
self._save_session()
@@ -92,8 +93,8 @@ class Repository(repository.RPC_Repository): if e.faultCode == -4011: # File not present raise cfg_exceptions.RepositoryFileMissingError(config_channel, - repopath) - raise e + repopath), None, sys.exc_info()[2] + raise return result
def get_file_info(self, config_channel, repopath, revision=None, auto_delete=1, dest_directory=tempfile.gettempdir()): @@ -166,18 +167,18 @@ class Repository(repository.RPC_Repository): fault_code, fault_string = e.faultCode, e.faultString
if is_first_revision and fault_code == -4013: - raise cfg_exceptions.RepositoryFileExistsError(fault_string) + raise cfg_exceptions.RepositoryFileExistsError(fault_string), None, sys.exc_info()[2]
if old_revision and fault_code == -4012: - raise cfg_exceptions.RepositoryFileVersionMismatchError(fault_string) + raise cfg_exceptions.RepositoryFileVersionMismatchError(fault_string), None, sys.exc_info()[2]
if fault_code == -4003: - raise cfg_exceptions.ConfigFileTooLargeError(fault_string) + raise cfg_exceptions.ConfigFileTooLargeError(fault_string), None, sys.exc_info()[2]
if fault_code == -4014: - raise cfg_exceptions.QuotaExceeded(fault_string) + raise cfg_exceptions.QuotaExceeded(fault_string), None, sys.exc_info()[2]
- raise cfg_exceptions.RepositoryFilePushError(fault_code, fault_string) + raise cfg_exceptions.RepositoryFilePushError(fault_code, fault_string), None, sys.exc_info()[2]
return result
@@ -214,8 +215,8 @@ class Repository(repository.RPC_Repository): if e.faultCode == -4011: # File not present raise cfg_exceptions.RepositoryFileMissingError( - config_channel, repopath) - raise e + config_channel, repopath), None, sys.exc_info()[2] + raise return revisions
def list_config_channels(self): @@ -238,7 +239,7 @@ class Repository(repository.RPC_Repository): {'session' : self.session, 'config_channel' : config_channel}) except xmlrpclib.Fault, e: if e.faultCode == -4010: - raise cfg_exceptions.ConfigChannelAlreadyExistsError(config_channel) + raise cfg_exceptions.ConfigChannelAlreadyExistsError(config_channel), None, sys.exc_info()[2] raise
def remove_config_channel(self, config_channel): @@ -249,9 +250,9 @@ class Repository(repository.RPC_Repository): {'session' : self.session, 'config_channel' : config_channel}) except xmlrpclib.Fault, e: if e.faultCode == -4009: - raise cfg_exceptions.ConfigChannelNotInRepo(config_channel) + raise cfg_exceptions.ConfigChannelNotInRepo(config_channel), None, sys.exc_info()[2] if e.faultCode == -4005: - raise cfg_exceptions.ConfigChannelNotEmptyError(config_channel) + raise cfg_exceptions.ConfigChannelNotEmptyError(config_channel), None, sys.exc_info()[2] raise
def _get_default_delimiters(self): @@ -290,11 +291,11 @@ class Repository(repository.RPC_Repository): except xmlrpclib.Fault, e: if e.faultCode == -4011: # File not present - raise cfg_exceptions.RepositoryFileMissingError(e.faultString) + raise cfg_exceptions.RepositoryFileMissingError(e.faultString), None, sys.exc_info()[2] if e.faultCode == -4004: # Binary file requested - raise cfg_exceptions.BinaryFileDiffError(e.faultString) - raise e + raise cfg_exceptions.BinaryFileDiffError(e.faultString), None, sys.exc_info()[2] + raise return ret
def _get_session(self): diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py index 72018c9..b874bc5 100644 --- a/client/tools/rhnpush/connection.py +++ b/client/tools/rhnpush/connection.py @@ -16,6 +16,7 @@ import socket import string import base64 +import sys import urllib import urlparse
@@ -124,7 +125,7 @@ class PackageUpload: try: self.connection.connect() except socket.error, e: - raise ConnectionError("Error connecting", str(e)) + raise ConnectionError("Error connecting", str(e)), None, sys.exc_info()[2]
# Add content_length if not self.headers.has_key('Content-Length') and \ @@ -154,7 +155,7 @@ class PackageUpload: try: self.connection.send(buf) except IOError, e: - raise ConnectionError("Error sending body", str(e)) + raise ConnectionError("Error sending body", str(e)), None, sys.exc_info()[2]
def send_http(self, method, stream_body=None): if stream_body is None: diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py index f9ad7e4..938f213 100755 --- a/client/tools/rhnpush/rhnpush.py +++ b/client/tools/rhnpush/rhnpush.py @@ -639,7 +639,7 @@ class UploadClass(uploadLib.UploadClass): except: # Raise the exception instead of silently dying raise UploadError("Error pushing %s: %s (%s)" % - (package, msgstr, status)) + (package, msgstr, status)), None, sys.exc_info()[2] (diff_dict, ), methodname = data del methodname diff_level = diff_dict['level'] diff --git a/client/tools/rhnpush/solaris2mpm.py b/client/tools/rhnpush/solaris2mpm.py index 1bd559d..1cc048c 100644 --- a/client/tools/rhnpush/solaris2mpm.py +++ b/client/tools/rhnpush/solaris2mpm.py @@ -1028,7 +1028,7 @@ def _extract_pstamp_as_release(pstamp): try: date_time_struct = time.strptime(date_time_stamp, "%y%m%d%H%M%S") except ValueError, ve: - raise PStampParseException("Error parsing date/time: %s" % str(ve)) + raise PStampParseException("Error parsing date/time: %s" % str(ve)), None, sys.exc_info()[2]
# Convert the structure into a string in the release number format. release_number = time.strftime("%Y.%m.%d.%H.%M", date_time_struct) @@ -1058,7 +1058,7 @@ def _to_db_timestamp(s): if m == _months[i]: break else: - raise Exception("unknown month %s" % arr[0]) + raise Exception("unknown month %s" % arr[0]), None, sys.exc_info()[2] m = i + 1
d = int(d) diff --git a/contrib/swapi.py b/contrib/swapi.py index 31b239a..8d2a4ee 100755 --- a/contrib/swapi.py +++ b/contrib/swapi.py @@ -342,7 +342,7 @@ class RpcApi(object): return ret
except xmlrpclib.Fault, m: - raise RuntimeError("rpc: method '%s', args '%s'\nError message: %s" % (method_name, str(args), m)) + raise RuntimeError("rpc: method '%s', args '%s'\nError message: %s" % (method_name, str(args), m)), None, sys.exc_info()[2]
def multicall(self, method_name, argsets): """Quick hack to implement XML-RPC's multicall like function. diff --git a/proxy/proxy/broker/rhnRepository.py b/proxy/proxy/broker/rhnRepository.py index 5394eb0..b532797 100644 --- a/proxy/proxy/broker/rhnRepository.py +++ b/proxy/proxy/broker/rhnRepository.py @@ -25,6 +25,7 @@ import time import glob import string import cPickle +import sys import types from operator import truth import xmlrpclib @@ -129,7 +130,7 @@ class Repository(rhnRepository.Repository): pkgFilename, self.channelName, self.clientInfo) except xmlrpclib.Fault, e: raise rhnFault(1000, - _("Error retrieving source package: %s") % str(e)) + _("Error retrieving source package: %s") % str(e)), None, sys.exc_info()[2] if not retval: raise rhnFault(17, _("Invalid SRPM package requested: %s") % pkgFilename) @@ -242,7 +243,7 @@ def listPackages(function, channel, version): except xmlrpclib.ProtocolError, e: errcode, errmsg = rpclib.reportError(e.headers) raise rhnFault(1000, "RHN Proxy error (xmlrpclib.ProtocolError): " - "errode=%s; errmsg=%s" % (errcode, errmsg)) + "errode=%s; errmsg=%s" % (errcode, errmsg)), None, sys.exc_info()[2]
def computePackagePath(nvrea, source=0, prepend=""): @@ -315,7 +316,7 @@ def cache(stringObject, dir, filename, version): tempfile = tempfile + "%.20f" % time.time() continue # Another error - raise e + raise else: # We've got the file; everything's nice and dandy break diff --git a/proxy/proxy/pm/rhn_package_manager b/proxy/proxy/pm/rhn_package_manager index 4a888b6..5573cb8 100755 --- a/proxy/proxy/pm/rhn_package_manager +++ b/proxy/proxy/pm/rhn_package_manager @@ -22,7 +22,7 @@ if __name__ == '__main__': except ImportError, e: sys.stderr.write("Unable to find package management libraries.\n" "Path not correct? '%s'\n" % LIBPATH) - raise ImportError, e + raise
try: rhn_package_manager.main() diff --git a/proxy/proxy/pm/uploadLib.py b/proxy/proxy/pm/uploadLib.py index 9b86d0f..d7d8512 100644 --- a/proxy/proxy/pm/uploadLib.py +++ b/proxy/proxy/pm/uploadLib.py @@ -14,6 +14,7 @@ # in this software or its documentation. #
+import sys # RHN imports from spacewalk.common import rhn_mpm from spacewalk.common.checksum import getFileChecksum @@ -175,7 +176,7 @@ def get_header(file, fildes=None, source=None): try: h = rhn_mpm.get_package_header(filename=file, fd=fildes) except rhn_mpm.InvalidPackageError: - raise uploadLib.UploadError("Package is invalid") + raise uploadLib.UploadError("Package is invalid"), None, sys.exc_info()[2] # Verify that this is indeed a binary/source. xor magic # xor doesn't work with None values, so compare the negated values - the # results are identical diff --git a/proxy/proxy/rhnAuthCacheClient.py b/proxy/proxy/rhnAuthCacheClient.py index 1135935..db033a2 100644 --- a/proxy/proxy/rhnAuthCacheClient.py +++ b/proxy/proxy/rhnAuthCacheClient.py @@ -21,6 +21,7 @@
## language imports import socket +import sys
## local imports from spacewalk.common.rhnLog import log_debug, log_error @@ -90,7 +91,7 @@ class Shelf: # FIXME: PROBLEM: this rhnFault will never reach the client raise rhnFault(1000, _("RHN Proxy error (issues connecting to auth cache). " - "Please contact your system administrator")) + "Please contact your system administrator")), None, sys.exc_info()[2]
wfile = sock.makefile("w")
@@ -112,7 +113,7 @@ class Shelf: # FIXME: PROBLEM: this rhnFault will never reach the client raise rhnFault(1000, _("RHN Proxy error (issues connecting to auth cache). " - "Please contact your system administrator")) + "Please contact your system administrator")), None, sys.exc_info()[2]
wfile.close()
@@ -130,7 +131,7 @@ class Shelf: # FIXME: PROBLEM: this rhnFault will never reach the client raise rhnFault(1000, _("RHN Proxy error (issues communicating to auth cache). " - "Please contact your system administrator")) + "Please contact your system administrator")), None, sys.exc_info()[2] except Fault, e: rfile.close() sock.close() @@ -158,7 +159,7 @@ class Shelf: # Instantiate the exception object import new _dict = {'args' : args} - raise new.instance(getattr(__builtins__, name), _dict) + raise new.instance(getattr(__builtins__, name), _dict), None, sys.exc_info()[2]
return params[0]
diff --git a/proxy/proxy/rhnProxyAuth.py b/proxy/proxy/rhnProxyAuth.py index bb8c988..4216660 100644 --- a/proxy/proxy/rhnProxyAuth.py +++ b/proxy/proxy/rhnProxyAuth.py @@ -22,6 +22,7 @@ import time import string import socket import xmlrpclib +import sys
## local imports import rhnAuthCacheClient @@ -82,7 +83,7 @@ class ProxyAuth: log_error("unable to stat %s: %s" % (ProxyAuth.__systemid_filename, repr(e))) raise rhnFault(1000, _("RHN Proxy error (RHN Proxy systemid has wrong permissions?). " - "Please contact your system administrator.")) + "Please contact your system administrator.")), None, sys.exc_info()[2]
if not self.__systemid_mtime: ProxyAuth.__systemid_mtime = mtime @@ -99,7 +100,7 @@ class ProxyAuth: log_error("unable to read %s" % ProxyAuth.__systemid_filename) raise rhnFault(1000, _("RHN Proxy error (RHN Proxy systemid has wrong permissions?). " - "Please contact your system administrator.")) + "Please contact your system administrator.")), None, sys.exc_info()[2]
# get serverid sysid, cruft = xmlrpclib.loads(ProxyAuth.__systemid) @@ -154,7 +155,7 @@ problems, isn't running, or the token is somehow corrupt. Traceback("ProxyAuth.set_cached_token", extra=text) raise rhnFault(1000, _("RHN Proxy error (auth caching issue). " - "Please contact your system administrator.")) + "Please contact your system administrator.")), None, sys.exc_info()[2] log_debug(4, "successfully returning") return token
@@ -287,7 +288,7 @@ problems, isn't running, or the token is somehow corrupt. if e.faultCode == 10000: # reraise it for the users (outage or "important message" # coming through") - raise rhnFault(e.faultCode, e.faultString) + raise rhnFault(e.faultCode, e.faultString), None, sys.exc_info()[2] # ok... it's some other fault Traceback("ProxyAuth.login (Fault) - RHN Proxy not " "able to log in.") @@ -295,7 +296,7 @@ problems, isn't running, or the token is somehow corrupt. # clear raise rhnFault(1000, _("RHN Proxy error (during proxy login). " - "Please contact your system administrator.")) + "Please contact your system administrator.")), None, sys.exc_info()[2] except Exception, e: token = None log_error("Unhandled exception", e) diff --git a/proxy/proxy/rhnShared.py b/proxy/proxy/rhnShared.py index 9722063..acdcf23 100644 --- a/proxy/proxy/rhnShared.py +++ b/proxy/proxy/rhnShared.py @@ -19,6 +19,7 @@ import urllib import string import socket +import sys from types import ListType, TupleType
## global imports @@ -123,7 +124,7 @@ class SharedHandler: Traceback(mail=0) raise rhnFault(1000, _("RHN Proxy could not successfully connect its RHN parent. " - "Please contact your system administrator.")) + "Please contact your system administrator.")), None, sys.exc_info()[2]
# At this point the server should be okay log_debug(3, "Connected to parent: %s " % self.rhnParent) @@ -204,12 +205,12 @@ class SharedHandler: # XXX: why are we not mailing this out??? Traceback("SharedHandler._serverCommo", self.req, mail=0) raise rhnFault(1000, _( - "RHN Proxy error: connection with the RHN server failed")) + "RHN Proxy error: connection with the RHN server failed")), None, sys.exc_info()[2] except socket.error: # maybe self.req.read() failed? Traceback("SharedHandler._serverCommo", self.req) raise rhnFault(1000, _( - "RHN Proxy error: connection with the RHN server failed")) + "RHN Proxy error: connection with the RHN server failed")), None, sys.exc_info()[2]
log_debug(2, "HTTP status code (200 means all is well): %s" % status)
diff --git a/reporting/reports.py b/reporting/reports.py index 8d47091..3a97706 100644 --- a/reporting/reports.py +++ b/reporting/reports.py @@ -1,6 +1,7 @@
import os import re +import sys
REPORT_DEFINITIONS = "/usr/share/spacewalk/reports/data"
@@ -26,7 +27,7 @@ class report: try: fd = open(full_path, 'r') except (IOError): - raise spacewalk_unknown_report + raise spacewalk_unknown_report, None, sys.exc_info()[2] tag = None value = '' re_comment = re.compile('^\s*#') diff --git a/spacecmd/src/lib/misc.py b/spacecmd/src/lib/misc.py index 8bdfad6..0587ad1 100644 --- a/spacecmd/src/lib/misc.py +++ b/spacecmd/src/lib/misc.py @@ -236,7 +236,7 @@ def do_login(self, args): logging.debug('Server API Version = %s' % self.api_version) except Exception, e: self.client = None - raise e + raise
# ensure the server is recent enough if self.api_version < self.MINIMUM_API_VERSION: diff --git a/utils/spacewalk-common-channels b/utils/spacewalk-common-channels index b22f8cf..62c3481 100755 --- a/utils/spacewalk-common-channels +++ b/utils/spacewalk-common-channels @@ -218,7 +218,7 @@ Create everything as well as unlimited activation key for every channel: "Either the password or username is incorrect.\n") sys.exit(2) else: - raise e + raise
if create_channel: base_info = channels[base_channel_label]
spacewalk-commits@lists.fedorahosted.org