summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-01-26 09:03:46 -0500
committerScott Moser <smoser@ubuntu.com>2011-01-26 09:03:46 -0500
commitbe11324740ad4624c45a6e909643ab84aecdbf16 (patch)
treea7a2a7e8a4b4a05ea5a071610b7c52bf4e6ef810
parentf69109bb2be91a7210a88bfb1b4467f80dc6ba64 (diff)
downloadvyos-cloud-init-be11324740ad4624c45a6e909643ab84aecdbf16.tar.gz
vyos-cloud-init-be11324740ad4624c45a6e909643ab84aecdbf16.zip
change 'except' syntax to python 3 style.
Everywhere that there occurred: except Exception, e: changed to except Exception as e:
-rwxr-xr-xcloud-init-cfg.py2
-rwxr-xr-xcloud-init.py6
-rw-r--r--cloudinit/CloudConfig/cc_locale.py2
-rw-r--r--cloudinit/CloudConfig/cc_phone_home.py2
-rw-r--r--cloudinit/CloudConfig/cc_resizefs.py4
-rw-r--r--cloudinit/CloudConfig/cc_rightscale_userdata.py2
-rw-r--r--cloudinit/CloudConfig/cc_rsyslog.py4
-rw-r--r--cloudinit/CloudConfig/cc_set_hostname.py2
-rw-r--r--cloudinit/CloudConfig/cc_update_hostname.py6
-rw-r--r--cloudinit/DataSourceEc2.py4
-rw-r--r--cloudinit/__init__.py2
-rw-r--r--cloudinit/boto_utils.py2
12 files changed, 19 insertions, 19 deletions
diff --git a/cloud-init-cfg.py b/cloud-init-cfg.py
index 442fc4d8..75ede23f 100755
--- a/cloud-init-cfg.py
+++ b/cloud-init-cfg.py
@@ -65,7 +65,7 @@ def main():
try:
(outfmt, errfmt) = CC.get_output_cfg(cc.cfg,modename)
CC.redirect_output(outfmt, errfmt)
- except Exception, e:
+ except Exception as e:
err("Failed to get and set output config: %s\n" % e)
cloudinit.logging_set_from_cfg(cc.cfg)
diff --git a/cloud-init.py b/cloud-init.py
index adac1874..92d8a091 100755
--- a/cloud-init.py
+++ b/cloud-init.py
@@ -57,7 +57,7 @@ def main():
cfg = cloudinit.get_base_cfg()
(outfmt, errfmt) = CC.get_output_cfg(cfg,"init")
CC.redirect_output(outfmt, errfmt)
- except Exception, e:
+ except Exception as e:
warn("Failed to get and set output config: %s\n" % e)
msg = "cloud-init %s running: %s. up %s seconds" % (cmd, now, uptime)
@@ -70,7 +70,7 @@ def main():
try:
cloudinit.initfs()
- except Exception, e:
+ except Exception as e:
warn("failed to initfs, likely bad things to come: %s\n" % str(e))
@@ -120,7 +120,7 @@ def main():
if outfmt_orig != outfmt or errfmt_orig != errfmt:
warn("stdout, stderr changing to (%s,%s)" % (outfmt,errfmt))
CC.redirect_output(outfmt, errfmt)
- except Exception, e:
+ except Exception as e:
warn("Failed to get and set output config: %s\n" % e)
module_list = CC.read_cc_modules(cc.cfg,"cloud_init_modules")
diff --git a/cloudinit/CloudConfig/cc_locale.py b/cloudinit/CloudConfig/cc_locale.py
index c164b5ba..b9a221ca 100644
--- a/cloudinit/CloudConfig/cc_locale.py
+++ b/cloudinit/CloudConfig/cc_locale.py
@@ -38,6 +38,6 @@ def handle(name,cfg,cloud,log,args):
try:
apply_locale(locale)
- except Exception, e:
+ except Exception as e:
log.debug(traceback.format_exc(e))
raise Exception("failed to apply locale %s" % locale)
diff --git a/cloudinit/CloudConfig/cc_phone_home.py b/cloudinit/CloudConfig/cc_phone_home.py
index ee463757..be6abfa8 100644
--- a/cloudinit/CloudConfig/cc_phone_home.py
+++ b/cloudinit/CloudConfig/cc_phone_home.py
@@ -88,7 +88,7 @@ def handle(name,cfg,cloud,log,args):
util.readurl(url, submit_keys)
log.debug("succeeded submit to %s on try %i" % (url, i+1))
return
- except Exception, e:
+ except Exception as e:
log.debug("failed to post to %s on try %i" % (url, i+1))
last_e = e
sleep(3)
diff --git a/cloudinit/CloudConfig/cc_resizefs.py b/cloudinit/CloudConfig/cc_resizefs.py
index 11a10005..6e5f364c 100644
--- a/cloudinit/CloudConfig/cc_resizefs.py
+++ b/cloudinit/CloudConfig/cc_resizefs.py
@@ -34,7 +34,7 @@ def handle(name,cfg,cloud,log,args):
cmd = ['blkid', '-sTYPE', '-ovalue', '/dev/root']
try:
(fstype,err) = util.subp(cmd)
- except Exception, e:
+ except Exception as e:
log.warn("Failed to get filesystem type via %s" % cmd)
raise
@@ -48,7 +48,7 @@ def handle(name,cfg,cloud,log,args):
try:
(out,err) = util.subp(resize_cmd)
- except Exception, e:
+ except Exception as e:
log.warn("Failed to resize filesystem (%s,%s)" % cmd)
raise
diff --git a/cloudinit/CloudConfig/cc_rightscale_userdata.py b/cloudinit/CloudConfig/cc_rightscale_userdata.py
index a90e6d18..4875acbe 100644
--- a/cloudinit/CloudConfig/cc_rightscale_userdata.py
+++ b/cloudinit/CloudConfig/cc_rightscale_userdata.py
@@ -65,7 +65,7 @@ def handle(name,cfg,cloud,log,args):
try:
content = util.readurl(url)
util.write_file(fname, content, mode=0700)
- except Exception, e:
+ except Exception as e:
if not first_e: first_e = None
log.warn("%s failed to read %s: %s" % (my_name, url, e))
diff --git a/cloudinit/CloudConfig/cc_rsyslog.py b/cloudinit/CloudConfig/cc_rsyslog.py
index 3320dbb2..a8ee8476 100644
--- a/cloudinit/CloudConfig/cc_rsyslog.py
+++ b/cloudinit/CloudConfig/cc_rsyslog.py
@@ -64,7 +64,7 @@ def handle(name,cfg,cloud,log,args):
try:
util.write_file(filename, content + "\n", omode=omode)
- except Exception, e:
+ except Exception as e:
log.debug(traceback.format_exc(e))
elst.append((content, "failed to write to %s" % filename))
@@ -83,7 +83,7 @@ def handle(name,cfg,cloud,log,args):
p = util.subp(['service', 'rsyslog', 'restart'])
restarted = True
- except Exception, e:
+ except Exception as e:
elst.append(("restart", str(e)))
if restarted:
diff --git a/cloudinit/CloudConfig/cc_set_hostname.py b/cloudinit/CloudConfig/cc_set_hostname.py
index 34621e97..2b130810 100644
--- a/cloudinit/CloudConfig/cc_set_hostname.py
+++ b/cloudinit/CloudConfig/cc_set_hostname.py
@@ -26,7 +26,7 @@ def handle(name,cfg,cloud,log,args):
try:
hostname = util.get_cfg_option_str(cfg,"hostname",cloud.get_hostname())
set_hostname(hostname, log)
- except Exception, e:
+ except Exception as e:
util.logexc(log)
log.warn("failed to set hostname\n")
diff --git a/cloudinit/CloudConfig/cc_update_hostname.py b/cloudinit/CloudConfig/cc_update_hostname.py
index 3663c0ab..a49f8649 100644
--- a/cloudinit/CloudConfig/cc_update_hostname.py
+++ b/cloudinit/CloudConfig/cc_update_hostname.py
@@ -31,7 +31,7 @@ def handle(name,cfg,cloud,log,args):
hostname = util.get_cfg_option_str(cfg,"hostname",cloud.get_hostname())
prev ="%s/%s" % (cloud.get_cpath('datadir'),"previous-hostname")
update_hostname(hostname, prev, log)
- except Exception, e:
+ except Exception as e:
log.warn("failed to set hostname\n")
raise
@@ -50,7 +50,7 @@ def read_hostname(filename, default=None):
line = line.rstrip()
if line:
return line
- except IOError, e:
+ except IOError as e:
if e.errno != errno.ENOENT: raise
return default
@@ -62,7 +62,7 @@ def update_hostname(hostname, prev_file, log):
try:
hostname_prev = read_hostname(prev_file)
- except Exception, e:
+ except Exception as e:
log.warn("Failed to open %s: %s" % (prev_file, e))
try:
diff --git a/cloudinit/DataSourceEc2.py b/cloudinit/DataSourceEc2.py
index 1c0edc59..8ecb28ad 100644
--- a/cloudinit/DataSourceEc2.py
+++ b/cloudinit/DataSourceEc2.py
@@ -99,9 +99,9 @@ class DataSourceEc2(DataSource.DataSource):
resp = urllib2.urlopen(req, timeout=2)
if resp.read() != "": return True
reason = "empty data [%s]" % resp.getcode()
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
reason = "http error [%s]" % e.code
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
reason = "url error [%s]" % e.reason
if x == 0:
diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py
index 2d4b8c87..7e60ee13 100644
--- a/cloudinit/__init__.py
+++ b/cloudinit/__init__.py
@@ -222,7 +222,7 @@ class CloudInit:
def set_cur_instance(self):
try:
os.unlink(cur_instance_link)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT: raise
os.symlink("./instances/%s" % self.get_instance_id(), cur_instance_link)
diff --git a/cloudinit/boto_utils.py b/cloudinit/boto_utils.py
index 5030e5fd..b38483fa 100644
--- a/cloudinit/boto_utils.py
+++ b/cloudinit/boto_utils.py
@@ -43,7 +43,7 @@ def retry_url(url, retry_on_404=True):
req = urllib2.Request(url)
resp = urllib2.urlopen(req)
return resp.read()
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
# in 2.6 you use getcode(), in 2.5 and earlier you use code
if hasattr(e, 'getcode'):
code = e.getcode()