Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 08/10] netboot: convert to log module
Date: Sun, 11 Oct 2015 06:29:37
Message-Id: 1444544952-32408-8-git-send-email-vapier@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 01/10] stage1: convert to log module by Mike Frysinger
1 ---
2 catalyst/targets/netboot.py | 6 +++---
3 catalyst/targets/netboot2.py | 19 ++++++++++---------
4 2 files changed, 13 insertions(+), 12 deletions(-)
5
6 diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
7 index 46ec4eb..333a230 100644
8 --- a/catalyst/targets/netboot.py
9 +++ b/catalyst/targets/netboot.py
10 @@ -6,7 +6,7 @@ netboot target, version 1
11 import os
12 import types
13
14 -
15 +from catalyst import log
16 from catalyst.support import (CatalystError, normpath,
17 cmd, list_bashify, file_locate)
18
19 @@ -58,7 +58,7 @@ class netboot(StageBase):
20 def set_root_path(self):
21 # ROOT= variable for emerges
22 self.settings["root_path"]=normpath("/tmp/image")
23 - print "netboot root path is "+self.settings["root_path"]
24 + log.info('netboot root path is %s', self.settings['root_path'])
25
26 # def build_packages(self):
27 # # build packages
28 @@ -123,7 +123,7 @@ class netboot(StageBase):
29 raise CatalystError("netboot build aborting due to error.",
30 print_traceback=True)
31 # end
32 - print "netboot: build finished !"
33 + log.notice('netboot: build finished !')
34
35 def set_action_sequence(self):
36 self.settings["action_sequence"]=["unpack","unpack_snapshot",
37 diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
38 index 5508367..d882a06 100644
39 --- a/catalyst/targets/netboot2.py
40 +++ b/catalyst/targets/netboot2.py
41 @@ -8,6 +8,7 @@ import types
42 import shutil
43 from stat import ST_UID, ST_GID, ST_MODE
44
45 +from catalyst import log
46 from catalyst.support import (CatalystError, normpath, cmd, list_bashify)
47 from catalyst.fileops import ensure_dirs
48
49 @@ -53,7 +54,7 @@ class netboot2(StageBase):
50 self.settings["target_subpath"])
51 if "autoresume" in self.settings["options"] \
52 and self.resume.is_enabled("setup_target_path"):
53 - print "Resume point detected, skipping target path setup operation..."
54 + log.notice('Resume point detected, skipping target path setup operation...')
55 else:
56 # first clean up any existing target stuff
57 if os.path.isfile(self.settings["target_path"]):
58 @@ -69,7 +70,7 @@ class netboot2(StageBase):
59 # check for autoresume point
60 if "autoresume" in self.settings["options"] \
61 and self.resume.is_enabled("copy_files_to_image"):
62 - print "Resume point detected, skipping target path setup operation..."
63 + log.notice('Resume point detected, skipping target path setup operation...')
64 else:
65 if "netboot2/packages" in self.settings:
66 if type(self.settings["netboot2/packages"]) == types.StringType:
67 @@ -103,7 +104,7 @@ class netboot2(StageBase):
68 def setup_overlay(self):
69 if "autoresume" in self.settings["options"] \
70 and self.resume.is_enabled("setup_overlay"):
71 - print "Resume point detected, skipping setup_overlay operation..."
72 + log.notice('Resume point detected, skipping setup_overlay operation...')
73 else:
74 if "netboot2/overlay" in self.settings:
75 for x in self.settings["netboot2/overlay"]:
76 @@ -119,7 +120,7 @@ class netboot2(StageBase):
77 try:
78 cmd(self.settings["controller_file"]+\
79 " final",env=self.env)
80 - print ">>> Netboot Build Finished!"
81 + log.notice('Netboot Build Finished!')
82 except CatalystError:
83 self.unbind()
84 raise CatalystError("Failed to move kernel images!",
85 @@ -128,20 +129,20 @@ class netboot2(StageBase):
86 def remove(self):
87 if "autoresume" in self.settings["options"] \
88 and self.resume.is_enabled("remove"):
89 - print "Resume point detected, skipping remove operation..."
90 + log.notice('Resume point detected, skipping remove operation...')
91 else:
92 if self.settings["spec_prefix"]+"/rm" in self.settings:
93 for x in self.settings[self.settings["spec_prefix"]+"/rm"]:
94 # we're going to shell out for all these cleaning operations,
95 # so we get easy glob handling
96 - print "netboot2: removing " + x
97 + log.notice('netboot2: removing %s', x)
98 os.system("rm -rf " + self.settings["chroot_path"] +
99 self.settings["merge_path"] + x)
100
101 def empty(self):
102 if "autoresume" in self.settings["options"] \
103 and self.resume.is_enabled("empty"):
104 - print "Resume point detected, skipping empty operation..."
105 + log.notice('Resume point detected, skipping empty operation...')
106 else:
107 if "netboot2/empty" in self.settings:
108 if type(self.settings["netboot2/empty"])==types.StringType:
109 @@ -149,9 +150,9 @@ class netboot2(StageBase):
110 for x in self.settings["netboot2/empty"]:
111 myemp=self.settings["chroot_path"] + self.settings["merge_path"] + x
112 if not os.path.isdir(myemp):
113 - print x,"not a directory or does not exist, skipping 'empty' operation."
114 + log.warning('not a directory or does not exist, skipping "empty" operation: %s', x)
115 continue
116 - print "Emptying directory", x
117 + log.info('Emptying directory %s', x)
118 # stat the dir, delete the dir, recreate the dir and set
119 # the proper perms and ownership
120 mystat=os.stat(myemp)
121 --
122 2.5.2