Tag Archives: google voice

Is this already running?

I currently have some of my google voice scripts running once every 5 minutes to avoid overlap.  My processing script and sending script will both be fine if multiple instances run, due to the tracking system I’ve developed on the database, but I worry about the script that actually fetches the incoming messages from Google Voice.  Duplicate instances of that script may cause messages to be fetched twice, and I have yet to write a script to check for duplicate incoming messages.  I might as well make an effort to kill some of the duplicates at the source first.

Here is the function:

# check_if_running.py
import os
import commands
import sys

def checkRunning():

	# ps -ef | grep  | grep -v grep | grep -v

	psCommand = "ps -ef | grep "+str(sys.argv[0])+" | grep -v grep | grep -v "+str(os.getpid())
	psOutput = commands.getoutput(psCommand)

	if (len(psOutput) == 0):
		functionReturn = 0
		functionReturn = 1
	return functionReturn

print "Function returns: "+str(checkRunning())


Speaking of duplicates, I have noticed that some outgoing messages are sent multiple times.  My theory is that the phone is actually sending duplicate messages in low signal areas when it cannot be certain if the message has been sent or not, therefore still necessitating the duplicate checking script even if it just just a secondary check on the existing processes.

PS: This is an example of a new-to-me wordpress plugin, WP-Syntax.  Pretty slick?  Yes, I think it is.

My Textbot and the Weather

About a month ago, I stumbled upon pygooglevoice, a python library to interface with google voice.  Of course, the wheels started spinning, and I decided to write a script that will send and receive text messages.  The project provided several examples to use with command line interfaces, which were very helpful in interfacing with google voice, but I took those examples and modified them to interface with a MySQL database.

The script will log onto Google voice, grab all messages, and place them in the incoming table.  The script will then grab all incoming messages, process them and place responses in an outgoing table.  Finally, the script will send all messages in the outgoing table.

….and now for the weather

The first service I have developed for my textbot is the weather.  Using python-weather-api, I am able to provide weather results via text message.  All text messages starting with the word weather followed by a space will be sent to the weather api.  The weather api will then interpret everything after the space as a location code.  Since, I am sending the request through Google weather, a number of different formats may be used.  Typically a city/state or zip code can be used.  Large cities such as Chicago or New York do not require the state, but small ones do.

Here are some examples:

Me to <textbot number>
8/9/10 12:50 AM 21 minutes ago
Me: weather kansas city, mo 12:31 AM
<textbot number>: It is 89 and Clear. Wind: S at 9 mph, Humidity: 63% in Kansas City, MO 12:36 AM
Me: weather 64086 12:37 AM
<textbot number>: It is 85 and Clear. Wind: S at 8 mph, Humidity: 74% in Lee’s Summit, MO 12:41 AM
Me: weather bangkok 12:41 AM
<textbot number>: It is 90 and Cloudy. Wind: SW at 13 mph, Humidity: 49% in bangkok 12:46 AM
Me: weather Moscow, Russia 12:49 AM
<textbot number>: It is 69 and Overcast. Wind: N at 0 mph, Humidity: 90% in moscow, russia 12:50 AM

As you can see, the number for the service is <textbot number>.  That number will not ring any phones or deliver text messages to a human being.  Unless you

I’ve created a basic tutorial page at textbot.ryanveach.com to provide a listing of features and instructions.  At the moment, it is nothing fancy by any means, but it gets the job done.

I’ve got more ideas planned, but they are a surprise 😉

Edit: This service has been taken offline so I can pursue other options with this google voice account.  Because of this, I’ve decided to edit out the number in case somebody else winds up with the same phone number.  I don’t want to spam them!