From: Andrew Gaffney Date: Sun, 11 Jan 2009 21:31:01 +0000 (-0600) Subject: Replace catalyst.support.read_from_clst() with catalyst.util.readfile() and update... X-Git-Tag: CATALYST-2.0.10~3^2~206 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1f148d21323959570fd12da0858eefd208d4b003;p=catalyst.git Replace catalyst.support.read_from_clst() with catalyst.util.readfile() and update references --- diff --git a/ChangeLog b/ChangeLog index df66444c..288a43cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney + modules/catalyst/support.py, modules/catalyst/target/generic_stage.py, + modules/catalyst/target/livecd_stage2.py, modules/catalyst/util.py: + Replace catalyst.support.read_from_clst() with catalyst.util.readfile() + and update references + 11 Jan 2009; Andrew Gaffney catalyst, modules/catalyst/util.py: Modify global import from catalyst.support to just import what's needed diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index 2a96dae1..2c209121 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -180,21 +180,6 @@ hash_map={ "whirlpool":[calc_hash2,"shash","-a WHIRLPOOL","WHIRLPOOL"],\ } -def read_from_clst(file): - line = '' - myline = '' - try: - myf=open(file,"r") - except: - return -1 - #raise CatalystError, "Could not open file "+file - for line in myf.readlines(): - #line = string.replace(line, "\n", "") # drop newline - myline = myline + line - myf.close() - return myline -# read_from_clst - required_config_file_values=["storedir","sharedir","distdir","portdir"] valid_config_file_values=required_config_file_values[:] valid_config_file_values.append("PKGCACHE") diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 143e74fe..89710fda 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -11,6 +11,7 @@ from stat import * import catalyst.lock import catalyst.arch from catalyst.output import warn +import catalyst.util class generic_stage_target(generic_target): @@ -597,7 +598,7 @@ class generic_stage_target(generic_target): def unpack(self): unpack=True - clst_unpack_hash=read_from_clst(self.settings["autoresume_path"]+\ + clst_unpack_hash = catalyst.util.readfile(self.settings["autoresume_path"]+\ "unpack") if "SEEDCACHE" in self.settings: @@ -719,12 +720,12 @@ class generic_stage_target(generic_target): def unpack_snapshot(self): unpack=True - snapshot_hash=read_from_clst(self.settings["autoresume_path"]+\ + snapshot_hash = catalyst.util.readfile(self.settings["autoresume_path"]+\ "unpack_portage") if "SNAPCACHE" in self.settings: - snapshot_cache_hash=\ - read_from_clst(self.settings["snapshot_cache_path"]+\ + snapshot_cache_hash = \ + catalyst.util.readfile(self.settings["snapshot_cache_path"]+\ "catalyst-hash") destdir=self.settings["snapshot_cache_path"] unpack_cmd="tar xjpf "+self.settings["snapshot_path"]+" -C "+destdir diff --git a/modules/catalyst/target/livecd_stage2.py b/modules/catalyst/target/livecd_stage2.py index d9228dc8..d09cb623 100644 --- a/modules/catalyst/target/livecd_stage2.py +++ b/modules/catalyst/target/livecd_stage2.py @@ -6,6 +6,7 @@ Builder class for a LiveCD stage2 build. import os,string,types,stat,shutil from catalyst.support import * from generic_stage import * +import catalyst.util class livecd_stage2_target(generic_stage_target): def __init__(self,spec,addlargs): @@ -73,7 +74,7 @@ class livecd_stage2_target(generic_stage_target): unpack=True display_msg=None - clst_unpack_hash=read_from_clst(self.settings["autoresume_path"]+"unpack") + clst_unpack_hash = catalyst.util.readfile(self.settings["autoresume_path"]+"unpack") if os.path.isdir(self.settings["source_path"]): unpack_cmd="rsync -a --delete "+self.settings["source_path"]+" "+self.settings["chroot_path"] diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index f56d6626..1f90e65f 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -34,3 +34,14 @@ def find_binary(myc): return "%s/%s" % (x,myc) return None +def readfile(file): + file_contents = "" + try: + myf = open(file, "r") + file_contents = "".join(myf.readlines()) + myf.close() + return file_contents + except: + return None + #raise CatalystError, "Could not read file " + file +