From 305cde6bdedf145310ead96ec542c1c175a0a009 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sat, 19 Jan 2013 20:29:16 -0800 Subject: [PATCH] Massive pyflakes import cleanup and broken CatalystError calls. Replace "import *" with named imports, remove unused imports. Fix broken CatalystError usage. --- catalyst/arch/alpha.py | 3 +- catalyst/arch/arm.py | 2 - catalyst/arch/hppa.py | 3 - catalyst/arch/ia64.py | 3 - catalyst/arch/mips.py | 3 - catalyst/arch/powerpc.py | 5 +- catalyst/arch/s390.py | 3 - catalyst/arch/sh.py | 3 - catalyst/arch/sparc.py | 5 +- catalyst/arch/x86.py | 5 +- catalyst/config.py | 9 +-- catalyst/contents.py | 8 +-- catalyst/defaults.py | 2 +- catalyst/hash_utils.py | 6 +- catalyst/lock.py | 5 +- catalyst/main.py | 28 ++++----- catalyst/support.py | 36 +++++++----- catalyst/targets/embedded_target.py | 8 +-- catalyst/targets/generic_stage_target.py | 75 +++++++++++++++--------- catalyst/targets/generic_target.py | 4 +- catalyst/targets/grp_target.py | 18 ++++-- catalyst/targets/livecd_stage1_target.py | 15 +++-- catalyst/targets/livecd_stage2_target.py | 28 ++++++--- catalyst/targets/netboot2_target.py | 22 +++++-- catalyst/targets/netboot_target.py | 26 +++++--- catalyst/targets/snapshot_target.py | 10 +++- catalyst/targets/stage1_target.py | 9 ++- catalyst/targets/stage2_target.py | 8 ++- catalyst/targets/stage3_target.py | 5 +- catalyst/targets/stage4_target.py | 5 +- catalyst/targets/tinderbox_target.py | 12 +++- targets/stage1/build.py | 4 +- 32 files changed, 231 insertions(+), 147 deletions(-) mode change 100644 => 100755 targets/stage1/build.py diff --git a/catalyst/arch/alpha.py b/catalyst/arch/alpha.py index 72480203..01b63822 100644 --- a/catalyst/arch/alpha.py +++ b/catalyst/arch/alpha.py @@ -1,8 +1,7 @@ -import os from catalyst import builder -from catalyst.support import * + class generic_alpha(builder.generic): "abstract base class for all alpha builders" diff --git a/catalyst/arch/arm.py b/catalyst/arch/arm.py index 8f207fff..c0d322ca 100644 --- a/catalyst/arch/arm.py +++ b/catalyst/arch/arm.py @@ -1,8 +1,6 @@ -import os from catalyst import builder -from catalyst.support import * class generic_arm(builder.generic): "Abstract base class for all arm (little endian) builders" diff --git a/catalyst/arch/hppa.py b/catalyst/arch/hppa.py index 3aac9b6a..c5589c4f 100644 --- a/catalyst/arch/hppa.py +++ b/catalyst/arch/hppa.py @@ -1,8 +1,5 @@ -import os - from catalyst import builder -from catalyst.support import * class generic_hppa(builder.generic): "Abstract base class for all hppa builders" diff --git a/catalyst/arch/ia64.py b/catalyst/arch/ia64.py index 40030853..3f060404 100644 --- a/catalyst/arch/ia64.py +++ b/catalyst/arch/ia64.py @@ -1,8 +1,5 @@ -import os - from catalyst import builder -from catalyst.support import * class arch_ia64(builder.generic): "builder class for ia64" diff --git a/catalyst/arch/mips.py b/catalyst/arch/mips.py index 7cce3921..5297a4b3 100644 --- a/catalyst/arch/mips.py +++ b/catalyst/arch/mips.py @@ -1,8 +1,5 @@ -import os - from catalyst import builder -from catalyst.support import * class generic_mips(builder.generic): "Abstract base class for all mips builders [Big-endian]" diff --git a/catalyst/arch/powerpc.py b/catalyst/arch/powerpc.py index 6cec5807..f903b38c 100644 --- a/catalyst/arch/powerpc.py +++ b/catalyst/arch/powerpc.py @@ -2,7 +2,7 @@ import os from catalyst import builder -from catalyst.support import * +from catalyst.support import CatalystError class generic_ppc(builder.generic): "abstract base class for all 32-bit powerpc builders" @@ -11,7 +11,8 @@ class generic_ppc(builder.generic): self.settings["CHOST"]="powerpc-unknown-linux-gnu" if self.settings["buildarch"]=="ppc64": if not os.path.exists("/bin/linux32") and not os.path.exists("/usr/bin/linux32"): - raise CatalystError,"required executable linux32 not found (\"emerge setarch\" to fix.)" + raise CatalystError("required executable linux32 not found " + "(\"emerge setarch\" to fix.)", print_traceback=True) self.settings["CHROOT"]="linux32 chroot" self.settings["crosscompile"] = False; else: diff --git a/catalyst/arch/s390.py b/catalyst/arch/s390.py index c49e0b76..f2cf80de 100644 --- a/catalyst/arch/s390.py +++ b/catalyst/arch/s390.py @@ -1,8 +1,5 @@ -import os - from catalyst import builder -from catalyst.support import * class generic_s390(builder.generic): "abstract base class for all s390 builders" diff --git a/catalyst/arch/sh.py b/catalyst/arch/sh.py index 1fa1b0b6..64d6e0e8 100644 --- a/catalyst/arch/sh.py +++ b/catalyst/arch/sh.py @@ -1,8 +1,5 @@ -import os - from catalyst import builder -from catalyst.support import * class generic_sh(builder.generic): "Abstract base class for all sh builders [Little-endian]" diff --git a/catalyst/arch/sparc.py b/catalyst/arch/sparc.py index 28895287..da2ad352 100644 --- a/catalyst/arch/sparc.py +++ b/catalyst/arch/sparc.py @@ -2,7 +2,7 @@ import os from catalyst import builder -from catalyst.support import * +from catalyst.support import CatalystError class generic_sparc(builder.generic): "abstract base class for all sparc builders" @@ -10,7 +10,8 @@ class generic_sparc(builder.generic): builder.generic.__init__(self,myspec) if self.settings["buildarch"]=="sparc64": if not os.path.exists("/bin/linux32") and not os.path.exists("/usr/bin/linux32"): - raise CatalystError,"required executable linux32 not found (\"emerge setarch\" to fix.)" + raise CatalystError("required executable linux32 not found " + "(\"emerge setarch\" to fix.)", print_traceback=True) self.settings["CHROOT"]="linux32 chroot" self.settings["crosscompile"] = False; else: diff --git a/catalyst/arch/x86.py b/catalyst/arch/x86.py index c8d19118..9f1bba24 100644 --- a/catalyst/arch/x86.py +++ b/catalyst/arch/x86.py @@ -2,7 +2,7 @@ import os from catalyst import builder -from catalyst.support import * +from catalyst.support import CatalystError class generic_x86(builder.generic): "abstract base class for all x86 builders" @@ -10,7 +10,8 @@ class generic_x86(builder.generic): builder.generic.__init__(self,myspec) if self.settings["buildarch"]=="amd64": if not os.path.exists("/bin/linux32") and not os.path.exists("/usr/bin/linux32"): - raise CatalystError,"required executable linux32 not found (\"emerge setarch\" to fix.)" + raise CatalystError("required executable linux32 not found " + "(\"emerge setarch\" to fix.)", print_traceback=True) self.settings["CHROOT"]="linux32 chroot" self.settings["crosscompile"] = False; else: diff --git a/catalyst/config.py b/catalyst/config.py index 0684855d..20153357 100644 --- a/catalyst/config.py +++ b/catalyst/config.py @@ -1,5 +1,5 @@ import re -from catalyst.support import * +from catalyst.support import CatalystError class ParserBase: @@ -26,7 +26,8 @@ class ParserBase: try: myf = open(filename, "r") except: - raise CatalystError, "Could not open file " + filename + raise CatalystError("Could not open file " + filename, + print_traceback=True) self.lines = myf.readlines() myf.close() self.filename = filename @@ -41,7 +42,7 @@ class ParserBase: cur_array = [] trailing_comment=re.compile('\s*#.*$') - white_space=re.compile('\s+') + #white_space=re.compile('\s+') for x, myline in enumerate(self.lines): myline = myline.strip() @@ -84,7 +85,7 @@ class ParserBase: # cur_array += mobjs cur_array += myline.split() else: - raise CatalystError, "Syntax error: " + x + raise CatalystError("Syntax error: " + x, print_traceback=True) # XXX: Do we really still need this "single value is a string" behavior? if len(cur_array) == 2: diff --git a/catalyst/contents.py b/catalyst/contents.py index 0ecabbd1..1a9ed28a 100644 --- a/catalyst/contents.py +++ b/catalyst/contents.py @@ -54,10 +54,10 @@ class ContentsMap(object): func = getattr(self, '_%s_' % self.contents_map[getter].func) return func(file_, self.contents_map[getter].cmd, verbose) except: - raise CatalystError,\ - "Error generating contents, is appropriate utility " +\ - "(%s) installed on your system?" \ - % (self.contents_map[getter].cmd) + raise CatalystError( + "Error generating contents, is appropriate utility " + + "(%s) installed on your system?" + % (self.contents_map[getter].cmd), print_traceback=True) @staticmethod diff --git a/catalyst/defaults.py b/catalyst/defaults.py index f87bc8bb..2a0a3ffb 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -1,7 +1,7 @@ # these should never be touched -required_build_targets = ["generic_target", "generic_stage_target"] +required_build_targets = ["generic_stage_target"] # new build types should be added here valid_build_targets = ["stage1_target", "stage2_target", "stage3_target", diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py index 0dfe98b6..b03c6ed1 100644 --- a/catalyst/hash_utils.py +++ b/catalyst/hash_utils.py @@ -49,8 +49,8 @@ class HashMap(object): verbose ) except: - raise CatalystError,"Error generating hash, is appropriate " + \ - "utility installed on your system?" + raise CatalystError("Error generating hash, is appropriate " + \ + "utility installed on your system?", traceback=True) def calc_hash(self, file_, hash_, verbose=False): @@ -71,7 +71,7 @@ class HashMap(object): mylines=mylines[0].split() result=mylines[0] if verbose: - print _hash_.id + " (%s) = %s" % (file_, result) + print _hash.id + " (%s) = %s" % (file_, result) return result diff --git a/catalyst/lock.py b/catalyst/lock.py index ef00b49c..b963af23 100644 --- a/catalyst/lock.py +++ b/catalyst/lock.py @@ -122,7 +122,7 @@ class LockDir: if self.myfd==None: if not os.path.exists(os.path.dirname(self.lockdir)): raise CatalystError("DirectoryNotFound: %s" - % os.path.dirname(self.lockdir)) + % os.path.dirname(self.lockdir), print_traceback=True) if not os.path.exists(self.lockfile): old_mask=os.umask(000) self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660) @@ -265,7 +265,8 @@ class LockDir: self.add_hardlock_file_to_cleanup() if not os.path.exists(self.myhardlock): raise CatalystError("FileNotFound: Created lockfile is missing: " - "%(filename)s" % {"filename":self.myhardlock}) + "%(filename)s" % {"filename":self.myhardlock}, + print_traceback=True) try: os.link(self.myhardlock, self.lockfile) except SystemExit: diff --git a/catalyst/main.py b/catalyst/main.py index 21815455..936a9960 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -7,8 +7,10 @@ # Chris Gianelloni # $Id$ -import os, sys, imp, string, getopt -import pdb +import os +import sys +import imp +import getopt import os.path __selfpath__ = os.path.abspath(os.path.dirname(__file__)) @@ -154,8 +156,8 @@ def import_modules(): fh.close() except IOError: - raise CatalystError, "Can't find " + x + ".py plugin in " + \ - module_dir + raise CatalystError("Can't find " + x + ".py plugin in " + + module_dir, print_traceback=True) for x in valid_build_targets: try: fh=open(module_dir + x + ".py") @@ -165,8 +167,8 @@ def import_modules(): fh.close() except IOError: - raise CatalystError,"Can't find " + x + ".py plugin in " + \ - module_dir + raise CatalystError("Can't find " + x + ".py plugin in " + + module_dir, print_traceback=True) except ImportError as e: print "!!! catalyst: Python modules not found in "+\ @@ -179,15 +181,18 @@ def import_modules(): def build_target(addlargs, targetmap): try: if addlargs["target"] not in targetmap: - raise CatalystError, \ - "Target \"%s\" not available." % addlargs["target"] + raise CatalystError( + "Target \"%s\" not available." % addlargs["target"], + print_traceback=True) mytarget=targetmap[addlargs["target"]](conf_values, addlargs) mytarget.run() except: + print "Python traceback output follows:" catalyst.util.print_traceback() + print print "!!! catalyst: Error encountered during run of target " + \ addlargs["target"] sys.exit(1) @@ -219,14 +224,9 @@ def main(): usage() sys.exit(2) - # defaults for commandline opts - debug=False - verbose=False - fetch=False myconfig="" myspecfile="" mycmdline=[] - myopts=[] # check preconditions if len(opts) == 0: @@ -367,7 +367,7 @@ def main(): sys.exit(1) if "target" not in addlargs: - raise CatalystError, "Required value \"target\" not specified." + raise CatalystError("Required value \"target\" not specified.") # everything is setup, so the build is a go try: diff --git a/catalyst/support.py b/catalyst/support.py index 0940db58..2c394186 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -2,7 +2,7 @@ import sys,string,os,types,re,signal,traceback,time #import md5,sha -from catalyst.defaults import verbosity +from catalyst.defaults import verbosity, valid_config_file_values selinux_capable = False #userpriv_capable = (os.getuid() == 0) @@ -71,7 +71,7 @@ def read_from_clst(file): myf=open(file,"r") except: return -1 - #raise CatalystError, "Could not open file "+file + #raise CatalystError("Could not open file "+file) for line in myf.readlines(): #line = string.replace(line, "\n", "") # drop newline myline = myline + line @@ -104,12 +104,14 @@ def list_to_string(mylist): return mypack class CatalystError(Exception): - def __init__(self, message): + def __init__(self, message, print_traceback=False): if message: - (type,value)=sys.exc_info()[:2] - if value!=None: - print - print traceback.print_exc(file=sys.stdout) + if print_traceback: + (type,value)=sys.exc_info()[:2] + if value!=None: + print + print "Traceback valuse found. listing..." + print traceback.print_exc(file=sys.stdout) print print "!!! catalyst: "+message print @@ -371,7 +373,8 @@ def cmd(mycmd,myexc="",env={}): sys.stdout.flush() retval=spawn_bash(mycmd,env) if retval != 0: - raise CatalystError,myexc + raise CatalystError("cmd() NON-zero return value from: %s" % myexc, + print_traceback=True) except: raise @@ -398,14 +401,17 @@ def file_locate(settings,filelist,expand=1): pass else: if len(settings[myfile])==0: - raise CatalystError, "File variable \""+myfile+"\" has a length of zero (not specified.)" + raise CatalystError("File variable \"" + myfile + + "\" has a length of zero (not specified.)", print_traceback=True) if settings[myfile][0]=="/": if not os.path.exists(settings[myfile]): - raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile] + raise CatalystError("Cannot locate specified " + myfile + + ": "+settings[myfile], print_traceback=True) elif expand and os.path.exists(os.getcwd()+"/"+settings[myfile]): settings[myfile]=os.getcwd()+"/"+settings[myfile] else: - raise CatalystError, "Cannot locate specified "+myfile+": "+settings[myfile]+" (2nd try)" + raise CatalystError("Cannot locate specified " + myfile + + ": "+settings[myfile]+" (2nd try)" + """ Spec file format: @@ -426,6 +432,7 @@ that the order of multiple-value items is preserved, but the order that the item defined are not preserved. In other words, "foo", "bar", "oni" ordering is preserved but "item1" "item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash). """ +, print_traceback=True) def parse_makeconf(mylines): mymakeconf={} @@ -469,7 +476,8 @@ def read_makeconf(mymakeconffile): myf.close() return parse_makeconf(mylines) except: - raise CatalystError, "Could not parse make.conf file "+mymakeconffile + raise CatalystError("Could not parse make.conf file " + + mymakeconffile, print_traceback=True) else: makeconf={} return makeconf @@ -519,14 +527,14 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec): messages.append("Required argument \""+x+"\" not specified.") if messages: - raise CatalystError, '\n\tAlso: '.join(messages) + raise CatalystError('\n\tAlso: '.join(messages)) def touch(myfile): try: myf=open(myfile,"w") myf.close() except IOError: - raise CatalystError, "Could not touch "+myfile+"." + raise CatalystError("Could not touch "+myfile+".", print_traceback=True) def countdown(secs=5, doing="Starting"): if secs: diff --git a/catalyst/targets/embedded_target.py b/catalyst/targets/embedded_target.py index 7cee7a66..cbc2684d 100644 --- a/catalyst/targets/embedded_target.py +++ b/catalyst/targets/embedded_target.py @@ -10,10 +10,10 @@ ROOT=/tmp/submerge emerge --something foo bar . """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -import os,string,imp,types,shutil -from catalyst.support import * -from generic_stage_target import * -from stat import * + +from catalyst.support import normpath + +from generic_stage_target import generic_stage_target class embedded_target(generic_stage_target): """ diff --git a/catalyst/targets/generic_stage_target.py b/catalyst/targets/generic_stage_target.py index 078e6b50..8c209b7c 100644 --- a/catalyst/targets/generic_stage_target.py +++ b/catalyst/targets/generic_stage_target.py @@ -1,7 +1,18 @@ -import os,string,imp,types,shutil -from catalyst.support import * -from generic_target import * -from stat import * + +import os +import string +import imp +import types +import shutil +import sys +from stat import ST_UID, ST_GID, ST_MODE + + +from catalyst.support import (CatalystError, msg, file_locate, normpath, + touch, cmd, warn, list_bashify, countdown, read_makeconf, read_from_clst, + ismount) + +from generic_target import generic_target from catalyst.lock import LockDir @@ -81,7 +92,7 @@ class generic_stage_target(generic_target): if "chost" in self.settings: hostmachine = self.settings["chost"].split("-")[0] if hostmachine not in machinemap: - raise CatalystError, "Unknown host machine type "+hostmachine + raise CatalystError("Unknown host machine type "+hostmachine) self.settings["hostarch"]=machinemap[hostmachine] else: hostmachine = self.settings["subarch"] @@ -93,7 +104,7 @@ class generic_stage_target(generic_target): else: buildmachine = os.uname()[4] if buildmachine not in machinemap: - raise CatalystError, "Unknown build machine type "+buildmachine + raise CatalystError("Unknown build machine type "+buildmachine) self.settings["buildarch"]=machinemap[buildmachine] self.settings["crosscompile"]=(self.settings["hostarch"]!=\ self.settings["buildarch"]) @@ -212,9 +223,9 @@ class generic_stage_target(generic_target): else: ccdir="/root/.ccache" if not os.path.isdir(ccdir): - raise CatalystError,\ + raise CatalystError( "Compiler cache support can't be enabled (can't find "+\ - ccdir+")" + ccdir+")") self.mounts.append("ccache") self.mountmap["ccache"]=ccdir """ for the chroot: """ @@ -270,8 +281,9 @@ class generic_stage_target(generic_target): def set_source_subpath(self): if type(self.settings["source_subpath"])!=types.StringType: - raise CatalystError,\ - "source_subpath should have been a string. Perhaps you have something wrong in your spec file?" + raise CatalystError( + "source_subpath should have been a string. Perhaps you have " +\ + "something wrong in your spec file?") def set_pkgcache_path(self): if "pkgcache_path" in self.settings: @@ -464,8 +476,8 @@ class generic_stage_target(generic_target): self.settings["iso_volume_id"]=\ self.settings[self.settings["spec_prefix"]+"/volid"] if len(self.settings["iso_volume_id"])>32: - raise CatalystError,\ - "ISO volume ID must not exceed 32 characters." + raise CatalystError( + "ISO volume ID must not exceed 32 characters.") else: self.settings["iso_volume_id"]="catalyst "+self.settings["snapshot"] @@ -624,11 +636,13 @@ class generic_stage_target(generic_target): """ Try to umount stuff ourselves """ self.unbind() if ismount(mypath + self.mountmap[x]): - raise CatalystError, "Auto-unbind failed for " + self.mountmap[x] + raise CatalystError("Auto-unbind failed for " + + self.mountmap[x]) else: print "Auto-unbind successful..." except CatalystError: - raise CatalystError, "Unable to auto-unbind " + self.mountmap[x] + raise CatalystError("Unable to auto-unbind " + + self.mountmap[x]) def unpack(self): unpack=True @@ -722,8 +736,8 @@ class generic_stage_target(generic_target): invalid_snapshot=True elif os.path.isdir(self.settings["source_path"]): """ We should never reach this, so something is very wrong """ - raise CatalystError,\ - "source path is a dir but seedcache is not enabled" + raise CatalystError( + "source path is a dir but seedcache is not enabled") if unpack: self.mount_safety_check() @@ -924,7 +938,7 @@ class generic_stage_target(generic_target): self.settings["chroot_path"] + src) if retval!=0: self.unbind() - raise CatalystError,"Couldn't bind mount " + src + raise CatalystError("Couldn't bind mount " + src) def unbind(self): ouch=0 @@ -970,8 +984,8 @@ class generic_stage_target(generic_target): this to potentially prevent an upcoming bash stage cleanup script from wiping our bind mounts. """ - raise CatalystError,\ - "Couldn't umount one or more bind-mounts; aborting for safety." + raise CatalystError( + "Couldn't umount one or more bind-mounts; aborting for safety.") def chroot_setup(self): self.makeconf=read_makeconf(self.settings["chroot_path"]+\ @@ -995,8 +1009,9 @@ class generic_stage_target(generic_target): """ Copy over the envscript, if applicable """ if "envscript" in self.settings: if not os.path.exists(self.settings["envscript"]): - raise CatalystError,\ - "Can't find envscript "+self.settings["envscript"] + raise CatalystError( + "Can't find envscript " + self.settings["envscript"], + print_traceback=True) print "\nWarning!!!!" print "\tOverriding certain env variables may cause catastrophic failure." @@ -1195,7 +1210,7 @@ class generic_stage_target(generic_target): except: self.unbind() - raise CatalystError, "Build failed, could not execute preclean" + raise CatalystError("Build failed, could not execute preclean") def capture(self): if "autoresume" in self.settings["options"] \ @@ -1235,7 +1250,8 @@ class generic_stage_target(generic_target): except CatalystError: self.unbind() - raise CatalystError,"Stage build aborting due to error." + raise CatalystError("Stage build aborting due to error.", + print_traceback=True) def setup_environment(self): """ @@ -1393,8 +1409,8 @@ class generic_stage_target(generic_target): touch(self.settings["autoresume_path"]+"build_packages") except CatalystError: self.unbind() - raise CatalystError,self.settings["spec_prefix"]+\ - "build aborting due to error." + raise CatalystError(self.settings["spec_prefix"]+\ + "build aborting due to error.") def build_kernel(self): if "autoresume" in self.settings["options"] \ @@ -1417,8 +1433,9 @@ class generic_stage_target(generic_target): touch(self.settings["autoresume_path"]+"build_kernel") except CatalystError: self.unbind() - raise CatalystError,\ - "build aborting due to kernel build error." + raise CatalystError( + "build aborting due to kernel build error.", + print_traceback=True) def _build_kernel(self, kname): "Build a single configured kernel by name" @@ -1531,7 +1548,7 @@ class generic_stage_target(generic_target): touch(self.settings["autoresume_path"]+"bootloader") except CatalystError: self.unbind() - raise CatalystError,"Script aborting due to error." + raise CatalystError("Script aborting due to error.") def livecd_update(self): if "autoresume" in self.settings["options"] \ @@ -1546,7 +1563,7 @@ class generic_stage_target(generic_target): except CatalystError: self.unbind() - raise CatalystError,"build aborting due to livecd_update error." + raise CatalystError("build aborting due to livecd_update error.") def clear_chroot(self): myemp=self.settings["chroot_path"] diff --git a/catalyst/targets/generic_target.py b/catalyst/targets/generic_target.py index de519942..d3b9511e 100644 --- a/catalyst/targets/generic_target.py +++ b/catalyst/targets/generic_target.py @@ -1,4 +1,6 @@ -from catalyst.support import * + + +from catalyst.support import addl_arg_parse class generic_target: """ diff --git a/catalyst/targets/grp_target.py b/catalyst/targets/grp_target.py index a8309a81..7c921334 100644 --- a/catalyst/targets/grp_target.py +++ b/catalyst/targets/grp_target.py @@ -3,9 +3,16 @@ Gentoo Reference Platform (GRP) target """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -import os,types,glob -from catalyst.support import * -from generic_stage_target import * +import os +import types +import glob + + +from catalyst.support import (CatalystError, normpath, + touch, cmd, list_bashify) + +from generic_stage_target import generic_stage_target + class grp_target(generic_stage_target): """ @@ -18,7 +25,7 @@ class grp_target(generic_stage_target): self.valid_values=self.required_values[:] self.valid_values.extend(["grp/use"]) if "grp" not in addlargs: - raise CatalystError,"Required value \"grp\" not specified in spec." + raise CatalystError("Required value \"grp\" not specified in spec.") self.required_values.extend(["grp"]) if type(addlargs["grp"])==types.StringType: @@ -59,7 +66,8 @@ class grp_target(generic_stage_target): except CatalystError: self.unbind() - raise CatalystError,"GRP build aborting due to error." + raise CatalystError("GRP build aborting due to error.", + print_traceback=True) def set_use(self): generic_stage_target.set_use(self) diff --git a/catalyst/targets/livecd_stage1_target.py b/catalyst/targets/livecd_stage1_target.py index 6273c9e8..9a53fd13 100644 --- a/catalyst/targets/livecd_stage1_target.py +++ b/catalyst/targets/livecd_stage1_target.py @@ -3,8 +3,16 @@ LiveCD stage1 target """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -from catalyst.support import * -from generic_stage_target import * +import os +import types +import string + + +from catalyst.support import (normpath, + touch, cmd) + +from generic_stage_target import generic_stage_target + class livecd_stage1_target(generic_stage_target): """ @@ -38,9 +46,6 @@ class livecd_stage1_target(generic_stage_target): if not os.path.exists(self.settings["target_path"]): os.makedirs(self.settings["target_path"]) - def set_target_path(self): - pass - def set_spec_prefix(self): self.settings["spec_prefix"]="livecd" diff --git a/catalyst/targets/livecd_stage2_target.py b/catalyst/targets/livecd_stage2_target.py index e89ed73b..ed398578 100644 --- a/catalyst/targets/livecd_stage2_target.py +++ b/catalyst/targets/livecd_stage2_target.py @@ -3,9 +3,13 @@ LiveCD stage2 target, builds upon previous LiveCD stage1 tarball """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -import os,string,types,stat,shutil -from catalyst.support import * -from generic_stage_target import * +import os + + +from catalyst.support import (normpath, file_locate, CatalystError, cmd, + read_from_clst, touch) +from generic_stage_target import generic_stage_target + class livecd_stage2_target(generic_stage_target): """ @@ -35,11 +39,15 @@ class livecd_stage2_target(generic_stage_target): def set_source_path(self): self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2") if os.path.isfile(self.settings["source_path"]): - self.settings["source_path_hash"]=generate_hash(self.settings["source_path"]) + self.settings["source_path_hash"] = \ + self.settings["hash_map"].generate_hash( + self.settings["source_path"]) else: self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/") if not os.path.exists(self.settings["source_path"]): - raise CatalystError,"Source Path: "+self.settings["source_path"]+" does not exist." + raise CatalystError("Source Path: " + + self.settings["source_path"] + " does not exist.", + print_traceback=True) def set_spec_prefix(self): self.settings["spec_prefix"]="livecd" @@ -65,7 +73,10 @@ class livecd_stage2_target(generic_stage_target): myf=open(self.settings["chroot_path"]+"/etc/modprobe.d/blacklist.conf","a") except: self.unbind() - raise CatalystError,"Couldn't open "+self.settings["chroot_path"]+"/etc/modprobe.d/blacklist.conf." + raise CatalystError("Couldn't open " + + self.settings["chroot_path"] + + "/etc/modprobe.d/blacklist.conf.", + print_traceback=True) myf.write("\n#Added by Catalyst:") for x in self.settings["livecd/modblacklist"]: @@ -114,7 +125,10 @@ class livecd_stage2_target(generic_stage_target): os.makedirs(self.settings["pkgcache_path"],0755) if not display_msg: - raise CatalystError,"Could not find appropriate source. Please check the 'source_subpath' setting in the spec file." + raise CatalystError("Could not find appropriate source.\n" + "Please check the 'source_subpath' " + "setting in the spec file.", + print_traceback=True) print display_msg cmd(unpack_cmd,error_msg,env=self.env) diff --git a/catalyst/targets/netboot2_target.py b/catalyst/targets/netboot2_target.py index 8809dd0f..3077cf70 100644 --- a/catalyst/targets/netboot2_target.py +++ b/catalyst/targets/netboot2_target.py @@ -3,9 +3,17 @@ netboot target, version 2 """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -import os,string,types -from catalyst.support import * -from generic_stage_target import * +import os +import types +import shutil +from stat import ST_UID, ST_GID, ST_MODE + + +from catalyst.support import (CatalystError, normpath, + touch, cmd, list_bashify) + +from generic_stage_target import generic_stage_target + class netboot2_target(generic_stage_target): """ @@ -36,7 +44,7 @@ class netboot2_target(generic_stage_target): for x in loopy: self.valid_values.append("netboot2/packages/"+x+"/files") except: - raise CatalystError,"configuration error in netboot2/packages." + raise CatalystError("configuration error in netboot2/packages.") generic_stage_target.__init__(self,spec,addlargs) self.set_build_kernel_vars() @@ -91,7 +99,8 @@ class netboot2_target(generic_stage_target): " image " + list_bashify(myfiles),env=self.env) except CatalystError: self.unbind() - raise CatalystError,"Failed to copy files to image!" + raise CatalystError("Failed to copy files to image!", + print_traceback=True) touch(self.settings["autoresume_path"]+"copy_files_to_image") @@ -117,7 +126,8 @@ class netboot2_target(generic_stage_target): print ">>> Netboot Build Finished!" except CatalystError: self.unbind() - raise CatalystError,"Failed to move kernel images!" + raise CatalystError("Failed to move kernel images!", + print_traceback=True) def remove(self): if "autoresume" in self.settings["options"] \ diff --git a/catalyst/targets/netboot_target.py b/catalyst/targets/netboot_target.py index 9d01b7e2..c2e40b61 100644 --- a/catalyst/targets/netboot_target.py +++ b/catalyst/targets/netboot_target.py @@ -3,9 +3,15 @@ netboot target, version 1 """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -import os,string,types -from catalyst.support import * -from generic_stage_target import * +import os +import types + + +from catalyst.support import (CatalystError, normpath, + cmd, list_bashify, file_locate) + +from generic_stage_target import generic_stage_target + class netboot_target(generic_stage_target): """ @@ -34,7 +40,7 @@ class netboot_target(generic_stage_target): # for x in loopy: # self.required_values.append("netboot/packages/"+x+"/files") except: - raise CatalystError,"configuration error in netboot/packages." + raise CatalystError("configuration error in netboot/packages.") generic_stage_target.__init__(self,spec,addlargs) self.set_build_kernel_vars(addlargs) @@ -62,7 +68,8 @@ class netboot_target(generic_stage_target): # cmd("/bin/bash "+self.settings["controller_file"]+" packages "+mypack,env=self.env) # except CatalystError: # self.unbind() -# raise CatalystError,"netboot build aborting due to error." +# raise CatalystError("netboot build aborting due to error.", +# print_traceback=True) def build_busybox(self): # build busybox @@ -74,7 +81,8 @@ class netboot_target(generic_stage_target): cmd("/bin/bash "+self.settings["controller_file"]+" busybox "+ mycmd,env=self.env) except CatalystError: self.unbind() - raise CatalystError,"netboot build aborting due to error." + raise CatalystError("netboot build aborting due to error.", + print_traceback=True) def copy_files_to_image(self): # create image @@ -103,7 +111,8 @@ class netboot_target(generic_stage_target): " image " + list_bashify(myfiles),env=self.env) except CatalystError: self.unbind() - raise CatalystError,"netboot build aborting due to error." + raise CatalystError("netboot build aborting due to error.", + print_traceback=True) def create_netboot_files(self): # finish it all up @@ -111,7 +120,8 @@ class netboot_target(generic_stage_target): cmd("/bin/bash "+self.settings["controller_file"]+" finish",env=self.env) except CatalystError: self.unbind() - raise CatalystError,"netboot build aborting due to error." + raise CatalystError("netboot build aborting due to error.", + print_traceback=True) # end print "netboot: build finished !" diff --git a/catalyst/targets/snapshot_target.py b/catalyst/targets/snapshot_target.py index 0329a612..4fecef39 100644 --- a/catalyst/targets/snapshot_target.py +++ b/catalyst/targets/snapshot_target.py @@ -3,8 +3,12 @@ Snapshot target """ import os -from catalyst.support import * -from generic_stage_target import * +import shutil +from stat import ST_UID, ST_GID, ST_MODE + + +from catalyst.support import normpath, cmd +from generic_stage_target import generic_stage_target class snapshot_target(generic_stage_target): """ @@ -14,7 +18,7 @@ class snapshot_target(generic_stage_target): self.required_values=["version_stamp","target"] self.valid_values=["version_stamp","target"] - generic_target.__init__(self,myspec,addlargs) + generic_stage_target.__init__(self,myspec,addlargs) self.settings=myspec self.settings["target_subpath"]="portage" st=self.settings["storedir"] diff --git a/catalyst/targets/stage1_target.py b/catalyst/targets/stage1_target.py index 25f7116e..57d2b6aa 100644 --- a/catalyst/targets/stage1_target.py +++ b/catalyst/targets/stage1_target.py @@ -3,8 +3,13 @@ stage1 target """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -from catalyst.support import * -from generic_stage_target import * + +import os + + +from catalyst.support import normpath, list_to_string +from generic_stage_target import generic_stage_target + class stage1_target(generic_stage_target): """ diff --git a/catalyst/targets/stage2_target.py b/catalyst/targets/stage2_target.py index 94d4a1e7..ad06935f 100644 --- a/catalyst/targets/stage2_target.py +++ b/catalyst/targets/stage2_target.py @@ -3,8 +3,12 @@ stage2 target, builds upon previous stage1 tarball """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -from catalyst.support import * -from generic_stage_target import * +import os + + +from catalyst.support import normpath, list_to_string +from generic_stage_target import generic_stage_target + class stage2_target(generic_stage_target): """ diff --git a/catalyst/targets/stage3_target.py b/catalyst/targets/stage3_target.py index 89edd661..63b9ebc7 100644 --- a/catalyst/targets/stage3_target.py +++ b/catalyst/targets/stage3_target.py @@ -3,8 +3,9 @@ stage3 target, builds upon previous stage2/stage3 tarball """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -from catalyst.support import * -from generic_stage_target import * + +from generic_stage_target import generic_stage_target + class stage3_target(generic_stage_target): """ diff --git a/catalyst/targets/stage4_target.py b/catalyst/targets/stage4_target.py index e2b8a79a..9b48e6f9 100644 --- a/catalyst/targets/stage4_target.py +++ b/catalyst/targets/stage4_target.py @@ -3,8 +3,9 @@ stage4 target, builds upon previous stage3/stage4 tarball """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -from catalyst.support import * -from generic_stage_target import * + +from generic_stage_target import generic_stage_target + class stage4_target(generic_stage_target): """ diff --git a/catalyst/targets/tinderbox_target.py b/catalyst/targets/tinderbox_target.py index 5985c5bb..8ebca21f 100644 --- a/catalyst/targets/tinderbox_target.py +++ b/catalyst/targets/tinderbox_target.py @@ -3,8 +3,13 @@ Tinderbox target """ # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation. -from catalyst.support import * -from generic_stage_target import * + +import os + + +from catalyst.support import cmd, list_bashify, CatalystError +from generic_stage_target import generic_stage_target + class tinderbox_target(generic_stage_target): """ @@ -26,7 +31,8 @@ class tinderbox_target(generic_stage_target): except CatalystError: self.unbind() - raise CatalystError,"Tinderbox aborting due to error." + raise CatalystError("Tinderbox aborting due to error.", + print_traceback=True) def set_cleanables(self): self.settings["cleanables"]=["/etc/resolv.conf","/var/tmp/*","/root/*", diff --git a/targets/stage1/build.py b/targets/stage1/build.py old mode 100644 new mode 100755 index bf20bcf3..b2c8b0fb --- a/targets/stage1/build.py +++ b/targets/stage1/build.py @@ -1,6 +1,8 @@ #!/usr/bin/python -import os,portage,sys +import os +import sys +import portage # this loads files from the profiles ... # wrap it here to take care of the different -- 2.26.2