Talk:Projects

From MID DAQ
Jump to: navigation, search

Contents

Connect to Twitter

Hi,

We have been trying to install the programme "tweepy.py" into our Python 2.6 in order to send tweets.

As of now, we are able to access the "readtweet.py" to obtain twitter feed from the NEAsg. However, when we attempt to type out our own tweets, we faced the problem:

Traceback (most recent call last):
  File "C:/Python26/st", line 1, in <module>
    import tweepy
ImportError: No module named tweepy

We obtained the programme from http://pypi.python.org/pypi/tweepy/1.8 and we downloaded "tweepy-1.8.tar.gz (md5)" and "tweepy-1.8-py2.6.egg (md5)". Following which, we extracted the files from the former download, which gave us an error of "no setuptools". We searched online for help and downloaded the setuptool from "http://pypi.python.org/pypi/setuptools#files". But after all our efforts, we still returned to square one where there is still "No module named tweepy"

Please help us! Thank you!


if you can run readtweet.py from android twitter client examples, then it shows that the tweepy module has been correctly installed. To write a tweet, run the second example send_tweet.py. However before running it, you must change 'Consumer key','Consumer secret' ... to that of your twitter account

# modify the following before running
CONSUMER_KEY = 'Consumer key'
CONSUMER_SECRET = 'Consumer secret'
ACCESS_KEY = 'Access token'
ACCESS_SECRET = 'Access token secret'

Read the instructions on the same page to obtain the various keys and secrets from your twitter account.

--Admin 20:00, 1 February 2012 (EST)

Health monitoring on the Android Smartphones Input of GPS info in URL via SMS

Hi,

Q: we are able to complete the steps 1 to 7 of the given Health monitoring on the Android Smartphones. However, we are unable to do step 5, which is to use the GPS info to help generate a URL of the location from google map. Is there any other way to show the user the exact location?

A: Construct URL to display map using longitude, latitude

Q: We also would like to know if there is a way to store the data in the phone/CPU. For instance, can we transmit the temperature and location of the victim to another phone/CPU and store that particular data?

A: Write the information to the cloud at sensor cloud. Advantage is the information is available to everyone with internet access rather than just on the recipient phone. At sensor-cloud.com, the graph can only be seen on a PC browser. Visit m.sensor-cloud.com for a phone browser (on iphone, android ..) Also you may want to set the data to public for demonstration purposes (so viewers do not need to log in to facebook and are your friends). Example code for python to write to the sensor-cloud.com can be found here Py4A to sensor-cloud.com

Retrieve data the cloud

Thank you for providing the Sensor Cloud example. I was able to create and save data onto the cloud database. I have another question, about the cloud database.

Q. It is possible to save a file like a excel sheet with people's contact (next of kin) onto cloud or other places, so that I can retrieve the contact's number in order to message them?

A. No you can't. To read/write configuration data, please look at the preferences example or the Google Spreadsheet example

Reverse Geocoding Lat and Lng

I am able to provide a URL link with the Lat and Lng produced from the phone.

Q. Is it possible to use Lat and Lng obtain from the android GPS, to get a estimated location, of nearest street/landmark without clicking on the URL click? I read that I need to register to get GoogleMap API key in order to run a program to do reverse geocoding.

A. geocode is available in the ApiReference. You do not need the GoogleMap API key but network access must be available for this to work

address = droid.geocode(lat, lng).result

The address format is list of dictionaries. Generally only one entry in the list is returned for address lookups, though the geocoder may return several results when address queries are ambiguous:

[{u'thoroughfare': u'Some Street', u'locality': u'Some Town', u'sub_admin_area': u'Some Borough',
u'admin_area': u'Some City', u'feature_name': u'House Numbers', u'country_code': u'GB',
u'country_name': u'United Kingdom', u'postal_code': u'ST1 1'}]

The additional information can be deduced from LocationFacade.java

Q: May I know what does the function, geocode(), returns? Example it is dictornary or list? Because I tried to convert it to strings for both dictornary and list, it created a error, either there is no items or no dictornary.

Hint: d is a dictionary

d = {u'thoroughfare': u'Ang Mo Kio St 31', u'country_code': u'Singapore'}
print d['country_code']

run the snippet and you get

Singapore

l is a list of dictionaries with one dictonary

l = [{u'thoroughfare': u'Ang Mo Kio St 31', u'country_code': u'Singapore'}]
print l[0]['thoroughfare']

result

Ang Mo Kio St 31

l is a list of dictionaries with 2 dictonaries

l = [{u'thoroughfare': u'Ang Mo Kio St 31', u'country_code': u'Singapore'},{u'thoroughfare': u'Ang Mo Kio St 32', u'country_code': u'Singapore'}]
for a in l:
    print a['thoroughfare']

result

Ang Mo Kio St 31
Ang Mo Kio St 32

Google Spreadsheet

Hi, I have tried the google spreadsheet example given from the smartphonedaq on the PC. I was able to link it with a google spreadsheet. I tried using the example spreadsheet on the phone but a error, "ImportError: No module named spreadsheetExample", I tried installing the gdata-2.0.16.zip onto the phone directly, but it gives me a error, "Errorjava.io.FileNotFoundException:/data/data/com.googlecode.pythonforandroid/files/python/egg-info/gdata-2.0.16.zip/files.txt(No such file or directory).

A: On the PC you may have to install the gdata library but on the smartphone Py4A it is already installed. You are missing the spreadsheetExample.py which you need to copy from your PC. If you had scanned the example directly to your smartphone, the downloader program would have copied the spreadsheetExample.py to your phone.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox