-
Website
http://oiledmachine.com/posts -
Original page
http://www.oiledmachine.com/posts/2009/09/05/app-sales-machine.html -
Subscribe
All Comments -
Community
-
Top Commenters
-
nonoDream
1 comment · 1 points
-
Lakshmi Vyas
1 comment · 1 points
-
banoidas
1 comment · 1 points
-
calbot
1 comment · 1 points
-
uprise78
1 comment · 1 points
-
-
Popular Threads
???
I've successfully installed your app. Is there a way to test the application without waiting for one day to test if one settings are good ?
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 509, in __call__
handler.post(*groups)
File "/base/data/home/apps/appstoresalesmachine/1.336283913765627149/handlers/admin.py", line 32, in post
tarball = tarfile.open(fileobj=file_data)
File "/base/python_dist/lib/python2.5/tarfile.py", line 1153, in open
raise ReadError("file could not be opened successfully")
ReadError: file could not be opened successfully
1. I downloaded my last 4 daily reports from iTunes Connect into a new directory.
2. I changed to the new directory and executed: "tar cvf reports.tar *.txt"
3. I opened my app's home URL and attempted to upload reports.tar which resulted in:
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 509, in __call__
handler.post(*groups)
File "/base/data/home/apps/headcasegamesappsales/2.336355808577417080/handlers/admin.py", line 37, in post
report_persister.persist(tarinfo.name, file_buffer)
File "/base/data/home/apps/headcasegamesappsales/2.336355808577417080/processors/report_persister.py", line 15, in persist
parsed_data = report_munger.AppStoreSalesDataMunger().munge(content, settings.SETTINGS['base_currency'])
File "/base/data/home/apps/headcasegamesappsales/2.336355808577417080/processors/report_munger.py", line 98, in munge
date = parsedSales[-1]['date']
IndexError: list index out of range
Using the GAE Dashboard Datastore Data Viewer it appears that the reports were not added to RawReport.
Can you advise?
Thank you,
Ben
Not sure what to tell you except to ensure that the tar file is a flat structure and contains only text files as you received them from iTunes Connect. You can debug it by placing some log statements in processors/report_munger.py which the stack trace describes.
To test your settings, you can visit the following URL:
<your application name>.appspot.com/jobs/pull_report
That will download yesterday's iTunes Connect report, parse it and store it in the data store, provided yesterday's report currently exists. If it doesn't you will get a stack trace. :(
If no stack trace appears, it probably worked. Log into your GAE account and examine the data store to see if it downloaded correctly.
Like I said, rather primitive at the moment but eh it works.
You can test a local instance by filling out settings.py and then running it locally using the Google App Engine Launcher.
Pull the latest report:
http://localhost:8080/jobs/pull_report
Or import a tarball with any existing reports from the admin page.
Once there is content inside the data store hit this URL:
http://localhost:8080/jobs/email_report
And watch the GAE Log Console for output regarding email.
It should dump out the attributes of your email (from, to, subject) and tell you that 'You are not currently sending out real email.'
So here is some feedback. I received the first automated email and I can only say it's awesome.
A small problem about the graph : to initialize my data, I uploaded my weekly reports. It worked fine. Now the data are automatically updated daily. Let's say I sell 100 apps a day. On the left part of the graph where data have been imported from weekly reports, the graph is at 700 sales. And now that the sales are daily, the graph goes down to 100. So it looks like the sales have decreased a lot, but they have not. Do you see what I mean ?
You would be better off uploading daily reports for accurate reporting and graph generation.
If you upload weekly reports, the figures and graphs are likely to be wrong.
However it will not send any email to a product which does not have any existing sales data in the data store.
If that is your issue, then I just committed a patch that fixes this issue here: http://github.com/baz/app-sales-machine/commit/...
If the issue is that it is not correctly parsing and storing sales data from your reports then I have not been able to replicate this. If you would like to try debugging it yourself, the data parsing occurs in processors/report_munger.py. You may want to start from handlers/admin.py though.
I've uploaded a tarball of my reports, and hit /jobs/email_report, but get this error:
local variable 'sales_start' referenced before assignment
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 507, in __call__
handler.get(*groups)
File "/base/data/home/apps/jjappsalesmachine/1.336674502001868990/jobs/email_report.py", line 110, in get
'sales_start': self._date_string(sales_start),
UnboundLocalError: local variable 'sales_start' referenced before assignment
Been trying to figure out what's going on here. I pulled down your initial commit of this project and tried that, everything appeared to work (no stack trace), but no email received, in dev or on the server. The above error is with the latest version of the code, and occurs in both my dev machine and in production. I've tinkered and toyed and reverted and started over enough times now, and while the learning is fun, I figure it might be time to see if anybody else has some insight.
Any hints would be greatly appreciated!
James
Log into your GAE dashboard and open the Data Viewer.
Is there any data in the Sale table?
Also you may want to check if your app's SKU is accurate. (Does the value in settings.py match the SKUs shown in Apple's reports?)
Initially, my settings.py was configured with 3 SKUs, but my sales report for yesterday only had entries for 1 SKU, so I modified the settings to only reference the 1 SKU.
I now get this error locally when I clear the data store, run pull_report, then email_report:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 507, in __call__
handler.get(*groups)
File "/Users/james/Code/Tools/app-sales-machine/jobs/email_report.py", line 105, in get
overall_chart_url, concentrated_chart_url = self.units_chart(pid)
File "/Users/james/Code/Tools/app-sales-machine/jobs/email_report.py", line 202, in units_chart
overall_chart.left.max = max(upgrades) if max(upgrades) > max(sales) else max(sales)
UnboundLocalError: local variable 'upgrades' referenced before assignment
Thanks for the help!
Update your working copy and try it again. Let me know how you go.
email_report.py (starting on line 205)
if upgrades:
overall_chart.left.max = max(upgrades) if max(upgrades) > max(sales) else max(sales)
else:
overall_chart.left.max = max(sales)
So I got the emails to send, but I noticed that for 2 of my 3 SKUs, there was no data (in the email or even in the datastore). I think I fixed the problem:
report_persister.py, starting on line 45:
# Store sale and upgrade data in separate tables
for product in sales:
sale_store = models.data.Sale()
_store_data(product, sale_store, date)
sale_store.put()
for product in upgrades:
upgrade_store = models.data.Upgrade()
_store_data(product, upgrade_store, date)
upgrade_store.put()
def _store_data(product, store, date):
store.income_revenue = float(product['incomeRevenue'])
store.income_units = product['incomeUnits']
store.revenue_by_currency = product['revenueByCurrency']
store.units_by_country = product['unitsByCountry']
store.refund_loss = float(product['refundLoss'])
store.refund_units = float(product['refundUnits'])
store.pid = product['pid']
store.report_date = date
I hope this is helpful!