Replace catalyst.support.read_from_clst() with catalyst.util.readfile() and update...
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 21:31:01 +0000 (15:31 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 21:31:01 +0000 (15:31 -0600)
ChangeLog
modules/catalyst/support.py
modules/catalyst/target/generic_stage.py
modules/catalyst/target/livecd_stage2.py
modules/catalyst/util.py

index df66444cbcc03bea74aaa18b3d15eeff3365b616..288a43cb84fd33ddb7b13a8fa9251f29edb7e372 100644 (file)
--- 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 <agaffney@gentoo.org>
+  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 <agaffney@gentoo.org> catalyst,
   modules/catalyst/util.py:
   Modify global import from catalyst.support to just import what's needed
index 2a96dae1ff0a72e398e65f6319cf7e3d99499b96..2c209121756009228b058e41da2ee02c174a1972 100644 (file)
@@ -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")
index 143e74fe97ed0be86abd659cc6be63dc95ee366e..89710fdad60ac5ca6686088c665ddced96243b4a 100644 (file)
@@ -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
index d9228dc84d72101dfc1b28307f23163a6d359848..d09cb623c376f20734f564ee6d663aba2c05c0e8 100644 (file)
@@ -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"]
index f56d6626ad815081aef13139c021b145ce2813e0..1f90e65ffbd6b951e6fb7a256cb8249ce5a2ada4 100644 (file)
@@ -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
+