backend/server/handlers/xp/packages.py | 84 +--------------------------------
1 file changed, 3 insertions(+), 81 deletions(-)
New commits:
commit eca3359ec554c2c31c396e51462c82ad1cf73726
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Sep 20 16:46:26 2010 +0200
/XP handler defines just 4 calls identical to /APP calls
let's reuse already written code
diff --git a/backend/server/handlers/xp/packages.py
b/backend/server/handlers/xp/packages.py
index e23f714..9c96014 100644
--- a/backend/server/handlers/xp/packages.py
+++ b/backend/server/handlers/xp/packages.py
@@ -17,15 +17,10 @@
# Package info checking routines.
#
-import string
+from spacewalk.common import RPC_Base, log_debug
+from spacewalk.server.handlers.app.packages import Packages as APP_Packages
-from spacewalk.common import RPC_Base, rhnFault, log_debug
-from spacewalk.server.importlib.packageUpload import uploadPackages, listChannels
-from spacewalk.server.importlib.importLib import IncompatibleArchError
-from spacewalk.server.importlib.userAuth import UserAuth
-from spacewalk.server import rhnSQL
-
-class Packages(RPC_Base):
+class Packages(APP_Packages):
def __init__(self):
log_debug(3)
RPC_Base.__init__(self)
@@ -35,76 +30,3 @@ class Packages(RPC_Base):
self.functions.append('listMissingSourcePackages')
- def uploadPackageInfo(self, login, password, info):
- """ Upload a collection of binary packages """
- log_debug(5, login, info)
- authobj = auth(login, password)
- # Get the channels
- channels = info.get('channels')
- if channels:
- authobj.authzChannels(channels)
- info['orgId'] = authobj.org_id
- try:
- return uploadPackages(info, caller="server.xp.uploadPackageInfo")
- except IncompatibleArchError, e:
- raise rhnFault(506, string.join(e.args), explain=0)
-
-
- def uploadSourcePackageInfo(self, login, password, info):
- """ Upload a collection of source packages """
- log_debug(5, login, info)
- authobj = auth(login, password)
- info['orgId'] = authobj.org_id
- return uploadPackages(info, source=1,
- caller="server.xp.uploadSourcePackageInfo")
-
-
- def listChannel(self, channelList, login, password):
- """ List packages of a specified channel """
- log_debug(4, channelList, login)
- authobj = auth(login, password)
- authobj.authzChannels(channelList)
- return listChannels(channelList)
-
- def listMissingSourcePackages(self, channelList, username, password):
- """ List source packages for a list of channels
"""
- log_debug(5, channelList, username)
- authobj = auth(username, password)
- authobj.authzChannels(channelList)
-
- h = rhnSQL.prepare("""
- select distinct sr.name source_rpm
- from rhnChannel c
- join rhnChannelNewestPackage cnp
- on cnp.channel_id = c.id
- join rhnPackage p
- on cnp.package_id = p.id
- join rhnSourceRPM sr
- on p.source_rpm_id = sr.id
- left join rhnPackageSource ps
- on p.source_rpm_id = ps.source_rpm_id
- and (p.org_id = ps.org_id or
- (p.org_id is null and ps.org_id is null)
- )
- where c.label = :channel_label
- and ps.source_rpm_id is null
- """)
- missing_packages = []
- for c in channelList:
- h.execute(channel_label=c)
- while 1:
- row = h.fetchone_dict()
- if not row:
- break
-
- missing_packages.append([row['source_rpm'], c])
-
- return missing_packages
-
-def auth(login, password):
- """ Authorize this user """
- authobj = UserAuth()
- authobj.auth(login, password)
- # Check if he's authorized to perform administrative tasks
- authobj.authzOrg({'orgId' : authobj.org_id})
- return authobj
Show replies by date