예제 #1
0
 def checkBumpRight(self):
   input_right = GPIO.input(21)
   if ((not self.prev_right) and input_right):
     print("ouch on right")
     speaker.say("ouch mind the right side")
   self.prev_right = input_right
   return input_right
예제 #2
0
 def checkBumpLeft(self):
   input_left = GPIO.input(20)
   if ((not self.prev_left) and input_left):
     print("ouch on left")
     speaker.say("oof bumped the left")
   self.prev_left = input_left
   return input_left
예제 #3
0
def say_headlines(user):

	feeds = user.get_news_feeds()

	feed_count = 1
	for feed in feeds:
		print (str(feed_count) + "/ " + feed[0])
		feed_count += 1

	print ("Which feed would you like to hear ?")

	feed_index = -1
	while (feed_index < 0 or feed_index > feed_count - 1):
		try:
			feed_index = int(raw_input()) - 1
		except ValueError:
			print("Wrong index")

	num = 4
	url = "https://newsapi.org/v1/articles?source=" + feeds[feed_index][1] + "&sortBy=top&apiKey=" + news_api_key
	r = requests.get(url)
	j = json.loads(r.text)
	articles = j['articles']
	feed_pres = "Top articles for : " + feeds[feed_index][0]
	s.say(feed_pres)
	article_count = 0

	for article in articles:
		if article_count >= num:
			break
		else:
			article_title = (str(article_count + 1) + "/ " + article['title'])
			s.say(article_title)
			#print ("URL : " + article['url'])
			article_count += 1
예제 #4
0
파일: get_info.py 프로젝트: Accalmie/Stuffs
    """ Read a list """
    pass


if __name__ == '__main__':

    if os.path.isfile('./main_user.u'):
        main_user = u.load_user()

    else:
        main_user = u.register_user()
        u.register_news_feed(main_user)
        u.save_user(main_user)
        print("We registered and saved user " + main_user.name)

    print("Hello, " + main_user.name)
    print(get_date())
    print(get_today_weather())
    print(
        "\nHere is an inspirationnal quote to get you started for the day:\n")
    print(get_inspirational_quote())
    print("")
    get_news_headlines(8, main_user)

    s.say("Hello, " + main_user.name)
    s.say(get_date())
    s.say(get_today_weather())
    s.say("Here is an inspirationnal quote to get you started for the day:")
    s.say(get_inspirational_quote())
    s.say("Have a nice day master :" + main_user.name)
예제 #5
0
def say():
    text = request.args.get('text')
    speaker.say(text)
    return ''
예제 #6
0
	#s.say("Hello, " + main_user.name)
	#s.say(g.get_date())
	#s.say(g.get_today_weather())
	#s.say("Here is an inspirationnal quote to get you started for the day:")
	#s.say(g.get_inspirational_quote())
	#s.say("Have a nice day master :" + main_user.name)


	
	while (True):
		print_instruction()
		command = -1
		while (command < 1 or command > 4):
			try :
				command = int(raw_input())
			except ValueError:
				print("Wrong value")

		if command == 1:
			s.say(g.get_date())
		if command == 2:
			s.say(g.get_today_weather())

		if command == 3:
			say_headlines(main_user)
		
		if command == 4:
			s.say("Goodbye master " + main_user.name)
			break
예제 #7
0
            print "Sorry, those two didn't match"
        
#initialize
print '\nWelcome to Robot Sentry'
user_input = raw_input('Would you like to use default settings? (y/n) ')
while(user_input == 'n'):
    man_init()
    printEmailSetup()
    user_input = raw_input('Does that look right?')
    if not user_input == 'n':
        resetEmail()
        text = open('init.txt', 'rb')
        subj = 'Initiation Complete'
        txt = str(text.read())
        sendAlert(txt, subj)
        say(txt)
        text.close()

e = raw_input("Press enter to calibrate motion tracker...\n(make sure nothing is moving onscreen)")
tracker.calibrate()

print "\nInitiation Complete:\n\ntracker running..."

tickcount = 0
movecount = 0

while tracker.running():
    #Robot Sentry Main Loop
    tickcount += 1    
    tracker.tick()