* [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module
@ 2015-10-11 6:29 Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 02/10] stage2: " Mike Frysinger
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/targets/stage1.py | 38 ++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index b5dfac7..18ef520 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -5,6 +5,9 @@ stage1 target
import os
+from snakeoil import fileutils
+
+from catalyst import log
from catalyst.support import normpath
from catalyst.fileops import ensure_dirs
from catalyst.base.stagebase import StageBase
@@ -22,12 +25,12 @@ class stage1(StageBase):
def set_stage_path(self):
self.settings["stage_path"]=normpath(self.settings["chroot_path"]+self.settings["root_path"])
- print "stage1 stage path is "+self.settings["stage_path"]
+ log.notice('stage1 stage path is %s', self.settings['stage_path'])
def set_root_path(self):
# sets the root path, relative to 'chroot_path', of the stage1 root
self.settings["root_path"]=normpath("/tmp/stage1root")
- print "stage1 root path is "+self.settings["root_path"]
+ log.info('stage1 root path is %s', self.settings['root_path'])
def set_cleanables(self):
StageBase.set_cleanables(self)
@@ -55,10 +58,10 @@ class stage1(StageBase):
def set_portage_overlay(self):
StageBase.set_portage_overlay(self)
if "portage_overlay" in self.settings:
- print "\nWARNING !!!!!"
- print "\tUsing an portage overlay for earlier stages could cause build issues."
- print "\tIf you break it, you buy it. Don't complain to us about it."
- print "\tDont say we did not warn you\n"
+ log.warning(
+ 'Using an overlay for earlier stages could cause build issues.\n'
+ "If you break it, you buy it. Don't complain to us about it.\n"
+ "Don't say we did not warn you.")
def base_dirs(self):
if os.uname()[0] == "FreeBSD":
@@ -67,22 +70,13 @@ class stage1(StageBase):
# since proc and dev are not writeable, so...create them here
ensure_dirs(self.settings["stage_path"]+"/proc")
ensure_dirs(self.settings["stage_path"]+"/dev")
- if not os.path.isfile(self.settings["stage_path"]+"/proc/.keep"):
- try:
- proc_keepfile = open(self.settings["stage_path"]+"/proc/.keep","w")
- proc_keepfile.write('')
- proc_keepfile.close()
- except IOError:
- print "!!! Failed to create %s" % (self.settings["stage_path"]+"/dev/.keep")
- if not os.path.isfile(self.settings["stage_path"]+"/dev/.keep"):
- try:
- dev_keepfile = open(self.settings["stage_path"]+"/dev/.keep","w")
- dev_keepfile.write('')
- dev_keepfile.close()
- except IOError:
- print "!!! Failed to create %s" % (self.settings["stage_path"]+"/dev/.keep")
- else:
- pass
+ for f in ('/proc', '/dev'):
+ f = self.settings['stage_path'] + f + '/.keep'
+ if not os.path.isfile(f):
+ try:
+ fileutils.touch(f)
+ except IOError:
+ log.error('Failed to create %s', f)
def set_mounts(self):
# stage_path/proc probably doesn't exist yet, so create it
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 02/10] stage2: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 03/10] stage3: " Mike Frysinger
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/targets/stage2.py | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py
index 786aaa4..ff060d2 100644
--- a/catalyst/targets/stage2.py
+++ b/catalyst/targets/stage2.py
@@ -5,6 +5,7 @@ stage2 target, builds upon previous stage1 tarball
import os
+from catalyst import log
from catalyst.support import normpath
from catalyst.base.stagebase import StageBase
@@ -30,10 +31,12 @@ class stage2(StageBase):
self.settings["hash_map"].generate_hash(
self.settings["source_path"],\
hash_=self.settings["hash_function"])
- print "Source path set to "+self.settings["source_path"]
+ log.notice('Source path set to %s', self.settings['source_path'])
if os.path.isdir(self.settings["source_path"]):
- print "\tIf this is not desired, remove this directory or turn off seedcache in the options of catalyst.conf"
- print "\tthe source path will then be "+normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"] + "\n")
+ log.warning(
+ 'If this is not desired, remove this directory or turn off seedcache in the\n'
+ 'options of catalyst.conf. The source path will then be:\n%s',
+ normpath(self.settings['storedir'] + '/builds/' + self.settings['source_subpath']))
# XXX: How do these override_foo() functions differ from the ones in
# StageBase and why aren't they in stage3_target?
@@ -57,7 +60,7 @@ class stage2(StageBase):
def set_portage_overlay(self):
StageBase.set_portage_overlay(self)
if "portage_overlay" in self.settings:
- print "\nWARNING !!!!!"
- print "\tUsing an portage overlay for earlier stages could cause build issues."
- print "\tIf you break it, you buy it. Don't complain to us about it."
- print "\tDont say we did not warn you\n"
+ log.warning(
+ 'Using an overlay for earlier stages could cause build issues.\n'
+ "If you break it, you buy it. Don't complain to us about it.\n"
+ "Don't say we did not warn you.")
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 03/10] stage3: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 02/10] stage2: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 04/10] stagebase: " Mike Frysinger
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/targets/stage3.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/catalyst/targets/stage3.py b/catalyst/targets/stage3.py
index cc3e520..f083193 100644
--- a/catalyst/targets/stage3.py
+++ b/catalyst/targets/stage3.py
@@ -3,6 +3,7 @@ stage3 target, builds upon previous stage2/stage3 tarball
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
+from catalyst import log
from catalyst.base.stagebase import StageBase
@@ -18,10 +19,10 @@ class stage3(StageBase):
def set_portage_overlay(self):
StageBase.set_portage_overlay(self)
if "portage_overlay" in self.settings:
- print "\nWARNING !!!!!"
- print "\tUsing an overlay for earlier stages could cause build issues."
- print "\tIf you break it, you buy it. Don't complain to us about it."
- print "\tDont say we did not warn you\n"
+ log.warning(
+ 'Using an overlay for earlier stages could cause build issues.\n'
+ "If you break it, you buy it. Don't complain to us about it.\n"
+ "Don't say we did not warn you.")
def set_cleanables(self):
StageBase.set_cleanables(self)
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 04/10] stagebase: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 02/10] stage2: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 03/10] stage3: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 05/10] clearbase: " Mike Frysinger
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
This also allows cleaning up a few funcs from the support module
as they were only lightly used in stagebase.
---
catalyst/base/stagebase.py | 262 ++++++++++++++++++++++-----------------------
catalyst/defaults.py | 2 -
catalyst/support.py | 16 +--
3 files changed, 128 insertions(+), 152 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 3ce7dba..e7514e2 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -13,10 +13,11 @@ from snakeoil import fileutils
from DeComp.compress import CompressMap
+from catalyst import log
from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS, TARGET_MOUNT_DEFAULTS,
PORT_LOGDIR_CLEAN)
-from catalyst.support import (CatalystError, msg, file_locate, normpath,
- cmd, warn, list_bashify, read_makeconf, ismount, file_check)
+from catalyst.support import (CatalystError, file_locate, normpath,
+ cmd, list_bashify, read_makeconf, ismount, file_check)
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
@@ -97,7 +98,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# This message should probably change a bit, since everything in
# the dir should load just fine. If it doesn't, it's probably a
# syntax error in the module
- msg("Can't find/load " + x + ".py plugin in " + arch_dir)
+ log.warning("Can't find/load %s.py plugin in %s", x, arch_dir)
if "chost" in self.settings:
hostmachine = self.settings["chost"].split("-")[0]
@@ -123,23 +124,22 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
self.arch=self.subarchmap[self.settings["subarch"]](self.settings)
except KeyError:
- print "Invalid subarch: "+self.settings["subarch"]
- print "Choose one of the following:",
- for x in self.subarchmap:
- print x,
- print
- sys.exit(2)
-
- print "Using target:",self.settings["target"]
+ log.critical(
+ 'Invalid subarch: %s\n'
+ 'Choose one of the following:\n'
+ ' %s',
+ self.settings['subarch'], ' '.join(self.subarchmap))
+
+ log.notice('Using target: %s', self.settings['target'])
# Print a nice informational message
if self.settings["buildarch"]==self.settings["hostarch"]:
- print "Building natively for",self.settings["hostarch"]
+ log.info('Building natively for %s', self.settings['hostarch'])
elif self.settings["crosscompile"]:
- print "Cross-compiling on",self.settings["buildarch"],\
- "for different machine type",self.settings["hostarch"]
+ log.info('Cross-compiling on %s for different machine type %s',
+ self.settings['buildarch'], self.settings['hostarch'])
else:
- print "Building on",self.settings["buildarch"],\
- "for alternate personality type",self.settings["hostarch"]
+ log.info('Building on %s for alternate personality type %s',
+ self.settings['buildarch'], self.settings['hostarch'])
# This must be set first as other set_ options depend on this
self.set_spec_prefix()
@@ -218,15 +218,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
# the command line).
if "pkgcache" in self.settings["options"]:
self.set_pkgcache_path()
- print "Location of the package cache is "+\
- self.settings["pkgcache_path"]
+ log.info('Location of the package cache is %s', self.settings['pkgcache_path'])
self.mounts.append("packagedir")
self.mountmap["packagedir"] = self.settings["pkgcache_path"]
if "kerncache" in self.settings["options"]:
self.set_kerncache_path()
- print "Location of the kerncache is "+\
- self.settings["kerncache_path"]
+ log.info('Location of the kerncache is %s', self.settings['kerncache_path'])
self.mounts.append("kerncache")
self.mountmap["kerncache"] = self.settings["kerncache_path"]
@@ -344,8 +342,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"]\
and self.resume.is_enabled("setup_target_path"):
- print \
- "Resume point detected, skipping target path setup operation..."
+ log.notice('Resume point detected, skipping target path setup operation...')
else:
# First clean up any existing target stuff
# XXX WTF are we removing the old tarball before we start building the
@@ -406,8 +403,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["fstype"]="normal"
for x in self.valid_values:
if x == self.settings["spec_prefix"]+"/fstype":
- print "\n"+self.settings["spec_prefix"]+\
- "/fstype is being set to the default of \"normal\"\n"
+ log.info('%s/fstype is being set to the default of "normal"',
+ self.settings['spec_prefix'])
def set_fsops(self):
if "fstype" in self.settings:
@@ -435,13 +432,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["hash_map"].generate_hash(
self.settings["source_path"],
hash_=self.settings["hash_function"])
- print "Source path set to "+self.settings["source_path"]
+ log.info('Source path set to %s', self.settings['source_path'])
if os.path.isdir(self.settings["source_path"]):
- print "\tIf this is not desired, remove this directory or turn off"
- print "\tseedcache in the options of catalyst.conf the source path"
- print "\twill then be "+\
- normpath(self.settings["storedir"]+"/builds/"+\
- self.settings["source_subpath"]+"\n")
+ log.warning(
+ 'If this is not desired, remove this directory or turn off\n'
+ 'seedcache in the options of catalyst.conf the source path\n'
+ 'will then be %s',
+ normpath(self.settings['storedir'] + '/builds/' +
+ self.settings['source_subpath']))
def set_dest_path(self):
if "root_path" in self.settings:
@@ -458,7 +456,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["snapshot_path"]= file_check(normpath(self.settings["storedir"]+\
"/snapshots/" + self.settings["snapshot_name"] +
self.settings["snapshot"]))
- print "*** SNAPSHOT_PATH set to:", self.settings["snapshot_path"]
+ log.info('SNAPSHOT_PATH set to: %s', self.settings['snapshot_path'])
self.settings["snapshot_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["snapshot_path"],
@@ -474,7 +472,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["snapshot"]))
self.snapcache_lock=\
LockDir(self.settings["snapshot_cache_path"])
- print "Setting snapshot cache to "+self.settings["snapshot_cache_path"]
+ log.info('Setting snapshot cache to %s', self.settings['snapshot_cache_path'])
def set_chroot_path(self):
"""
@@ -493,7 +491,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["version_stamp"])
))
if "autoresume" in self.settings["options"]:
- print "The autoresume path is " + self.settings["autoresume_path"]
+ log.info('The autoresume path is %s', self.settings['autoresume_path'])
self.resume = AutoResume(self.settings["autoresume_path"], mode=0755)
def set_controller_file(self):
@@ -582,8 +580,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
if type(self.settings["portage_overlay"])==types.StringType:
self.settings["portage_overlay"]=\
self.settings["portage_overlay"].split()
- print "portage_overlay directories are set to: \""+\
- ' '.join(self.settings["portage_overlay"])+"\""
+ log.info('portage_overlay directories are set to: %s',
+ ' '.join(self.settings['portage_overlay']))
def set_overlay(self):
if self.settings["spec_prefix"]+"/overlay" in self.settings:
@@ -639,7 +637,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
del self.settings[self.settings["spec_prefix"]+"/gk_mainargs"]
def kill_chroot_pids(self):
- print "Checking for processes running in chroot and killing them."
+ log.info('Checking for processes running in chroot and killing them.')
# Force environment variables to be exported so script can see them
self.setup_environment()
@@ -659,23 +657,23 @@ class StageBase(TargetBase, ClearBase, GenBase):
if not os.path.exists(self.settings["chroot_path"]):
return
- #print "self.mounts =", self.mounts
+ log.debug('self.mounts = %s', self.mounts)
for x in self.mounts:
target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
- #print "mount_safety_check() x =", x, target
+ log.debug('mount_safety_check() x = %s %s', x, target)
if not os.path.exists(target):
continue
if ismount(target):
# Something is still mounted
try:
- print target + " is still mounted; performing auto-bind-umount...",
+ log.warning('%s is still mounted; performing auto-bind-umount...', target)
# Try to umount stuff ourselves
self.unbind()
if ismount(target):
raise CatalystError("Auto-unbind failed for " + target)
else:
- print "Auto-unbind successful..."
+ log.notice('Auto-unbind successful...')
except CatalystError:
raise CatalystError("Unable to auto-unbind " + target)
@@ -691,8 +689,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
'auto-ext': False,
}
- display_msg="\nStarting %(mode)s from %(source)s\nto "+\
- "%(destination)s (This may take some time) ...\n"
+ display_msg = (
+ 'Starting %(mode)s from %(source)s\nto '
+ '%(destination)s (this may take some time) ..')
error_msg="'%(mode)s' extraction of %(source)s to %(destination)s failed."
@@ -702,7 +701,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
unpack_info['mode'] = "rsync"
else:
# SEEDCACHE is a not a directory, try untar'ing
- print "Referenced SEEDCACHE does not appear to be a directory, trying to untar..."
+ log.notice('Referenced SEEDCACHE does not appear to be a directory, trying to untar...')
unpack_info['source'] = file_check(unpack_info['source'])
else:
# No SEEDCACHE, use tar
@@ -764,7 +763,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if invalid_snapshot:
if "autoresume" in self.settings["options"]:
- print "No Valid Resume point detected, cleaning up..."
+ log.notice('No Valid Resume point detected, cleaning up...')
self.clear_autoresume()
self.clear_chroot()
@@ -779,11 +778,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "kerncache" in self.settings["options"]:
ensure_dirs(self.settings["kerncache_path"],mode=0755)
- print display_msg %(unpack_info)
+ log.notice('%s', display_msg % unpack_info)
# now run the decompressor
if not self.decompressor.extract(unpack_info):
- print error_msg %(unpack_info)
+ log.error('%s', error_msg % unpack_info)
if "source_path_hash" in self.settings:
self.resume.enable("unpack",
@@ -791,7 +790,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
self.resume.enable("unpack")
else:
- print "Resume point detected, skipping unpack operation..."
+ log.notice('Resume point detected, skipping unpack operation...')
def unpack_snapshot(self):
unpack=True
@@ -808,8 +807,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
target_portdir = normpath(self.settings["chroot_path"] +
self.settings["repo_basedir"] + "/" + self.settings["repo_name"])
- print self.settings["chroot_path"]
- print "unpack(), target_portdir = " + target_portdir
+ log.info('%s', self.settings['chroot_path'])
+ log.info('unpack(), target_portdir = %s', target_portdir)
if "snapcache" in self.settings["options"]:
snapshot_cache_hash_path = pjoin(
self.settings['snapshot_cache_path'], 'catalyst-hash')
@@ -819,16 +818,16 @@ class StageBase(TargetBase, ClearBase, GenBase):
cleanup_msg="Cleaning up invalid snapshot cache at \n\t"+\
self.settings["snapshot_cache_path"]+\
- " (This can take a long time)..."
+ " (this can take a long time)..."
cleanup_errmsg="Error removing existing snapshot cache directory."
if self.settings["snapshot_path_hash"]==snapshot_cache_hash:
- print "Valid snapshot cache, skipping unpack of portage tree..."
+ log.info('Valid snapshot cache, skipping unpack of portage tree...')
unpack=False
else:
cleanup_errmsg="Error removing existing snapshot directory."
cleanup_msg=\
- "Cleaning up existing portage tree (This can take a long time)..."
+ 'Cleaning up existing portage tree (this can take a long time)...'
unpack_info['destination'] = normpath(
self.settings["chroot_path"] + self.settings["repo_basedir"])
unpack_info['mode'] = self.decompressor.determine_mode(
@@ -838,30 +837,29 @@ class StageBase(TargetBase, ClearBase, GenBase):
and os.path.exists(target_portdir) \
and self.resume.is_enabled("unpack_portage") \
and self.settings["snapshot_path_hash"] == snapshot_hash:
- print \
- "Valid Resume point detected, skipping unpack of portage tree..."
+ log.notice('Valid Resume point detected, skipping unpack of portage tree...')
unpack = False
if unpack:
if "snapcache" in self.settings["options"]:
self.snapcache_lock.write_lock()
if os.path.exists(target_portdir):
- print cleanup_msg
+ log.info('%s', cleanup_msg)
cleanup_cmd = "rm -rf " + target_portdir
- print "unpack() cleanup_cmd = " + cleanup_cmd
+ log.info('unpack() cleanup_cmd = %s', cleanup_cmd)
cmd(cleanup_cmd,cleanup_errmsg,env=self.env)
ensure_dirs(target_portdir, mode=0755)
- print "Unpacking portage tree (This can take a long time) ..."
+ log.notice('Unpacking portage tree (this can take a long time) ...')
if not self.decompressor.extract(unpack_info):
- print unpack_errmsg %(unpack_info)
+ log.error('%s', unpack_errmsg % unpack_info)
if "snapcache" in self.settings["options"]:
myf = open(snapshot_cache_hash_path, 'w')
myf.write(self.settings["snapshot_path_hash"])
myf.close()
else:
- print "Setting snapshot autoresume point"
+ log.info('Setting snapshot autoresume point')
self.resume.enable("unpack_portage",
data=self.settings["snapshot_path_hash"])
@@ -871,12 +869,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
def config_profile_link(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("config_profile_link"):
- print \
- "Resume point detected, skipping config_profile_link operation..."
+ log.notice('Resume point detected, skipping config_profile_link operation...')
else:
# TODO: zmedico and I discussed making this a directory and pushing
# in a parent file, as well as other user-specified configuration.
- print "Configuring profile link..."
+ log.info('Configuring profile link...')
cmd("rm -f " + self.settings["chroot_path"] +
self.settings["port_conf"] + "/make.profile",
"Error zapping profile link",env=self.env)
@@ -892,10 +889,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
def setup_confdir(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_confdir"):
- print "Resume point detected, skipping setup_confdir operation..."
+ log.notice('Resume point detected, skipping setup_confdir operation...')
else:
if "portage_confdir" in self.settings:
- print "Configuring %s..." % self.settings["port_conf"]
+ log.info('Configuring %s...', self.settings['port_conf'])
cmd("rsync -a " + self.settings["portage_confdir"] + "/ " +
self.settings["chroot_path"] + self.settings["port_conf"],
"Error copying %s" % self.settings["port_conf"],
@@ -907,7 +904,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "portage_overlay" in self.settings:
for x in self.settings["portage_overlay"]:
if os.path.exists(x):
- print "Copying overlay dir " +x
+ log.info('Copying overlay dir %s', x)
cmd("mkdir -p "+self.settings["chroot_path"]+\
self.settings["local_overlay"],\
"Could not make portage_overlay dir",env=self.env)
@@ -921,7 +918,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
for x in self.settings[self.settings["spec_prefix"]+\
"/root_overlay"]:
if os.path.exists(x):
- print "Copying root_overlay: "+x
+ log.info('Copying root_overlay: %s', x)
cmd("rsync -a "+x+"/ "+\
self.settings["chroot_path"],\
self.settings["spec_prefix"]+"/root_overlay: "+x+\
@@ -933,7 +930,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def bind(self):
for x in self.mounts:
_cmd = ''
- #print "bind(); x =", x
+ log.debug('bind(); x = %s', x)
target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
ensure_dirs(target, mode=0755)
@@ -942,7 +939,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
ensure_dirs(self.mountmap[x], mode=0755)
src=self.mountmap[x]
- #print "bind(); src =", src
+ log.debug('bind(); src = %s', src)
if "snapcache" in self.settings["options"] and x == "portdir":
self.snapcache_lock.read_lock()
if os.uname()[0] == "FreeBSD":
@@ -960,9 +957,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
_cmd = "mount -t tmpfs -o noexec,nosuid,nodev shm " + target
else:
_cmd = "mount --bind " + src + " " + target
- #print "bind(); _cmd =", _cmd
+ log.debug('bind(); _cmd = %s', _cmd)
cmd(_cmd, "Bind mounting Failed", env=self.env, fail_func=self.unbind)
- #print "bind(); finished :D"
+ log.debug('bind(); finished :D')
def unbind(self):
ouch=0
@@ -981,15 +978,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + target + " failed.")
- warn("Killing any pids still running in the chroot")
+ log.warning('First attempt to unmount failed: %s', target)
+ log.warning('Killing any pids still running in the chroot')
self.kill_chroot_pids()
retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + target)
+ log.warning("Couldn't umount bind mount: %s", target)
if "snapcache" in self.settings["options"] and x == "/usr/portage":
try:
@@ -1019,9 +1016,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.override_asflags()
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("chroot_setup"):
- print "Resume point detected, skipping chroot_setup operation..."
+ log.notice('Resume point detected, skipping chroot_setup operation...')
else:
- print "Setting up chroot..."
+ log.notice('Setting up chroot...')
cmd("cp /etc/resolv.conf " + self.settings["chroot_path"] + "/etc/",
"Could not copy resolv.conf into place.",env=self.env)
@@ -1033,13 +1030,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
"Can't find envscript " + self.settings["envscript"],
print_traceback=True)
- print "\nWarning!!!!"
- print "\tOverriding certain env variables may cause catastrophic failure."
- print "\tIf your build fails look here first as the possible problem."
- print "\tCatalyst assumes you know what you are doing when setting"
- print "\t\tthese variables."
- print "\tCatalyst Maintainers use VERY minimal envscripts if used at all"
- print "\tYou have been warned\n"
+ log.warning(
+ 'Overriding certain env variables may cause catastrophic failure.\n'
+ 'If your build fails look here first as the possible problem.\n'
+ 'Catalyst assumes you know what you are doing when setting these variables.\n'
+ 'Catalyst Maintainers use VERY minimal envscripts, if used at all.\n'
+ 'You have been warned.')
cmd("cp "+self.settings["envscript"]+" "+\
self.settings["chroot_path"]+"/tmp/envscript",\
@@ -1113,10 +1109,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
myusevars = sorted(set(myusevars))
myf.write('USE="' + ' '.join(myusevars) + '"\n')
if '-*' in myusevars:
- print "\nWarning!!! "
- print "\tThe use of -* in "+self.settings["spec_prefix"]+\
- "/use will cause portage to ignore"
- print "\tpackage.use in the profile and portage_confdir. You've been warned!"
+ log.warning(
+ 'The use of -* in %s/use will cause portage to ignore\n'
+ 'package.use in the profile and portage_confdir.\n'
+ "You've been warned!", self.settings['spec_prefix'])
myuseexpandvars={}
if "HOSTUSEEXPAND" in self.settings:
@@ -1141,7 +1137,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def fsscript(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("fsscript"):
- print "Resume point detected, skipping fsscript operation..."
+ log.notice('Resume point detected, skipping fsscript operation...')
else:
if "fsscript" in self.settings:
if os.path.exists(self.settings["controller_file"]):
@@ -1152,7 +1148,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def rcupdate(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("rcupdate"):
- print "Resume point detected, skipping rcupdate operation..."
+ log.notice('Resume point detected, skipping rcupdate operation...')
else:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+" rc-update",\
@@ -1162,10 +1158,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
def clean(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("clean"):
- print "Resume point detected, skipping clean operation..."
+ log.notice('Resume point detected, skipping clean operation...')
else:
for x in self.settings["cleanables"]:
- print "Cleaning chroot: "+x+"... "
+ log.notice('Cleaning chroot: %s', x)
cmd("rm -rf "+self.settings["destpath"]+x,"Couldn't clean "+\
x,env=self.env)
@@ -1197,7 +1193,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def empty(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("empty"):
- print "Resume point detected, skipping empty operation..."
+ log.notice('Resume point detected, skipping empty operation...')
else:
if self.settings["spec_prefix"]+"/empty" in self.settings:
if type(self.settings[self.settings["spec_prefix"]+\
@@ -1208,9 +1204,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
for x in self.settings[self.settings["spec_prefix"]+"/empty"]:
myemp=self.settings["destpath"]+x
if not os.path.isdir(myemp) or os.path.islink(myemp):
- print x,"not a directory or does not exist, skipping 'empty' operation."
+ log.warning('not a directory or does not exist, skipping "empty" operation: %s', x)
continue
- print "Emptying directory",x
+ log.info('Emptying directory %s', x)
# stat the dir, delete the dir, recreate the dir and set
# the proper perms and ownership
mystat=os.stat(myemp)
@@ -1223,13 +1219,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
def remove(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("remove"):
- print "Resume point detected, skipping remove operation..."
+ log.notice('Resume point detected, skipping remove operation...')
else:
if self.settings["spec_prefix"]+"/rm" in self.settings:
for x in self.settings[self.settings["spec_prefix"]+"/rm"]:
# We're going to shell out for all these cleaning
# operations, so we get easy glob handling.
- print "livecd: removing "+x
+ log.notice('livecd: removing %s', x)
os.system("rm -rf "+self.settings["chroot_path"]+x)
try:
if os.path.exists(self.settings["controller_file"]):
@@ -1243,7 +1239,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def preclean(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("preclean"):
- print "Resume point detected, skipping preclean operation..."
+ log.notice('Resume point detected, skipping preclean operation...')
else:
try:
if os.path.exists(self.settings["controller_file"]):
@@ -1264,9 +1260,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("capture"):
- print "Resume point detected, skipping capture operation..."
+ log.notice('Resume point detected, skipping capture operation...')
else:
- print "Capture target in a tarball"
+ log.notice('Capture target in a tarball')
# Remove filename from path
mypath = os.path.dirname(self.settings["target_path"])
@@ -1283,29 +1279,30 @@ class StageBase(TargetBase, ClearBase, GenBase):
target_filename = ".".join([self.settings["target_path"].rstrip('/'),
self.compressor.extension(pack_info['mode'])])
- print "Creating stage tarball... mode:", \
- self.settings["compression_mode"]
+ log.notice('Creating stage tarball... mode: %s',
+ self.settings['compression_mode'])
if self.compressor.compress(pack_info):
self.gen_contents_file(target_filename)
self.gen_digest_file(target_filename)
self.resume.enable("capture")
else:
- print "Couldn't create stage tarball:", target_filename
+ log.warning("Couldn't create stage tarball: %s", target_filename)
def run_local(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("run_local"):
- print "Resume point detected, skipping run_local operation..."
+ log.notice('Resume point detected, skipping run_local operation...')
else:
try:
if os.path.exists(self.settings["controller_file"]):
- print "run_local() starting controller script..."
+ log.info('run_local() starting controller script...')
cmd(self.settings["controller_file"]+" run",\
"run script failed.",env=self.env)
self.resume.enable("run_local")
else:
- print "run_local() no controller_file found...", self.settings["controller_file"]
+ log.info('run_local() no controller_file found... %s',
+ self.settings['controller_file'])
except CatalystError:
self.unbind()
@@ -1318,9 +1315,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
fixed. We need this to use the os.system() call since we can't
specify our own environ
"""
- #print "setup_environment(); settings =", list(self.settings)
+ log.debug('setup_environment(); settings = %r', self.settings)
for x in list(self.settings):
- #print "setup_environment(); processing:", x
+ log.debug('setup_environment(); processing: %s', x)
if x == "options":
#self.env['clst_' + x] = ' '.join(self.settings[x])
for opt in self.settings[x]:
@@ -1367,7 +1364,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "makeopts" in self.settings:
self.env["MAKEOPTS"]=self.settings["makeopts"]
- #print "setup_environment(); env =", self.env
+ log.debug('setup_environment(); env = %r', self.env)
def run(self):
self.chroot_lock.write_lock()
@@ -1386,33 +1383,30 @@ class StageBase(TargetBase, ClearBase, GenBase):
return
if "purgeonly" in self.settings["options"]:
- print "StageBase: run() purgeonly"
+ log.info('StageBase: run() purgeonly')
self.purge()
if "purge" in self.settings["options"]:
- print "StageBase: run() purge"
+ log.info('StageBase: run() purge')
self.purge()
failure = False
for x in self.settings["action_sequence"]:
- print "--- Running action sequence: "+x
+ log.notice('--- Running action sequence: %s', x)
sys.stdout.flush()
try:
getattr(self, x)()
except LockInUse:
- print "Error, unable to aquire the lock..."
- print " Catalyst aborting...."
+ log.error('Unable to aquire the lock...')
failure = True
break
- except Exception as error:
- print "Exception running action sequence %s" % x
- print "Error:", str(error)
- print " Catalyst aborting...."
+ except Exception:
+ log.error('Exception running action sequence %s', x, exc_info=True)
failure = True
break
if failure:
- print "Cleaning up... Running unbind()"
+ log.notice('Cleaning up... Running unbind()')
self.unbind()
return False
return True
@@ -1421,7 +1415,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def unmerge(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("unmerge"):
- print "Resume point detected, skipping unmerge operation..."
+ log.notice('Resume point detected, skipping unmerge operation...')
else:
if self.settings["spec_prefix"]+"/unmerge" in self.settings:
if type(self.settings[self.settings["spec_prefix"]+\
@@ -1442,7 +1436,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd(self.settings["controller_file"]+\
" unmerge "+ myunmerge,"Unmerge script failed.",\
env=self.env)
- print "unmerge shell script"
+ log.info('unmerge shell script')
except CatalystError:
self.unbind()
raise
@@ -1451,9 +1445,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
def target_setup(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("target_setup"):
- print "Resume point detected, skipping target_setup operation..."
+ log.notice('Resume point detected, skipping target_setup operation...')
else:
- print "Setting up filesystems per filesystem type"
+ log.notice('Setting up filesystems per filesystem type')
cmd(self.settings["controller_file"]+\
" target_image_setup "+ self.settings["target_path"],\
"target_image_setup script failed.",env=self.env)
@@ -1462,7 +1456,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def setup_overlay(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_overlay"):
- print "Resume point detected, skipping setup_overlay operation..."
+ log.notice('Resume point detected, skipping setup_overlay operation...')
else:
if self.settings["spec_prefix"]+"/overlay" in self.settings:
for x in self.settings[self.settings["spec_prefix"]+"/overlay"]:
@@ -1476,7 +1470,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def create_iso(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("create_iso"):
- print "Resume point detected, skipping create_iso operation..."
+ log.notice('Resume point detected, skipping create_iso operation...')
else:
# Create the ISO
if "iso" in self.settings:
@@ -1487,20 +1481,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.gen_digest_file(self.settings["iso"])
self.resume.enable("create_iso")
else:
- print "WARNING: livecd/iso was not defined."
- print "An ISO Image will not be created."
+ log.warning('livecd/iso was not defined. An ISO Image will not be created.')
def build_packages(self):
build_packages_resume = pjoin(self.settings["autoresume_path"],
"build_packages")
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("build_packages"):
- print "Resume point detected, skipping build_packages operation..."
+ log.notice('Resume point detected, skipping build_packages operation...')
else:
if self.settings["spec_prefix"]+"/packages" in self.settings:
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("build_packages"):
- print "Resume point detected, skipping build_packages operation..."
+ log.notice('Resume point detected, skipping build_packages operation...')
else:
mypack=\
list_bashify(self.settings[self.settings["spec_prefix"]\
@@ -1520,7 +1513,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
'''Build all configured kernels'''
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("build_kernel"):
- print "Resume point detected, skipping build_kernel operation..."
+ log.notice('Resume point detected, skipping build_kernel operation...')
else:
if "boot/kernel" in self.settings:
try:
@@ -1544,7 +1537,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"Build a single configured kernel by name"
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("build_kernel_"+kname):
- print "Resume point detected, skipping build_kernel for "+kname+" operation..."
+ log.notice('Resume point detected, skipping build_kernel for %s operation...', kname)
return
self._copy_kernel_config(kname=kname)
@@ -1579,7 +1572,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings:
if os.path.exists(self.settings["chroot_path"]+\
"/tmp/initramfs_overlay/"):
- print "Cleaning up temporary overlay dir"
+ log.notice('Cleaning up temporary overlay dir')
cmd("rm -R "+self.settings["chroot_path"]+\
"/tmp/initramfs_overlay/",env=self.env)
@@ -1615,9 +1608,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings:
if os.path.exists(self.settings["boot/kernel/"+\
kname+"/initramfs_overlay"]):
- print "Copying initramfs_overlay dir "+\
- self.settings["boot/kernel/"+kname+\
- "/initramfs_overlay"]
+ log.notice('Copying initramfs_overlay dir %s',
+ self.settings['boot/kernel/' + kname + '/initramfs_overlay'])
cmd("mkdir -p "+\
self.settings["chroot_path"]+\
@@ -1635,7 +1627,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def bootloader(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("bootloader"):
- print "Resume point detected, skipping bootloader operation..."
+ log.notice('Resume point detected, skipping bootloader operation...')
else:
try:
cmd(self.settings["controller_file"]+\
@@ -1649,7 +1641,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
def livecd_update(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("livecd_update"):
- print "Resume point detected, skipping build_packages operation..."
+ log.notice('Resume point detected, skipping build_packages operation...')
else:
try:
cmd(self.settings["controller_file"]+\
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 5db7ab6..666afca 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -22,8 +22,6 @@ valid_config_file_values.extend([ "distcc", "envscript",
"compression_mode", "decompressor_search_order",
])
-verbosity = 1
-
confdefaults={
"archdir": "%(PythonDir)s/arch",
"compression_mode": 'lbzip2_x',
diff --git a/catalyst/support.py b/catalyst/support.py
index c629025..6b1e727 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -8,7 +8,7 @@ import traceback
import time
from subprocess import Popen
-from catalyst.defaults import verbosity, valid_config_file_values
+from catalyst.defaults import valid_config_file_values
BASH_BINARY = "/bin/bash"
@@ -40,15 +40,6 @@ class CatalystError(Exception):
print
-def die(msg=None):
- warn(msg)
- sys.exit(1)
-
-
-def warn(msg):
- print "!!! catalyst: "+msg
-
-
def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
if env is None:
env = {}
@@ -186,11 +177,6 @@ def read_makeconf(mymakeconffile):
return makeconf
-def msg(mymsg,verblevel=1):
- if verbosity>=verblevel:
- print mymsg
-
-
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 05/10] clearbase: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
` (2 preceding siblings ...)
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 04/10] stagebase: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 06/10] support: " Mike Frysinger
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/base/clearbase.py | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index b2c1a11..3817196 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -1,5 +1,6 @@
+from catalyst import log
from catalyst.support import countdown
from catalyst.fileops import clear_dir
@@ -15,38 +16,38 @@ class ClearBase(object):
def clear_autoresume(self):
""" Clean resume points since they are no longer needed """
if "autoresume" in self.settings["options"]:
- print "Removing AutoResume Points: ..."
+ log.notice('Removing AutoResume Points ...')
self.resume.clear_all()
def remove_autoresume(self):
""" Rmove all resume points since they are no longer needed """
if "autoresume" in self.settings["options"]:
- print "Removing AutoResume: ..."
+ log.notice('Removing AutoResume ...')
self.resume.clear_all(remove=True)
def clear_chroot(self):
self.chroot_lock.unlock()
- print 'Clearing the chroot path ...'
+ log.notice('Clearing the chroot path ...')
clear_dir(self.settings["chroot_path"], 0755, True)
def remove_chroot(self):
self.chroot_lock.unlock()
- print 'Removing the chroot path ...'
+ log.notice('Removing the chroot path ...')
clear_dir(self.settings["chroot_path"], 0755, True, remove=True)
def clear_packages(self, remove=False):
if "pkgcache" in self.settings["options"]:
- print "purging the pkgcache ..."
+ log.notice('purging the pkgcache ...')
clear_dir(self.settings["pkgcache_path"], remove=remove)
def clear_kerncache(self, remove=False):
if "kerncache" in self.settings["options"]:
- print "purging the kerncache ..."
+ log.notice('purging the kerncache ...')
clear_dir(self.settings["kerncache_path"], remove=remove)
@@ -54,15 +55,15 @@ class ClearBase(object):
countdown(10,"Purging Caches ...")
if any(k in self.settings["options"] for k in ("purge",
"purgeonly", "purgetmponly")):
- print "purge(); clearing autoresume ..."
+ log.notice('purge(); clearing autoresume ...')
self.clear_autoresume()
- print "purge(); clearing chroot ..."
+ log.notice('purge(); clearing chroot ...')
self.clear_chroot()
if "purgetmponly" not in self.settings["options"]:
- print "purge(); clearing package cache ..."
+ log.notice('purge(); clearing package cache ...')
self.clear_packages(remove)
- print "purge(); clearing kerncache ..."
+ log.notice('purge(); clearing kerncache ...')
self.clear_kerncache(remove)
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 06/10] support: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
` (3 preceding siblings ...)
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 05/10] clearbase: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 07/10] livecd_stage: " Mike Frysinger
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/support.py | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 6b1e727..8883acb 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -4,10 +4,10 @@ import sys
import os
import types
import re
-import traceback
import time
from subprocess import Popen
+from catalyst import log
from catalyst.defaults import valid_config_file_values
BASH_BINARY = "/bin/bash"
@@ -29,21 +29,13 @@ def list_bashify(mylist):
class CatalystError(Exception):
def __init__(self, message, print_traceback=False):
if message:
- if print_traceback:
- (_type, value) = sys.exc_info()[:2]
- if value!=None:
- print
- print "Traceback values found. listing..."
- print traceback.print_exc(file=sys.stdout)
- print
- print "!!! catalyst: "+message
- print
+ log.error('CatalystError: %s', message, exc_info=print_traceback)
def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
if env is None:
env = {}
- #print "***** cmd()"
+ log.debug('cmd: %r', mycmd)
sys.stdout.flush()
args=[BASH_BINARY]
if "BASH_ENV" not in env:
@@ -54,12 +46,11 @@ def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
args.append("-c")
args.append(mycmd)
- if debug:
- print "***** cmd(); args =", args
+ log.debug('args: %r', args)
proc = Popen(args, env=env)
if proc.wait() != 0:
if fail_func:
- print "CMD(), NON-Zero command return. Running fail_func()"
+ log.error('CMD(), NON-Zero command return. Running fail_func().')
fail_func()
raise CatalystError("cmd() NON-zero return value from: %s" % myexc,
print_traceback=False)
@@ -223,15 +214,17 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
def countdown(secs=5, doing="Starting"):
if secs:
- print ">>> Waiting",secs,"seconds before starting..."
- print ">>> (Control-C to abort)...\n"+doing+" in: ",
+ sys.stdout.write(
+ ('>>> Waiting %s seconds before starting...\n'
+ '>>> (Control-C to abort)...\n'
+ '%s in: ') % (secs, doing))
ticks=range(secs)
ticks.reverse()
for sec in ticks:
sys.stdout.write(str(sec+1)+" ")
sys.stdout.flush()
time.sleep(1)
- print
+ sys.stdout.write('\n')
def normpath(mypath):
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 07/10] livecd_stage: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
` (4 preceding siblings ...)
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 06/10] support: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 08/10] netboot: " Mike Frysinger
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/targets/livecd_stage1.py | 4 ++--
catalyst/targets/livecd_stage2.py | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 262db70..8d9dcc7 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -6,7 +6,7 @@ LiveCD stage1 target
import os
import types
-
+from catalyst import log
from catalyst.support import (normpath, cmd)
from catalyst.fileops import ensure_dirs
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
- print "Resume point detected, skipping target path setup operation..."
+ log.notice('Resume point detected, skipping target path setup operation...')
else:
# first clean up any existing target stuff
if os.path.exists(self.settings["target_path"]):
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index b54f2f0..fa76421 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -5,6 +5,7 @@ LiveCD stage2 target, builds upon previous LiveCD stage1 tarball
import os
+from catalyst import log
from catalyst.support import (normpath, file_locate, CatalystError, cmd)
from catalyst.fileops import ensure_dirs
from catalyst.base.stagebase import StageBase
@@ -55,7 +56,7 @@ class livecd_stage2(StageBase):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
- print "Resume point detected, skipping target path setup operation..."
+ log.notice('Resume point detected, skipping target path setup operation...')
else:
# first clean up any existing target stuff
if os.path.isdir(self.settings["target_path"]):
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 08/10] netboot: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
` (5 preceding siblings ...)
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 07/10] livecd_stage: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 09/10] embedded/grp: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 10/10] resume: " Mike Frysinger
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/targets/netboot.py | 6 +++---
catalyst/targets/netboot2.py | 19 ++++++++++---------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 46ec4eb..333a230 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -6,7 +6,7 @@ netboot target, version 1
import os
import types
-
+from catalyst import log
from catalyst.support import (CatalystError, normpath,
cmd, list_bashify, file_locate)
@@ -58,7 +58,7 @@ class netboot(StageBase):
def set_root_path(self):
# ROOT= variable for emerges
self.settings["root_path"]=normpath("/tmp/image")
- print "netboot root path is "+self.settings["root_path"]
+ log.info('netboot root path is %s', self.settings['root_path'])
# def build_packages(self):
# # build packages
@@ -123,7 +123,7 @@ class netboot(StageBase):
raise CatalystError("netboot build aborting due to error.",
print_traceback=True)
# end
- print "netboot: build finished !"
+ log.notice('netboot: build finished !')
def set_action_sequence(self):
self.settings["action_sequence"]=["unpack","unpack_snapshot",
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index 5508367..d882a06 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -8,6 +8,7 @@ import types
import shutil
from stat import ST_UID, ST_GID, ST_MODE
+from catalyst import log
from catalyst.support import (CatalystError, normpath, cmd, list_bashify)
from catalyst.fileops import ensure_dirs
@@ -53,7 +54,7 @@ class netboot2(StageBase):
self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
- print "Resume point detected, skipping target path setup operation..."
+ log.notice('Resume point detected, skipping target path setup operation...')
else:
# first clean up any existing target stuff
if os.path.isfile(self.settings["target_path"]):
@@ -69,7 +70,7 @@ class netboot2(StageBase):
# check for autoresume point
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("copy_files_to_image"):
- print "Resume point detected, skipping target path setup operation..."
+ log.notice('Resume point detected, skipping target path setup operation...')
else:
if "netboot2/packages" in self.settings:
if type(self.settings["netboot2/packages"]) == types.StringType:
@@ -103,7 +104,7 @@ class netboot2(StageBase):
def setup_overlay(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_overlay"):
- print "Resume point detected, skipping setup_overlay operation..."
+ log.notice('Resume point detected, skipping setup_overlay operation...')
else:
if "netboot2/overlay" in self.settings:
for x in self.settings["netboot2/overlay"]:
@@ -119,7 +120,7 @@ class netboot2(StageBase):
try:
cmd(self.settings["controller_file"]+\
" final",env=self.env)
- print ">>> Netboot Build Finished!"
+ log.notice('Netboot Build Finished!')
except CatalystError:
self.unbind()
raise CatalystError("Failed to move kernel images!",
@@ -128,20 +129,20 @@ class netboot2(StageBase):
def remove(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("remove"):
- print "Resume point detected, skipping remove operation..."
+ log.notice('Resume point detected, skipping remove operation...')
else:
if self.settings["spec_prefix"]+"/rm" in self.settings:
for x in self.settings[self.settings["spec_prefix"]+"/rm"]:
# we're going to shell out for all these cleaning operations,
# so we get easy glob handling
- print "netboot2: removing " + x
+ log.notice('netboot2: removing %s', x)
os.system("rm -rf " + self.settings["chroot_path"] +
self.settings["merge_path"] + x)
def empty(self):
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("empty"):
- print "Resume point detected, skipping empty operation..."
+ log.notice('Resume point detected, skipping empty operation...')
else:
if "netboot2/empty" in self.settings:
if type(self.settings["netboot2/empty"])==types.StringType:
@@ -149,9 +150,9 @@ class netboot2(StageBase):
for x in self.settings["netboot2/empty"]:
myemp=self.settings["chroot_path"] + self.settings["merge_path"] + x
if not os.path.isdir(myemp):
- print x,"not a directory or does not exist, skipping 'empty' operation."
+ log.warning('not a directory or does not exist, skipping "empty" operation: %s', x)
continue
- print "Emptying directory", x
+ log.info('Emptying directory %s', x)
# stat the dir, delete the dir, recreate the dir and set
# the proper perms and ownership
mystat=os.stat(myemp)
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 09/10] embedded/grp: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
` (6 preceding siblings ...)
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 08/10] netboot: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 10/10] resume: " Mike Frysinger
8 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
---
catalyst/targets/embedded.py | 7 +++----
catalyst/targets/grp.py | 8 ++++----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 6044e17..e441757 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -10,9 +10,8 @@ ROOT=/tmp/submerge emerge --something foo bar .
"""
# NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
-
+from catalyst import log
from catalyst.support import normpath
-
from catalyst.base.stagebase import StageBase
class embedded(StageBase):
@@ -39,8 +38,8 @@ class embedded(StageBase):
def set_stage_path(self):
self.settings["stage_path"]=normpath(self.settings["chroot_path"]+"/tmp/mergeroot")
- print "embedded stage path is "+self.settings["stage_path"]
+ log.info('embedded stage path is %s', self.settings['stage_path'])
def set_root_path(self):
self.settings["root_path"]=normpath("/tmp/mergeroot")
- print "embedded root path is "+self.settings["root_path"]
+ log.info('embedded root path is %s', self.settings['root_path'])
diff --git a/catalyst/targets/grp.py b/catalyst/targets/grp.py
index 4814ac6..b37366c 100644
--- a/catalyst/targets/grp.py
+++ b/catalyst/targets/grp.py
@@ -7,7 +7,7 @@ import os
import types
import glob
-
+from catalyst import log
from catalyst.support import (CatalystError, normpath, cmd, list_bashify)
from catalyst.fileops import ensure_dirs
from catalyst.base.stagebase import StageBase
@@ -44,7 +44,7 @@ class grp(StageBase):
self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
- print "Resume point detected, skipping target path setup operation..."
+ log.notice('Resume point detected, skipping target path setup operation...')
else:
# first clean up any existing target stuff
#if os.path.isdir(self.settings["target_path"]):
@@ -82,7 +82,7 @@ class grp(StageBase):
for pkgset in self.settings["grp"]:
if self.settings["grp/"+pkgset+"/type"] == "pkgset":
destdir=normpath(self.settings["target_path"]+"/"+pkgset+"/All")
- print "Digesting files in the pkgset....."
+ log.notice('Digesting files in the pkgset...')
digests=glob.glob(destdir+'/*.DIGESTS')
for i in digests:
if os.path.exists(i):
@@ -97,7 +97,7 @@ class grp(StageBase):
self.gen_digest_file(normpath(destdir+"/"+i))
else:
destdir=normpath(self.settings["target_path"]+"/"+pkgset)
- print "Digesting files in the srcset....."
+ log.notice('Digesting files in the srcset...')
digests=glob.glob(destdir+'/*.DIGESTS')
for i in digests:
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [gentoo-catalyst] [PATCH 10/10] resume: convert to log module
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
` (7 preceding siblings ...)
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 09/10] embedded/grp: " Mike Frysinger
@ 2015-10-11 6:29 ` Mike Frysinger
2015-10-11 14:16 ` Anthony G. Basile
8 siblings, 1 reply; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 6:29 UTC (permalink / raw
To: gentoo-catalyst
The AutoResumeError exception wasn't actually used as an exception --
it was never raised, only printed. Throw it away in place of a plain
log message.
---
catalyst/base/resume.py | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
index 443b46d..99d8abc 100644
--- a/catalyst/base/resume.py
+++ b/catalyst/base/resume.py
@@ -12,27 +12,13 @@ set, unset, is_set, is_unset, enabled, clear_all
'''
import os
-import sys
-import traceback
from snakeoil import fileutils
+from catalyst import log
from catalyst.fileops import ensure_dirs, pjoin, listdir_files, clear_dir
-class AutoResumeError(Exception):
- def __init__(self, message, print_traceback=False):
- if message:
- if print_traceback:
- (_type, value) = sys.exc_info()[:2]
- if value!=None:
- print
- print "Traceback values found. listing..."
- print traceback.print_exc(file=sys.stdout)
- print "!!! catalyst: AutoResumeError " + message
- print
-
-
class AutoResume(object):
'''Class for tracking and handling all aspects of
the autoresume option and related files.
@@ -73,7 +59,7 @@ class AutoResume(object):
fileutils.touch(fname)
self._points[point] = fname
except Exception as e:
- print AutoResumeError(str(e))
+ log.error('AutoResumeError: %s', e)
return False
return True
@@ -91,7 +77,7 @@ class AutoResume(object):
if data and no_lf:
data = data.replace('\n', '')
except OSError as e:
- print AutoResumeError(str(e))
+ log.error('AutoResumeError: %s', e)
return None
return data
return None
@@ -109,7 +95,7 @@ class AutoResume(object):
os.unlink(self._points[point])
self._points.pop(point)
except Exception as e:
- print AutoResumeError(str(e))
+ log.error('AutoResumeError: %s', e)
return False
return True
--
2.5.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [gentoo-catalyst] [PATCH 10/10] resume: convert to log module
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 10/10] resume: " Mike Frysinger
@ 2015-10-11 14:16 ` Anthony G. Basile
2015-10-11 17:38 ` Mike Frysinger
0 siblings, 1 reply; 12+ messages in thread
From: Anthony G. Basile @ 2015-10-11 14:16 UTC (permalink / raw
To: gentoo-catalyst
On 10/11/15 2:29 AM, Mike Frysinger wrote:
> The AutoResumeError exception wasn't actually used as an exception --
> it was never raised, only printed. Throw it away in place of a plain
> log message.
> ---
> catalyst/base/resume.py | 22 ++++------------------
> 1 file changed, 4 insertions(+), 18 deletions(-)
>
all the 'convert to log modules' are pretty straight forward.
mike let me know when you think i should give master/HEAD a test drive.
--
Anthony G. Basile, Ph.D.
Gentoo Linux Developer [Hardened]
E-Mail : blueness@gentoo.org
GnuPG FP : 1FED FAD9 D82C 52A5 3BAB DC79 9384 FA6E F52D 4BBA
GnuPG ID : F52D4BBA
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-catalyst] [PATCH 10/10] resume: convert to log module
2015-10-11 14:16 ` Anthony G. Basile
@ 2015-10-11 17:38 ` Mike Frysinger
0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2015-10-11 17:38 UTC (permalink / raw
To: gentoo-catalyst
[-- Attachment #1: Type: text/plain, Size: 645 bytes --]
On 11 Oct 2015 10:16, Anthony G. Basile wrote:
> On 10/11/15 2:29 AM, Mike Frysinger wrote:
> > The AutoResumeError exception wasn't actually used as an exception --
> > it was never raised, only printed. Throw it away in place of a plain
> > log message.
> > ---
> > catalyst/base/resume.py | 22 ++++------------------
> > 1 file changed, 4 insertions(+), 18 deletions(-)
>
> all the 'convert to log modules' are pretty straight forward.
>
> mike let me know when you think i should give master/HEAD a test drive.
sure, i've pushed everything now, and it'd be good to verify things keep
working for everyone else.
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-10-11 17:38 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-11 6:29 [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 02/10] stage2: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 03/10] stage3: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 04/10] stagebase: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 05/10] clearbase: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 06/10] support: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 07/10] livecd_stage: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 08/10] netboot: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 09/10] embedded/grp: " Mike Frysinger
2015-10-11 6:29 ` [gentoo-catalyst] [PATCH 10/10] resume: " Mike Frysinger
2015-10-11 14:16 ` Anthony G. Basile
2015-10-11 17:38 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox