From: Andrew Gaffney Date: Mon, 12 Jan 2009 00:02:38 +0000 (-0600) Subject: Small cleanups to make pychecker happy X-Git-Tag: CATALYST-2.0.10~3^2~190 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=746481981a72782151841627c43e83f127317880;p=catalyst.git Small cleanups to make pychecker happy --- diff --git a/ChangeLog b/ChangeLog index 42ad6a91..931b897e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,22 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 12 Jan 2009; Andrew Gaffney + modules/catalyst/__init__.py, modules/catalyst/arch/__init__.py, + modules/catalyst/arch/alpha.py, modules/catalyst/arch/arm.py, + modules/catalyst/arch/hppa.py, modules/catalyst/arch/ia64.py, + modules/catalyst/arch/mips.py, modules/catalyst/arch/s390.py, + modules/catalyst/arch/sh.py, modules/catalyst/config.py, + modules/catalyst/error.py, modules/catalyst/hash.py, + modules/catalyst/output.py, modules/catalyst/spawn.py, + modules/catalyst/support.py, modules/catalyst/target/__init__.py, + modules/catalyst/target/embedded.py, + modules/catalyst/target/generic_stage.py, + modules/catalyst/target/livecd_stage1.py, + modules/catalyst/target/livecd_stage2.py, + modules/catalyst/target/netboot.py, modules/catalyst/util.py: + Small cleanups to make pychecker happy + 11 Jan 2009; Andrew Gaffney modules/catalyst/support.py, modules/catalyst/util.py: import cleanups diff --git a/modules/catalyst/__init__.py b/modules/catalyst/__init__.py index e69de29b..ec0b62d8 100644 --- a/modules/catalyst/__init__.py +++ b/modules/catalyst/__init__.py @@ -0,0 +1,15 @@ +import catalyst.hash +import catalyst.arch +import catalyst.lock +import catalyst.util +import catalyst.error +import catalyst.spawn +import catalyst.target + +hash = catalyst.hash +arch = catalyst.arch +lock = catalyst.lock +util = catalyst.util +error = catalyst.error +spawn = catalyst.spawn +target = catalyst.target diff --git a/modules/catalyst/arch/__init__.py b/modules/catalyst/arch/__init__.py index c934986e..99628eda 100644 --- a/modules/catalyst/arch/__init__.py +++ b/modules/catalyst/arch/__init__.py @@ -3,17 +3,16 @@ Parent module of all arch modules """ import os -import imp import catalyst.util from catalyst.output import warn -def find_arch_modules(self): +def find_arch_modules(): search_dir = os.path.abspath(os.path.dirname(__file__)) arch_module_list = [x[:-3] for x in os.listdir(search_dir) \ if x.endswith('.py') and not x.startswith('__')] return arch_module_list -def get_arches(self): +def get_arches(): arch_modules = {} for x in find_arch_modules(): arch_modules[x] = catalyst.util.load_module("catalyst.arch." + x) diff --git a/modules/catalyst/arch/alpha.py b/modules/catalyst/arch/alpha.py index 9bcf229f..ec8c9e04 100644 --- a/modules/catalyst/arch/alpha.py +++ b/modules/catalyst/arch/alpha.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class generic_alpha(catalyst.arch.generic_arch): diff --git a/modules/catalyst/arch/arm.py b/modules/catalyst/arch/arm.py index e4bc2c52..1599f2dd 100644 --- a/modules/catalyst/arch/arm.py +++ b/modules/catalyst/arch/arm.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class generic_arm(catalyst.arch.generic_arch): diff --git a/modules/catalyst/arch/hppa.py b/modules/catalyst/arch/hppa.py index be382cbc..39c38d22 100644 --- a/modules/catalyst/arch/hppa.py +++ b/modules/catalyst/arch/hppa.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class generic_hppa(catalyst.arch.generic_arch): diff --git a/modules/catalyst/arch/ia64.py b/modules/catalyst/arch/ia64.py index cf74a8a6..ceffff4a 100644 --- a/modules/catalyst/arch/ia64.py +++ b/modules/catalyst/arch/ia64.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class arch_ia64(catalyst.arch.generic_arch): diff --git a/modules/catalyst/arch/mips.py b/modules/catalyst/arch/mips.py index de0ab3e1..9b2f30a7 100644 --- a/modules/catalyst/arch/mips.py +++ b/modules/catalyst/arch/mips.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class generic_mips(catalyst.arch.generic_arch): diff --git a/modules/catalyst/arch/s390.py b/modules/catalyst/arch/s390.py index 6c652c4c..ba8d8a63 100644 --- a/modules/catalyst/arch/s390.py +++ b/modules/catalyst/arch/s390.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class generic_s390(catalyst.arch.generic_arch): diff --git a/modules/catalyst/arch/sh.py b/modules/catalyst/arch/sh.py index 0c7690ba..485feb37 100644 --- a/modules/catalyst/arch/sh.py +++ b/modules/catalyst/arch/sh.py @@ -1,5 +1,5 @@ -import catalyst.arch,os +import catalyst.arch from catalyst.support import * class generic_sh(catalyst.arch.generic_arch): diff --git a/modules/catalyst/config.py b/modules/catalyst/config.py index 746a2c68..ba9d03d1 100644 --- a/modules/catalyst/config.py +++ b/modules/catalyst/config.py @@ -41,7 +41,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() diff --git a/modules/catalyst/error.py b/modules/catalyst/error.py index cc22e9b6..66ab3e0c 100644 --- a/modules/catalyst/error.py +++ b/modules/catalyst/error.py @@ -8,7 +8,7 @@ import catalyst.output class CatalystError(Exception): def __init__(self, message): if message: - (type,value)=sys.exc_info()[:2] + (extype,value)=sys.exc_info()[:2] if value!=None: print print traceback.print_exc(file=sys.stdout) @@ -19,7 +19,7 @@ class CatalystError(Exception): class LockInUse(Exception): def __init__(self, message): if message: - #(type,value)=sys.exc_info()[:2] + #(extype,value)=sys.exc_info()[:2] #if value!=None: #print #kprint traceback.print_exc(file=sys.stdout) diff --git a/modules/catalyst/hash.py b/modules/catalyst/hash.py index 7392010e..bdcb0997 100644 --- a/modules/catalyst/hash.py +++ b/modules/catalyst/hash.py @@ -4,6 +4,7 @@ This module contains functions for generating the CONTENTS and hash files import os from catalyst.error import * +from catalyst.output import warn def generate_contents(file, contents_function="auto", verbose=False): try: @@ -75,9 +76,9 @@ def calc_hash2(file, cmd, cmd_args, id_string="MD5", verbose=False): header = a.readline() myline = a.readline().split() a.close() - hash = myline[0] + tmphash = myline[0] short_file = os.path.split(myline[1])[1] - result = header + hash + " " + short_file + "\n" + result = header + tmphash + " " + short_file + "\n" if verbose: print "%s (%s) = %s" % (header, short_file, result) return result diff --git a/modules/catalyst/output.py b/modules/catalyst/output.py index 27dac0a4..e3030eb4 100644 --- a/modules/catalyst/output.py +++ b/modules/catalyst/output.py @@ -4,6 +4,8 @@ This module contains miscellaneous functions for outputting messages import sys +verbosity = 1 + def msg(mymsg, verblevel=1): if verbosity >= verblevel: print mymsg diff --git a/modules/catalyst/spawn.py b/modules/catalyst/spawn.py index bfd76612..7f26cd7d 100644 --- a/modules/catalyst/spawn.py +++ b/modules/catalyst/spawn.py @@ -2,7 +2,7 @@ This module contains all the functions related to spawning external commands """ -import sys, os, types +import sys, os, types, signal import catalyst.util from catalyst.error import * @@ -14,7 +14,7 @@ selinux_capable = False try: import resource - max_fd_limit=resource.getrlimit(RLIMIT_NOFILE) + max_fd_limit=resource.getrlimit(resource.RLIMIT_NOFILE) except SystemExit, e: raise except: diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index e2d7afe6..5e196349 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -24,8 +24,6 @@ valid_config_file_values.append("digests") valid_config_file_values.append("contents") valid_config_file_values.append("SEEDCACHE") -verbosity=1 - """ Spec file format: diff --git a/modules/catalyst/target/__init__.py b/modules/catalyst/target/__init__.py index 8e23b521..8688e081 100644 --- a/modules/catalyst/target/__init__.py +++ b/modules/catalyst/target/__init__.py @@ -3,7 +3,6 @@ Parent module of all target modules """ import os -import imp import catalyst.util from catalyst.output import warn diff --git a/modules/catalyst/target/embedded.py b/modules/catalyst/target/embedded.py index 5a3bc4bf..c116deda 100644 --- a/modules/catalyst/target/embedded.py +++ b/modules/catalyst/target/embedded.py @@ -24,7 +24,7 @@ class embedded_target(generic_stage_target): self.valid_values.append("embedded/fs-ops") generic_stage_target.__init__(self,spec,addlargs) - self.set_build_kernel_vars(addlargs) + self.set_build_kernel_vars() def set_action_sequence(self): self.settings["action_sequence"]=["dir_setup","unpack","unpack_snapshot",\ diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 222f586c..9688077a 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -4,7 +4,7 @@ This class does all of the chroot setup, copying of files, etc. It is the driver class for pretty much everything that Catalyst does. """ -import os,string,imp,types,shutil +import os, string, types, shutil from catalyst.support import * from catalyst.target.generic import * from stat import * @@ -1609,15 +1609,15 @@ class generic_stage_target(generic_target): for f in [file, file+'.CONTENTS']: if os.path.exists(f): if "all" in array: - for k in hash_map.keys(): - hash=catalyst.hash.generate_hash(f,hash_function=k,verbose=\ + for k in catalyst.hash.hash_map.keys(): + tmphash=catalyst.hash.generate_hash(f,hash_function=k,verbose=\ ("VERBOSE" in self.settings)) - myf.write(hash) + myf.write(tmphash) else: for j in array: - hash=catalyst.hash.generate_hash(f,hash_function=j,verbose=\ + tmphash=catalyst.hash.generate_hash(f,hash_function=j,verbose=\ ("VERBOSE" in self.settings)) - myf.write(hash) + myf.write(tmphash) myf.close() def purge(self): diff --git a/modules/catalyst/target/livecd_stage1.py b/modules/catalyst/target/livecd_stage1.py index 65d73b97..5cbc73fc 100644 --- a/modules/catalyst/target/livecd_stage1.py +++ b/modules/catalyst/target/livecd_stage1.py @@ -21,6 +21,7 @@ class livecd_stage1_target(generic_stage_target): "config_profile_link","setup_confdir","portage_overlay",\ "bind","chroot_setup","setup_environment","build_packages",\ "unbind", "clean","clear_autoresume"] + def set_target_path(self): self.settings["target_path"]=catalyst.util.normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]) if "AUTORESUME" in self.settings \ @@ -39,8 +40,9 @@ class livecd_stage1_target(generic_stage_target): def set_target_path(self): pass + def set_spec_prefix(self): - self.settings["spec_prefix"]="livecd" + self.settings["spec_prefix"]="livecd" def set_use(self): generic_stage_target.set_use(self) diff --git a/modules/catalyst/target/livecd_stage2.py b/modules/catalyst/target/livecd_stage2.py index 8ad662e7..6d215293 100644 --- a/modules/catalyst/target/livecd_stage2.py +++ b/modules/catalyst/target/livecd_stage2.py @@ -3,7 +3,7 @@ Builder class for a LiveCD stage2 build. """ -import os,string,types,stat,shutil +import os from catalyst.support import * from generic_stage import * import catalyst.util diff --git a/modules/catalyst/target/netboot.py b/modules/catalyst/target/netboot.py index e1a87ae9..e93d0864 100644 --- a/modules/catalyst/target/netboot.py +++ b/modules/catalyst/target/netboot.py @@ -40,7 +40,7 @@ class netboot_target(generic_stage_target): generic_stage_target.__init__(self,spec,addlargs) - self.set_build_kernel_vars(addlargs) + self.set_build_kernel_vars() if "netboot/busybox_config" in addlargs: catalyst.util.file_locate(self.settings, ["netboot/busybox_config"]) diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index 25823a25..8fa9ac31 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -2,7 +2,7 @@ Collection of utility functions for catalyst """ -import sys, traceback, os, os.path, re +import sys, traceback, os, os.path, re, time from catalyst.error import * def capture_traceback():