Exemplo n.º 1
0
def _check():
  tray = request.args.get("tray", "", type=str)
  pattern = request.args.get("pattern", "XXX", type=str)
  matches = find.search(WORDS, pattern, tray)
  ### Matches returns a list of words
  return jsonify(result={ "words": " ".join(matches) })
Exemplo n.º 2
0
        	courses.append(line.rsplit(','))
        elif(flag == 2):
        	email = (line.rsplit(','))

flag = 0
count = 0
sleepTime = 300
#while a course isn't available
while courses:
	count = count + 1
	print 'Attempt: ' + str(count)
	try:
		for e in list(courses):
			print "Checking: " + str(e[0]) + ' ' +  str(e[1]) + ' - CRN: ' + str(e[2])
			#check availability
			flag = find.search(semester, e)
			if( flag == 1):
				print 'Success!'
				print 'Sending email now!'
				courses.remove(e)
				try:
					gmailer.sendemail(email[0], email[0], "", str(e[0]) + " " + str(e[1]) + " IS OPEN", "The CRN is " + str(e[2]) + ". Register now!", email[0], email[1] )
				except:
					raise ValueError()
			else:
				print "It's Closed!"
		print "Sleeping for " + str(sleepTime) + " seconds!"
		#sleep five minutes
		time.sleep(sleepTime)
		print 'Done sleeping! \n'
	except KeyboardInterrupt:	
Exemplo n.º 3
0
# games, from which I'll make some patterns
#
boardwords = [ "wham", "air", "vipers", "tie", "pica", "eel",
               "sensors", "equal", "pram", "spade", "ide",
               "of", "flit", "tin", "keg", "yo", "radio",
               "bough", "jilt", "sub", "toucan", "candor",
               "fie", "zee", "go", "vixen", "giant", "town",
               "be", "ere", "ye", "town" ]

# Now for each word on the board, we look for ways to prefix it,
# ways to suffix it, and ways to cross it, with each hand.  That should
# take a while!
#
# Takes *too* long.  I'll limit number of trays and words to speed it
# up to about 15 seconds, which should be sufficient for profiling

TRAYLIMIT = 5
WORDLIMIT = 10

for tray in trays[:TRAYLIMIT]:
  print("\nTray: {}".format(tray))
  for word in boardwords[:WORDLIMIT]:
    prefixed = find.search(WORDS, "_"+word, tray)
    if len(prefixed) > 0:
      print("_{} => {}".format(word, prefixed))
    suffixed = find.search(WORDS, word+"_", tray)
    if len(suffixed) > 0:
      print("{}_ => {}".format(word, suffixed))