From 23cf7e35bf9aa1cffc9d1bb2f20d362b57110723 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 21 Jun 2012 20:28:21 -0700 Subject: Use RuntimeError subclass instead of top level Exception --- cloudinit/config/cc_landscape.py | 8 ++++---- cloudinit/config/cc_update_etc_hosts.py | 4 ++-- cloudinit/distros/rhel.py | 4 ++-- cloudinit/distros/ubuntu.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_landscape.py b/cloudinit/config/cc_landscape.py index d45c9203..99a958b0 100644 --- a/cloudinit/config/cc_landscape.py +++ b/cloudinit/config/cc_landscape.py @@ -61,10 +61,10 @@ def handle(name, cfg, cloud, log, _args): ls_cloudcfg = cfg.get("landscape", {}) - if not isinstance(ls_cloudcfg, dict): - raise Exception(("'landscape' key existed in config," - " but not a dictionary type," - " is a %s instead"), util.obj_name(ls_cloudcfg)) + if not isinstance(ls_cloudcfg, (dict)): + raise RuntimeError(("'landscape' key existed in config," + " but not a dictionary type," + " is a %s instead"), util.obj_name(ls_cloudcfg)) merge_data = [ LSC_BUILTIN_CFG, diff --git a/cloudinit/config/cc_update_etc_hosts.py b/cloudinit/config/cc_update_etc_hosts.py index 6820ac4f..c148b12e 100644 --- a/cloudinit/config/cc_update_etc_hosts.py +++ b/cloudinit/config/cc_update_etc_hosts.py @@ -39,8 +39,8 @@ def handle(name, cfg, cloud, log, _args): distro_n = cloud.distro.name tpl_fn_name = cloud.get_template_filename("hosts.%s" % (distro_n)) if not tpl_fn_name: - raise Exception(("No hosts template could be" - " found for distro %s") % (distro_n)) + raise RuntimeError(("No hosts template could be" + " found for distro %s") % (distro_n)) out_fn = cloud.paths.join(False, '/etc/hosts') templater.render_to_file(tpl_fn_name, out_fn, diff --git a/cloudinit/distros/rhel.py b/cloudinit/distros/rhel.py index df63d559..dff76075 100644 --- a/cloudinit/distros/rhel.py +++ b/cloudinit/distros/rhel.py @@ -208,8 +208,8 @@ class Distro(distros.Distro): def set_timezone(self, tz): tz_file = os.path.join("/usr/share/zoneinfo", tz) if not os.path.isfile(tz_file): - raise Exception(("Invalid timezone %s," - " no file found at %s") % (tz, tz_file)) + raise RuntimeError(("Invalid timezone %s," + " no file found at %s") % (tz, tz_file)) # Adjust the sysconfig clock zone setting read_fn = self._paths.join(True, "/etc/sysconfig/clock") old_contents = self._read_conf(read_fn) diff --git a/cloudinit/distros/ubuntu.py b/cloudinit/distros/ubuntu.py index e8b95374..b23945d8 100644 --- a/cloudinit/distros/ubuntu.py +++ b/cloudinit/distros/ubuntu.py @@ -121,8 +121,8 @@ class Distro(distros.Distro): def set_timezone(self, tz): tz_file = os.path.join("/usr/share/zoneinfo", tz) if not os.path.isfile(tz_file): - raise Exception(("Invalid timezone %s," - " no file found at %s") % (tz, tz_file)) + raise RuntimeError(("Invalid timezone %s," + " no file found at %s") % (tz, tz_file)) tz_lines = [ "# Created by cloud-init", str(tz), -- cgit v1.2.3