<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -257,7 +257,7 @@ class EmailReport(webapp.RequestHandler):
 			return None
 
 	def send_email(self, pid, subject, email_body):
-		message = mail.EmailMessage(sender=settings.PRODUCTS[pid]['from_address'],
+		message = mail.EmailMessage(sender=settings.SETTINGS['admin_email_address'],
 									subject=subject)
 		message.to = settings.PRODUCTS[pid]['to_addresses']
 		message.html = email_body</diff>
      <filename>jobs/email_report.py</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,8 @@ import wsgiref.handlers
 from google.appengine.ext import webapp
 from google.appengine.ext.webapp.util import login_required
 from google.appengine.api import urlfetch
-from google.appengine.api.labs import taskqueue
+from google.appengine.api import mail
+
 import datetime
 import sys
 
@@ -14,18 +15,22 @@ from processors import report_persister
 class ReportJob(webapp.RequestHandler):
 
 	def get(self):
+		# iTunes Connect stores reports with a 1 day delay
+		now = datetime.date.today()
+		one_day = datetime.timedelta(days=1)
+		yesterday = now - one_day
+		yesterday = yesterday.strftime('%m/%d/%Y')
 		try:
-			# iTunes Connect stores reports with a 1 day delay
-			now = datetime.date.today()
-			one_day = datetime.timedelta(days=1)
-			yesterday = now - one_day
-			yesterday = yesterday.strftime('%m/%d/%Y')
 			latest_report = itcscrape.getLastDayReport(settings.SETTINGS['itunesconnect_username'], settings.SETTINGS['itunesconnect_password'], yesterday)
 			report_persister.persist(latest_report['filename'], latest_report['content'])
-		except urlfetch.DownloadError:
-			# Download failed most likely due to a timeout
-			# Add to the task queue to keep trying to download the report
-			taskqueue.add(url='/jobs/pull_report', method='GET')
+		except:
+			# Download failed (timeout or report not available yet)
+			# Send email to administrator
+			message = mail.EmailMessage(sender=settings.SETTINGS['admin_email_address'],
+							   subject='[ASM] Report job failed for: ' + yesterday)
+			message.to = settings.SETTINGS['admin_email_address']
+			message.body = 'Failed to download the iTunes Connect sales report for: ' + yesterday
+			message.send()
 
 def main():
 	application = webapp.WSGIApplication([('/jobs/pull_report', ReportJob)], debug=True)</diff>
      <filename>jobs/pull_report.py</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,9 @@ SETTINGS = {
 	# Your iTunes Connect credentials for the cron job to log in and download your reports daily
 	&quot;itunesconnect_username&quot;: &quot;&lt;&lt;username&gt;&gt;&quot;,
 	&quot;itunesconnect_password&quot;: &quot;&lt;&lt;password&gt;&gt;&quot;,
+
+	# This must be the email address of a registered administrator for the application due to mail API restrictions
+	&quot;admin_email_address&quot;: &quot;My Name &lt;sender@example.com&gt;&quot;,
 	
 	# Don't change these
 	&quot;template_path&quot;: APP_ROOT_DIR + '/templates/',
@@ -38,9 +41,6 @@ PRODUCTS = {
 		&quot;versions&quot;: [{'name': 'v1.0', 'date': datetime.date(2009, 6, 22)},
 					{'name': 'v1.1', 'date': datetime.date(2009, 7, 18)}],
 
-		# This must be the email address of a registered administrator for the application due to mail API restrictions
-		&quot;from_address&quot;: &quot;My Name &lt;sender@example.com&gt;&quot;,
-
 		# List of email addresses you would like the daily reports sent to
 		&quot;to_addresses&quot;: [
 			'Recipient Name &lt;recipient@example.com&gt;',</diff>
      <filename>settings.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fd2737d64e2638d71befc1e34afbc1164e9d9ef1</id>
    </parent>
  </parents>
  <author>
    <name>Basil Shkara</name>
    <email>basil@oiledmachine.com</email>
  </author>
  <url>http://github.com/baz/app-sales-machine/commit/c7050da36a10b02ce7dd6f404b895d1e775dda54</url>
  <id>c7050da36a10b02ce7dd6f404b895d1e775dda54</id>
  <committed-date>2009-11-07T21:21:14-08:00</committed-date>
  <authored-date>2009-11-07T21:21:14-08:00</authored-date>
  <message>Send email to administrator when download fails.</message>
  <tree>ca6d39e8f633f6e70926b62a740fda9a0541d3f4</tree>
  <committer>
    <name>Basil Shkara</name>
    <email>basil@oiledmachine.com</email>
  </committer>
</commit>
