From bc004d904fe1b9272200bd6f6a2a4f3a470fff3a Mon Sep 17 00:00:00 2001
From: Juerg Haefliger <juerg.haefliger@hp.com>
Date: Fri, 16 Sep 2011 10:54:05 +0200
Subject: [PATCH] Modifications to support byte-compilation with python2.4

---
 cloud-init-run-module.py          |    4 ++--
 cloud-init.py                     |    4 ++--
 cloudinit/CloudConfig/__init__.py |    2 +-
 cloudinit/DataSourceEc2.py        |    2 +-
 cloudinit/UserDataHandler.py      |    4 ++--
 cloudinit/__init__.py             |   16 ++++++++--------
 cloudinit/execute.py              |    4 ++--
 cloudinit/util.py                 |    4 ++--
 9 files changed, 20 insertions(+), 20 deletions(-)
 create mode 100644 cloud-init-0.5.15/cloudinit/__init__.pyc

Index: b/cloud-init-run-module.py
===================================================================
--- a/cloud-init-run-module.py	2012-06-29 15:58:49.400652566 +0200
+++ b/cloud-init-run-module.py	2012-06-29 16:04:52.354452355 +0200
@@ -40,7 +40,7 @@
     cloud = cloudinit.CloudInit()
     try:
         cloud.get_data_source()
-    except Exception as e:
+    except Exception, e:
         fail("Failed to get instance data\n\t%s" % traceback.format_exc(),log)
 
     if cloud.sem_has_run(semname,freq):
@@ -64,7 +64,7 @@
 
     try:
         cloud.sem_and_run(semname, freq, inst.run, [run_args,cfg_path,log], False)
-    except Exception as e:
+    except Exception, e:
         fail("Execution of %s failed:%s" % (semname,e), log)
 
     sys.exit(0)
Index: b/cloud-init.py
===================================================================
--- a/cloud-init.py	2012-06-29 15:58:49.388652507 +0200
+++ b/cloud-init.py	2012-06-29 16:04:52.346452318 +0200
@@ -44,7 +44,7 @@
        uptimef=open("/proc/uptime")
        uptime=uptimef.read().split(" ")[0]
        uptimef.close()
-    except IOError as e:
+    except IOError, e:
        warn("unable to open /proc/uptime\n")
        uptime = "na"
 
@@ -70,7 +70,7 @@
 
     try:
         cloud.get_data_source()
-    except cloudinit.DataSourceNotFoundException as e:
+    except cloudinit.DataSourceNotFoundException, e:
         sys.stderr.write("no instance data found in %s\n" % cmd)
         sys.exit(1)
 
Index: b/cloudinit/CloudConfig/__init__.py
===================================================================
--- a/cloudinit/CloudConfig/__init__.py	2012-06-29 15:58:49.444652788 +0200
+++ b/cloudinit/CloudConfig/__init__.py	2012-06-29 16:04:52.498453069 +0200
@@ -25,7 +25,7 @@
 per_instance="once-per-instance"
 per_always="always"
 
-class CloudConfig():
+class CloudConfig:
     cfgfile = None
     cfg = None
 
Index: b/cloudinit/DataSourceEc2.py
===================================================================
--- a/cloudinit/DataSourceEc2.py	2012-06-29 15:58:49.420652665 +0200
+++ b/cloudinit/DataSourceEc2.py	2012-06-29 16:04:52.366452416 +0200
@@ -58,7 +58,7 @@
             self.userdata_raw = boto_utils.get_instance_userdata(self.api_ver)
             self.metadata = boto_utils.get_instance_metadata(self.api_ver)
             return True
-        except Exception as e:
+        except Exception, e:
             print e
             return False
 
Index: b/cloudinit/UserDataHandler.py
===================================================================
--- a/cloudinit/UserDataHandler.py	2012-06-29 15:58:49.432652729 +0200
+++ b/cloudinit/UserDataHandler.py	2012-06-29 16:04:52.374452464 +0200
@@ -17,8 +17,8 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import email
 
