Rolly Robot

Hello, I build the Rolly Robot. But I have problems to get it start. I followed exactly the instruction. I alwas get this error:

------------start-----------
Full text query for events on Primary Calendar: ‘wake1’
Traceback (most recent call last):
File “alarm.py”, line 161, in <module>
callable_func()
File “alarm.py”, line 154, in callable_func
FullTextQuery(calendar_service)
File “alarm.py”, line 81, in FullTextQuery
feed = calendar_service.CalendarQuery(query)
File “/usr/local/lib/python2.7/dist-packages/gdata/calendar/service.py”, line 126, in CalendarQuery
converter=gdata.calendar.CalendarEventFeedFromString)
File “/usr/local/lib/python2.7/dist-packages/gdata/calendar/service.py”, line 118, in Query
result = self.Get(uri, converter=converter)
File “/usr/local/lib/python2.7/dist-packages/gdata/service.py”, line 1108, in Get
’reason’: server_response.reason, ‘body’: result_body}
gdata.service.RequestError: {‘status’: 403, ‘body’: ‘<HTML>n<HEAD>n<TITLE>Forbidden</TITLE>n</HEAD>n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">n<H1>Forbidden</H1>n<H2>Error 403</H2>n</BODY>n</HTML>n’, ‘reason’: ‘Forbidden’}

Who can help me? Thanks.

Does this have something to do with logging in? I see Forbidden in there . . .

Hm, instead ‘email’ I wrote ‘myemailadress@gmail.com’ and instead ‘password’ I write’mypassword’. With these I can log in my google calendar. May my password have numbers?

Hey modulok,

where you wrote “e-mail” you wrote an valid gmail address. And where you wrote “password” you wrote a valid password, right? LIke the set you use to login to gmail. That’s the critical part . . . you can’t put a random email address and password in there.

Also, just to check: do you need to use a VPN to get to google? Some folks do.

John

Hi John, thanks for answer
no, i dont use VPN. Now I changed the Code :

#These are the imports google said to include
import gdata.calendar.service
import gdata.service
import atom.service
import gdata.calendar
import gdata.calendar
import atom
import getopt
import sys
import string
import time
import logging                                   # used for development. Not needed for normal usage.
logging.basicConfig(filename=&#039;alarm.log&#039;, filemode=&#039;w&#039;)
 
import xe #for the time comparator
from feed.date.rfc3339 import tf_from_timestamp #also for the comparator
from datetime import datetime #for the time on the rpi end
from apscheduler.scheduler import Scheduler #this will let us check the calender on a regular interval
import os, random #to play the mp3 later
 
import multiprocessing
from random import randint
from BrickPi import *   
import subprocess

#this is more stuff google told me to do, but essentially it handles the login credentials
calendar_service = gdata.calendar.service.CalendarService()
calendar_service.email = &#039;email&#039; #your email
calendar_service.password = &#039;password&#039; #your password
calendar_service.source = &#039;Google-Calendar_Python_Sample-1.0&#039;
calendar_service.ProgrammaticLogin()
 
#*****************************************
#Alarm processing starts
#To stop the output when playing the alarm 
devnull = open(&#039;/dev/null&#039;, &#039;w&#039;)

#Plays the alarm
def play_alarm(num):
	while(1):
		subprocess.call([&quot;mpg321&quot;, &quot;alarm_sound.mp3&quot;],stdout=devnull,stderr=devnull)
	#return
	
#Move the bot forward and turns 90 degree if an obstacle is encountered
#Stops when a touch sensor is pressed on Port 1 or 2
def wait_inp(num):
	ot = time.time()
	while True:
		#Move Motors
		power = -150
		BrickPi.MotorEnable[PORT_A]=1
		BrickPi.MotorEnable[PORT_D]=1
		BrickPi.MotorSpeed[PORT_A] = power  
		BrickPi.MotorSpeed[PORT_D] = power  
		result = BrickPiUpdateValues()  
		
		#Get values from both touch sensors and ultrasonic sensor
		b1=BrickPi.Sensor[PORT_1]
		b2=BrickPi.Sensor[PORT_2]
		udist=BrickPi.Sensor[PORT_4]
		#print udist
		
		#Return to main if any touch sensor is pressed
		if b1 or b2:     
			return
		
		#If the US sensor reads less than 20cm and the new distance value is older by 5secs, rotate 90 degrees
		#(New value checked because while rotating, the US sensor would read less that threshold for a few secs)
		if int(udist)&lt;200 and time.time() - ot &gt; 5:
			ot = time.time()
			power1=[-150,-150]
			deg=[110,-110]
			port=[PORT_A,PORT_D]
			motorRotateDegree(power1,deg,port,.1)
		time.sleep(.1)     # sleep for 10 ms
		
#Alarm processing ends
#*****************************************

def FullTextQuery(calendar_service, text_query=&#039;wake1&#039;):
	print &#039;Full text query for events on Primary Calendar: &#039;%s&#039;&#039; % ( text_query,)
	query = gdata.calendar.service.CalendarEventQuery(&#039;default&#039;, &#039;private&#039;, &#039;full&#039;, text_query)
	feed = calendar_service.CalendarQuery(query)
	for i, an_event in enumerate(feed.entry):
		for a_when in an_event.when:
			print &quot;---&quot;
			print an_event.title.text ,&quot;Number:&quot;,i,&quot;Event Time:&quot;,time.strftime(&#039;%d-%m-%Y %H:%M&#039;,time.localtime(tf_from_timestamp(a_when.start_time))),&quot;Current Time:&quot;,time.strftime(&#039;%d-%m-%Y %H:%M&#039;)
 
			if time.strftime(&#039;%d-%m-%Y %H:%M&#039;,time.localtime(tf_from_timestamp(a_when.start_time))) == time.strftime(&#039;%d-%m-%Y %H:%M&#039;):
				print &quot;Comparison: Pass&quot;
				print &quot;---&quot;
				while True:
					BrickPiSetup()
					
					#Set up motors, US sensor and touch sensors
					BrickPi.MotorEnable[PORT_A] = 1 #Enable the Motor A
					BrickPi.MotorEnable[PORT_D] = 1 #Enable the Motor B

					BrickPi.SensorType[PORT_4] = TYPE_SENSOR_ULTRASONIC_CONT
					BrickPi.SensorType[PORT_1] = TYPE_SENSOR_TOUCH   #Set the type of sensor at PORT_1
					BrickPi.SensorType[PORT_2] = TYPE_SENSOR_TOUCH

					BrickPiSetupSensors()   #Send the properties of sensors to BrickPi
					
					#Set timeout
					BrickPi.Timeout=1000
					BrickPiSetTimeout()
					
					#Start two parallel processes
					jobs = []
					
					#Start alarm process
					p1 = multiprocessing.Process(target=play_alarm, args=(0,))
					jobs.append(p1)
					p1.start() 
					
					#Start motor run process
					p3 = multiprocessing.Process(target=wait_inp, args=(1,))
					jobs.append(p3)
					p3.start()

					#The motor run process returns when any button is pressed
					p3.join()
					#Terminate the alarm process when any button press is recieved
					p1.terminate()
					
					#Button 1: Snooze
					#Button 2: Turn Off alarm
					result = BrickPiUpdateValues()
					b1=BrickPi.Sensor[PORT_1]
					b2=BrickPi.Sensor[PORT_2]
					print b1,b2
					
					#Kill the alarm that is already running
					p = subprocess.Popen([&#039;pidof&#039;, &#039;mpg321&#039;], stdout=subprocess.PIPE)
					out, err = p.communicate()
					for line in out.split(&quot; &quot;):
						os.kill(int(line), 9)
					
					#If button 1 is pressed then snooze for 5 minutes
					if b1:
						print &quot;Snooze for 5 mins&quot;
						time.sleep(300)
					
					#If button 2 is pressed then stop the alarm
					if b2:	
						print &quot;exit:&quot;
						return

			else:
				print &quot;Comparison:Fail&quot; #the &quot;wake&quot; event&#039;s start time != the system&#039;s current time
 
def callable_func():
    os.system(&quot;clear&quot;) #this is more for my benefit and is in no way necesarry
    print &quot;------------start-----------&quot;
    FullTextQuery(calendar_service)
    print &quot;-------------end------------&quot;
 
scheduler = Scheduler(standalone=True)
scheduler.add_interval_job(callable_func,seconds=5)
scheduler.start() #runs the program indefinatly on an interval of 5 seconds
#while True:
#	callable_func()
#	time.sleep(60)

Instead ‘email’ I wrote my email from google.And instead ‘password’ I wrote my password to log in to Google. Now I get only the message:

------------start-----------
Full text query for events on Primary Calendar: &#039;wake1&#039;


Ok, now i have the same error in a logfile.
If I use not my password, email, its the same :frowning:
EDIT: With the original code in the example it doesnt work too. Must I change more than my email and password?