From dcbd09d608fdb78a18b58656866436c82da44ad4 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Wed, 1 Aug 2012 14:17:08 +0800 Subject: [PATCH] adjust timezone warning to exception and refactor cp cmd Signed-off-by: Gui Chen --- mic/kickstart/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index bfa915b..5dcc803 100644 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -237,10 +237,16 @@ class TimezoneConfig(KickstartConfig): tz_source = "/usr/share/zoneinfo/%s" % (tz) tz_dest = "/etc/localtime" try: - self.call(["/bin/cp", "-f", tz_source, tz_dest]) + cpcmd = fs.find_binary_inchroot('cp', self.instroot) + if cpcmd: + self.call([cpcmd, "-f", tz_source, tz_dest]) + else: + cpcmd = fs.find_binary_path('cp') + subprocess.call([cpcmd, "-f", + self.path(tz_source), + self.path(tz_dest)]) except (IOError, OSError), (errno, msg): - msger.warning("Failed to copy timezone info from '%s' to '%s': %s" \ - % (tz_source, tz_dest, msg)) + raise errors.KsError("Timezone setting error: %s" % msg) class AuthConfig(KickstartConfig): """A class to apply a kickstart authconfig configuration to a system.""" -- 2.7.4