Anonymous avatar Anonymous committed 6ed9a0a

more logging

Comments (0)

Files changed (3)

ec2control/ec2.py

 from boto.ec2.connection import EC2Connection
 import time
+import logging
+log = logging.getLogger(__name__)
 
 class CommandError(Exception):
     pass
             return None
 
     def start(self):
-        instances = self._conn.start_instances(instance_ids=[self.config['instance_id']])
+        instance_id = self.config['instance_id']
+        log.info("Starting instance id: %s", instance_id)
+        instances = self._conn.start_instances(instance_ids=[instance_id])
 
         self.instance = inst = instances[0]
 
         time.sleep(10)
 
         self.status = inst.state
+        log.info("Status: %s", self.status)
 

ec2control/emailer.py

 from email.mime.text import MIMEText
 import re
 from mako.template import Template
+import logging
+log = logging.getLogger(__name__)
 
 class ParseMail(object):
     def __init__(self, email):
         self._send(subject, body)
 
     def _send(self, subject, message):
+
         msg = MIMEText(message)
 
         to_addr = self.parsed_struct.effective_from
         msg = msg.as_string()
         smtp = smtplib.SMTP(self.config['smtp_host'], int(self.config['smtp_port']))
 
-        for addr in set([to_addr] + re.split(r',\s*', cc_addr)):
+        addrs = set([to_addr] + re.split(r',\s*', cc_addr))
+        log.info("Sending mail to %s", ", ".join(addrs))
+        log.info(subject)
+        log.debug(message)
+
+        for addr in addrs:
             smtp.sendmail(from_addr, addr, msg)
       zip_safe=False,
       scripts=['scripts/ec2control'],
       install_requires=[
+          'boto',
           'Mako'
       ],
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.