backend/satellite_tools/rhn_ssl_dbstore.py | 18 +--------
backend/server/rhnChannel.py | 27 --------------
backend/server/rhnDependency.py | 53 +----------------------------
backend/server/rhnLib.py | 24 +++++++++++++
4 files changed, 30 insertions(+), 92 deletions(-)
New commits:
commit 694813a5ac6a9571609fc3a97a7d4895ee05c132
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Mar 2 12:14:10 2011 +0100
merged/moved make_evr() implemetation into a single code
diff --git a/backend/server/rhnChannel.py b/backend/server/rhnChannel.py
index 8ca0610..646d814 100644
--- a/backend/server/rhnChannel.py
+++ b/backend/server/rhnChannel.py
@@ -975,7 +975,7 @@ def list_packages_source(channel_id):
r = r['name']
if string.find(r, ".rpm") != -1:
r = string.replace(r, ".rpm", "")
- new_evr = make_evr(r,source=1)
+ new_evr = rhnLib.make_evr(r,source=1)
new_evr_list = [new_evr['name'], new_evr['version'], new_evr['release'],new_evr['epoch']]
ret.append(new_evr_list)
@@ -1901,31 +1901,6 @@ def system_reg_message(server):
return -1, no_entitlement_title, no_entitlement_message % params
return 0, "", ""
-# IN: 'e:name-version-release' or 'name-version-release:e'
-# OUT: {'name':name, 'version':version, 'release':release, 'epoch':epoch }
-def make_evr(nvre, source=False):
- import re
- if ":" in nvre:
- nvr, epoch = nvre.rsplit(":", 1)
- if "-" in epoch:
- nvr, epoch = epoch, nvr
- else:
- nvr, epoch = nvre, ""
-
- nvr_parts = nvr.rsplit("-", 2)
- if len(nvr_parts) != 3:
- raise rhnFault(err_code = 21, err_text = \
- "NVRE is missing name, version, or release.")
-
- result = dict(zip(["name", "version", "release"], nvr_parts))
- result["epoch"] = epoch
-
- if source and result["release"].endswith(".src"):
- result["release"] = result["release"][:-4]
-
- return result
-
-
def subscribe_to_tools_channel(server_id):
"""
Subscribes server_id to the RHN Tools channel associated with its base channel, if one exists.
diff --git a/backend/server/rhnDependency.py b/backend/server/rhnDependency.py
index 582090e..4e121f9 100644
--- a/backend/server/rhnDependency.py
+++ b/backend/server/rhnDependency.py
@@ -16,7 +16,7 @@
from spacewalk.common import log_debug, log_error
from spacewalk.common.rhnException import rhnFault
-import rhnSQL
+import rhnSQL, rhnLib
import rpm
import string
@@ -297,55 +297,6 @@ def __single_query_with_arch_and_id(server_id, deps, query):
ret[dep] = map(lambda a: a[:6], data)
return ret
-def make_evr(nvre):
- """ IN: 'e:name-version-release' or 'name-version-release:e'
- OUT: {'name':name, 'version':version, 'release':release, 'epoch':epoch }
- """
- epoch = ''
- name = ''
- version = ''
- release = ''
- list = None
- ret = None
-
- #There is an epoch
- if string.find(nvre, ':') != -1:
- holder = string.split(nvre, ':')
-
- #holder[0] has the n,v,r,a
- if string.find(holder[0], '-') != -1:
- holder[0] = string.split(holder[0], '-')
- ret = {
- 'name' : '-'.join(holder[0][:-2]),
- 'version' : holder[0][-2],
- 'release' : holder[0][-1],
- 'epoch' : holder[1]
- }
- return ret
- elif string.find(holder[1], '-') != -1:
- holder[1] = string.split(holder[1], '-')
- ret = {
- 'name' : '-'.join(holder[1][:-2]),
- 'version' : holder[1][-2],
- 'release' : holder[1][-1],
- 'epoch' : holder[0]
- }
- return ret
- else:
- raise rhnFault(err_code = 21,
- err_text = "NVRE is missing name, version, or release.")
- elif string.find(nvre, '-') != -1:
- nvre = string.split(nvre, '-')
- ret = {
- 'name' : '-'.join(nvre[:-2]),
- 'version' : nvre[-2],
- 'release' : nvre[-1],
- 'epoch' : None
- }
- return ret
- else:
- return MakeEvrError(message = "NVRE is missing name, version, or release.")
-
#
# Interfaces
#
@@ -422,7 +373,7 @@ def solve_dependencies_with_limits(server_id, deps, version, all = 0, limit_oper
keep_list = []
try:
- limit = make_evr(limit)
+ limit = rhnLib.make_evr(limit)
except:
raise
diff --git a/backend/server/rhnLib.py b/backend/server/rhnLib.py
index d83407c..24a6694 100644
--- a/backend/server/rhnLib.py
+++ b/backend/server/rhnLib.py
@@ -196,3 +196,27 @@ class CallableObj:
def __call__(self, *args, **kwargs):
return apply(self.func, (self.name, ) + args, kwargs)
+
+def make_evr(nvre):
+ """ IN: 'e:name-version-release' or 'name-version-release:e'
+ OUT: {'name':name, 'version':version, 'release':release, 'epoch':epoch }
+ """
+ if ":" in nvre:
+ nvr, epoch = nvre.rsplit(":", 1)
+ if "-" in epoch:
+ nvr, epoch = epoch, nvr
+ else:
+ nvr, epoch = nvre, ""
+
+ nvr_parts = nvr.rsplit("-", 2)
+ if len(nvr_parts) != 3:
+ raise rhnFault(err_code = 21, err_text = \
+ "NVRE is missing name, version, or release.")
+
+ result = dict(zip(["name", "version", "release"], nvr_parts))
+ result["epoch"] = epoch
+
+ if source and result["release"].endswith(".src"):
+ result["release"] = result["release"][:-4]
+
+ return result
commit d6efd058e1f7ae75d56eb973cdb4cbb0826eb02b
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Mar 2 11:46:27 2011 +0100
removed duplicated fetchTraceback()
diff --git a/backend/satellite_tools/rhn_ssl_dbstore.py b/backend/satellite_tools/rhn_ssl_dbstore.py
index 08b1926..fff40b2 100644
--- a/backend/satellite_tools/rhn_ssl_dbstore.py
+++ b/backend/satellite_tools/rhn_ssl_dbstore.py
@@ -25,18 +25,6 @@ import satCerts
DEFAULT_TRUSTED_CERT = 'RHN-ORG-TRUSTED-SSL-CERT'
-def fetchTraceback(method=None, req=None, extra=None):
- """ a cheat for snagging just the string value of a Traceback
- NOTE: this tool may be needed for RHN Satellite 3.2 as well,
- which doesn't have a fetchTraceback. So... this if for
- compatibility.
- """
- from cStringIO import StringIO
- exc = StringIO()
- rhnTB.Traceback(method=method, req=req, mail=0, ostream=exc,
- extra=extra, severity=None)
- return exc.getvalue()
-
def processCommandline():
initCFG('server.satellite')
@@ -73,7 +61,7 @@ def processCommandline():
sys.stderr.write("""\
ERROR: there was a problem trying to initialize the database:
-%s\n""" % fetchTraceback())
+%s\n""" % rhnTB.fetchTraceback())
sys.exit(11)
if values.verbose:
@@ -100,10 +88,10 @@ def main():
try:
satCerts.store_rhnCryptoKey(values.label, values.ca_cert, verbosity=values.verbose)
except satCerts.NoOrgIdError, e:
- writeError("no organization ID!?!\n\n%s\n" % fetchTraceback())
+ writeError("no organization ID!?!\n\n%s\n" % rhnTB.fetchTraceback())
sys.exit(12)
except satCerts.CaCertInsertionError, e:
- writeError("no organization ID!?!\n\n%s\n" % fetchTraceback())
+ writeError("no organization ID!?!\n\n%s\n" % rhnTB.fetchTraceback())
sys.exit(13)
return 0