-from email.mime.multipart import MIMEMultipart
-from email.mime.text import MIMEText
+from email import MIMEMultipart
+from email import MIMEText
 
 
 starts_with_mappings={
Index: b/cloudinit/__init__.py
===================================================================
--- a/cloudinit/__init__.py	2012-06-29 15:58:49.456652844 +0200
+++ b/cloudinit/__init__.py	2012-06-29 16:04:52.530453230 +0200
@@ -136,7 +136,7 @@
         try:
             open(def_log_file,"a").close()
             logfile = def_log_file
-        except IOError as e:
+        except IOError, e:
             if e.errno == errno.EACCES:
                 logfile = "/dev/null"
             else: raise
@@ -222,7 +222,7 @@
     def write_to_cache(self):
         try:
             os.makedirs(os.path.dirname(data_source_cache))
-        except OSError as e:
+        except OSError, e:
             if e.errno != errno.EEXIST:
                 return False
                 
@@ -263,7 +263,7 @@
                     self.datasource_name = ds
                     log.debug("found data source %s" % ds)
                     return True
-            except Exception as e:
+            except Exception, e:
                 log.warn("get_data of %s raised %s" % (ds,e))
                 util.logexc(log)
                 pass
@@ -305,7 +305,7 @@
     
         try:
             os.makedirs(os.path.dirname(semfile))
-        except OSError as e:
+        except OSError, e:
             if e.errno != errno.EEXIST:
                 raise e
     
@@ -325,7 +325,7 @@
         semfile = self.sem_getpath(name,freq)
         try:
             os.unlink(semfile)
-        except OSError as e:
+        except OSError, e:
             if e.errno != errno.ENOENT:
                 return False
             
@@ -458,10 +458,10 @@
             env=os.environ.copy()
             env['INSTANCE_ID']= self.datasource.get_instance_id()
             ret = subprocess.check_call([filepath], env=env)
-        except subprocess.CalledProcessError as e:
+        except subprocess.CalledProcessError, e:
             log.error("boothooks script %s returned %i" %
                 (filepath,e.returncode))
-        except Exception as e:
+        except Exception, e:
             log.error("boothooks unknown exception %s when running %s" %
                 (e,filepath))
 
@@ -484,7 +484,7 @@
 def purge_cache():
     try:
         os.unlink(data_source_cache)
-    except OSError as e:
+    except OSError, e:
         if e.errno != errno.ENOENT: return(False)
     except:
         return(False)
Index: b/cloudinit/execute.py
===================================================================
--- a/cloudinit/execute.py	2012-06-29 15:58:49.468652903 +0200
+++ b/cloudinit/execute.py	2012-06-29 16:04:52.542453289 +0200
@@ -21,9 +21,9 @@
     try:
         subprocess.check_call(args)
         return
-    except subprocess.CalledProcessError as e:
+    except subprocess.CalledProcessError, e:
         log.debug(traceback.format_exc(e))
         raise Exception("Cmd returned %s: %s" % ( e.returncode, args ))
-    except OSError as e:
+    except OSError, e:
         log.debug(traceback.format_exc(e))
         raise Exception("Cmd failed to execute: %s" % ( args ))
Index: b/cloudinit/util.py
===================================================================
--- a/cloudinit/util.py	2012-06-29 15:58:49.408652606 +0200
+++ b/cloudinit/util.py	2012-06-29 16:04:52.358452383 +0200
@@ -35,7 +35,7 @@
 	    conf = yaml.load(stream)
 	    stream.close()
 	    return conf
-    except IOError as e:
+    except IOError, e:
         if e.errno == errno.ENOENT:
             return { }
         raise
@@ -79,7 +79,7 @@
 def write_file(file,content,mode=0644,omode="wb"):
         try:
             os.makedirs(os.path.dirname(file))
-        except OSError as e:
+        except OSError, e:
             if e.errno != errno.EEXIST:
                 raise e
 
