running a local test instance of SMSMyBus

31 views
Skip to first unread message

Erik Paulson

unread,
Feb 13, 2012, 12:12:57 AM2/13/12
to smsmybus-dev
I wanted to hack on the serverside of SMSMyBus, and have gotten some
of it working.

First, what works:

I'm running it locally on my Mac, using the Google App Engine Launcher
and Python SDK - it's very slick, it looks like it implements most of
the GAE sandbox, complete with datastore/taskqueue/memcache APIs. Just
launch the applauncher, add the checked out directory, and press
'Run'. It doesn't authenticate, so whenever you hit an admin page, you
just give it whatever for an email address, and click on the 'login as
an administrator' checkbox, and congrats, you're an admin.

In order for anything to happen, though, you need to configure it. I
dropped a config.py in my root directory - thus far all I've put in it
is:


EMAIL_SENDER_ADDRESS = 'epau...@unit1127.com'
EMAIL_REPORT_ADDRESS = 'epau...@unit1127.com'
INVALID_STOP_IDS = [0]

Obviously, if I was going to try and hook myself into Twillio or
Google Docs for reporting, add those keys there.

Next, I created a developer API key for myself. On the
AppEngineLauncher, there's a button for 'SDK Console', which launches
safari and sends you to this URL:

http://localhost:8080/_ah/admin/datastore

One of the menu options on the side is for the 'Interactive Console'.
I ran this program:

from google.appengine.api import users
from data_model import DeveloperKeys

devkey = DeveloperKeys()

devkey.developerName = "erik"
devkey.developerKey = "keyvalhere"
devkey.developerEmail = "epau...@unit1127.com"
devkey.requestCounter = 0
devkey.errorCounter = 0

devkey.put()

and that seemed to be good enough to make some API calls work.

A bit later, I discovered that you can hit
/debug/create/newkey
and then update your key in the datastore viewer directly.

I was, for a long time, baffled by what I was supposed to do to load
route and stop data. This is my first time with GAE, and app.yaml led
me to believe that I should go to one of these:
/crawl/
/debug/create/
/debug/create/somestring

but I got nothing but 404 errors in the log.

Finally, I discovered that it's not just app.yaml, but also the
handlers in crawler.py that matter. Going to this:
http://localhost:8082/routelist/configure/

Seems to have filled some of the stops the routes - getarrivals
returns data (though at 11pm on Sunday, there's not much to check)

However, I haven't gotten getroutes to display anything, and none of
my stops are geocoded.

I'll put some of this into the README and send a push along.

-Erik

Greg Tracy

unread,
Feb 14, 2012, 10:56:04 PM2/14/12
to smsmyb...@googlegroups.com
wow! i'm pretty impressed by your ambition here. 

there is a lot of cruft in the github repository. and it dates all the way back to the early days when i had to scrape 100% of the system data from the metro site. it got a little better when they integrated with google maps because they started publishing the GTFS files. 

while having the code is a great fallback in case there was a dramatic change to the transit system and the datastore needed to be rebuilt, it's probably not a great solution for you to construct your own datastore to run within the app engine SDK. 

what i'd like to suggest is that i export the datastore of the production version of the app and provide instructions for importing it into your own app instance (i do this for a second, test instance i have running in app engine now). 

what do you think?

Erik Paulson

unread,
Feb 14, 2012, 11:12:16 PM2/14/12
to smsmyb...@googlegroups.com
I'm interested in whatever's easiest for you. I've got most of it
working now (though, I'm still confused by the StaticAPIs entities and
where the routes seem to be cached - I have an incomplete route list
there, but nothing ever seems to update it...?)

The feature I want to add is on the parking side, which doesn't touch
the metro side anyway. I just wanted to see if I had anything working
and I needed data for that :)

-Erik

> --
> ----
> API Docs : http://www.smsmybus.com/api/
>
>
> You received this message because you are subscribed to the Google
> Groups "smsmybus-dev" group.
> To post to this group, send email to smsmyb...@googlegroups.com
> To unsubscribe from this group, send email to
> smsmybus-dev...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/smsmybus-dev?hl=en?hl=en

Greg Tracy

unread,
Feb 14, 2012, 11:21:27 PM2/14/12
to smsmyb...@googlegroups.com

If the crawler is run to get the route details (and you're right that those are pretty static), it runs in two steps. I always have to remind myself how to do it so I'd have to go in and remind myself. 

But I think the best approach is to export the datastore from the production instance. 

Greg

Greg Tracy

unread,
Nov 1, 2012, 8:48:49 AM11/1/12
to smsmyb...@googlegroups.com

I just ran into this thread again and wanted to close the loop. 

A couple of months ago, I created wiki pages on the Github repo to describe how to populate an instance using the internal crawler. 

Greg


On Tuesday, February 14, 2012 10:21:27 PM UTC-6, Greg Tracy wrote:

If the crawler is run to get the route details (and you're right that those are pretty static), it runs in two steps. I always have to remind myself how to do it so I'd have to go in and remind myself. 

But I think the best approach is to export the datastore from the production instance. 

Greg

> For more options, visit this group at
> http://groups.google.com/group/smsmybus-dev?hl=en?hl=en

--
----
API Docs : http://www.smsmybus.com/api/


You received this message because you are subscribed to the Google
Groups "smsmybus-dev" group.
To post to this group, send email to smsmyb...@googlegroups.com
To unsubscribe from this group, send email to
Reply all
Reply to author
Forward
0 new messages