Use DataHolder instead of namedtuple for holding kernel info

This commit is contained in:
Martin Gracik 2010-11-23 13:27:07 +01:00
parent e9eea0f3ea
commit 0224cdf660
2 changed files with 13 additions and 29 deletions

View File

@ -43,8 +43,6 @@ import itertools
import glob import glob
import math import math
from collections import namedtuple
from base import BaseLoraxClass from base import BaseLoraxClass
import output import output
@ -86,10 +84,6 @@ K_PAE = 1
K_XEN = 1 K_XEN = 1
# XXX kernel tuple
Kernel = namedtuple("Kernel", "fname fpath version type")
class Lorax(BaseLoraxClass): class Lorax(BaseLoraxClass):
def __init__(self): def __init__(self):
@ -347,23 +341,20 @@ class Lorax(BaseLoraxClass):
splash = joinpaths(self.workdir, os.path.basename(splash)) splash = joinpaths(self.workdir, os.path.basename(splash))
# move kernels to workdir # move kernels to workdir
kernels = []
for kernel in self.installtree.kernels: for kernel in self.installtree.kernels:
type = "" suffix = ""
if kernel.type == K_PAE: if kernel.type == K_PAE:
type = "-PAE" suffix = "-PAE"
elif kernel.type == K_XEN: elif kernel.type == K_XEN:
type = "-XEN" suffix = "-XEN"
kname = "vmlinuz{0}".format(type)
kname = "vmlinuz{0}".format(suffix)
shutil.move(kernel.fpath, joinpaths(self.workdir, kname)) shutil.move(kernel.fpath, joinpaths(self.workdir, kname))
kernels.append(Kernel(kname, kernel.fname = kname
joinpaths(self.workdir, kname), kernel.fpath = joinpaths(self.workdir, kname)
kernel.version,
kernel.type))
self.outputtree.get_kernels(kernels[:]) # copy kernels to output directory
self.outputtree.get_kernels(self.installtree.kernels[:])
# get list of not required packages # get list of not required packages
logger.info("getting list of not required packages") logger.info("getting list of not required packages")

View File

@ -32,10 +32,7 @@ import time
import subprocess import subprocess
import operator import operator
from collections import namedtuple from base import BaseLoraxClass, DataHolder
from base import BaseLoraxClass
import constants import constants
from sysutils import * from sysutils import *
@ -46,10 +43,6 @@ K_PAE = 1
K_XEN = 1 K_XEN = 1
# XXX kernel tuple
Kernel = namedtuple("Kernel", "fname fpath version type")
class LoraxInstallTree(BaseLoraxClass): class LoraxInstallTree(BaseLoraxClass):
def __init__(self, yum, basearch, libdir): def __init__(self, yum, basearch, libdir):
@ -553,10 +546,10 @@ class LoraxInstallTree(BaseLoraxClass):
elif m.group("xen"): elif m.group("xen"):
type = K_XEN type = K_XEN
kernels.append(Kernel(fname, kernels.append(DataHolder(fname=fname,
joinpaths(kerneldir, fname), fpath=joinpaths(kerneldir, fname),
m.group("ver"), version=m.group("ver"),
type)) type=type))
kernels = sorted(kernels, key=operator.attrgetter("type")) kernels = sorted(kernels, key=operator.attrgetter("type"))
return kernels return kernels