My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Speak the weather."""

__author__ = 'T.V. Raman <raman@google.com>'
__copyright__ = 'Copyright (c) 2009, Google Inc.'
__license__ = 'Apache License, Version 2.0'

import android
import weather


def say_weather(droid):
"""Speak the weather at the current location."""
print 'Finding ZIP code.'
location = droid.getLastKnownLocation().result
if location['gps'] is not None:
location = location['gps']
else:
location = location['network']
addresses = droid.geocode(location['latitude'], location['longitude'])
zip = addresses.result[0]['postal_code']
if zip is None:
msg = 'Failed to find location.'
else:
print 'Fetching weather report.'
result = weather.fetch_weather(zip)
# Format the result for speech.
msg = '%(temperature)s degrees and %(conditions)s, in %(city)s.' % result
droid.ttsSpeak(msg)


if __name__ == '__main__':
droid = android.Android()
say_weather(droid)

Change log

3afde900bc52 by Alexey Reznichenko <alexey.reznichenko> on Jul 8, 2010   Diff
Added MainThreadInitializationFactory,
fixed a bug in notify_weather.py and
say_weather.py.
Go to: 
Project members, sign in to write a code review

Older revisions

9407d0bd872f by Alexey Reznichenko <alexey.reznichenko> on Jul 8, 2010   Diff
Fixed sample scripts to use new API
calls (+ a couple of minor fixes).
7236055c4628 by Damon Kohler <damonkohler> on Apr 5, 2010   Diff
Fix broken buildJsonList method and
add test for it.
Undo workarounds added to Python
scripts say_weather and
notify_weather.
e640f8fd52db by Damon Kohler <damonkohler> on Mar 14, 2010   Diff
Rename all scripts to use underscores
between words.
Fix notify and say weather scripts to
get result key from geocode result.
All revisions of this file

File info

Size: 928 bytes, 33 lines
Powered by Google Project Hosting