def rawRegionInterface(request, row, rowlimit, col, collimit, msg): row = int(row) rowlimit = int(rowlimit) col = int(col) collimit = int(collimit) responseMsg = "Running..." sock = None try: # sock = board.get_connection() board.clear_panel(sock, 1) board.write_region_wrap(sock, 0, row, col, msg, rowlimit, collimit) responseMsg = "Wrote " + msg board.close_connection(sock) except: responseMsg = "Err" finally: board.close_connection(sock) return HttpResponse(content=responseMsg)
def time_stamp(request): secs = time() lastTime = strftime("%a, %d %b %Y %H:%M:%S", localtime(secs)) timeLen = len('Thu, 28 Jun 2001 14:17:15') sock = None try: # sock = board.get_connection() #TODO: calculate when clearing is necessary (e.g. when formatted string length changes from prev) #board.write_to_board(sock, 4, 0, 0, " ") board.write_to_board(sock, 4, 0, 0, lastTime) msg = "Hi Teke" board.write_to_board(sock, 5, 11, 32 - len(msg), msg) msg = "Hi ROBERT!" board.write_to_board(sock, 5, 9, 32 - len(msg), msg) board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="Written")
def updateAnnouncementBoard(foo, bar): logger.warn("updateAnnouncementBoard called") try: # sock = board.get_connection() board.clear_panel(sock, 3) board.write_to_board(sock, 3, 0, 0, " - - - - - - - - - - - - - - - - Announcements - - - - - - - - - - - - - - - - ") curRowNum = 1 announcements = list(Announcement.objects.order_by('-creation_date')) for announcement in announcements: color = chr(29) if announcement.priority == 'M': color = chr(31) elif announcement.priority == 'H': color = chr(30) row = " " + announcement.announcement_text while len(row) < 66: # add some padding spaces row = row + " " row = row + " " + announcement.creation_date.strftime("%a %I:%M%p") while len(row) < 81: row = row + " " board.write_to_board(sock, 3, curRowNum, 0, str(color + row)) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return 0
def test_chars(request): sock = None try: # sock = board.get_connection() board.clear_panel(sock, 0) curRow = 0 curCol = 0 for i in range(152): thisStr = str(i) + ": " + str(chr(i)) + " " board.write_to_board(sock, 0, curRow, curCol, thisStr) curRow = curRow + 1 if curRow == 12: curRow = 0 curCol = curCol + 7 except: return HttpResponse(content="Unexpected error: " + str(sys.exc_info()[0])) finally: board.close_connection(sock) return HttpResponse(content="Test Chars Completed")
def updateInfoBoard(foo, bar): logger.warn("updateInfoBoard called") weatherRows = weather.Weather().getCurrentWeather() sock = None try: #sock = board.get_connection() #board.clear_panel(sock, 4) clearStr = ' '.rjust(32) board.write_to_board(sock, 4, 0, 0, clearStr) #if settings.MINI_TIME_TEMP: board.write_to_board(sock, 6, 6, 0, clearStr) timeStamp = localtime(time()) board.write_to_board(sock, 4, 0, 1, strftime("%a, %d %B %I:%M%p", timeStamp)) #if settings.MINI_TIME_TEMP: board.write_to_board(sock, 6, 6, 0, strftime("%A, %d %B %I:%M%p", timeStamp)) curRowNum = 1 for row in weatherRows: print row board.write_to_board(sock, 4, curRowNum, 3, clearStr) board.write_to_board(sock, 4, curRowNum, 3, str(row)) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return 0
def google_do_search(request, searchTerm="Test"): row = SEARCH_BOX_ROW col = SEARCH_BOX_COL display = SEARCH_BOX_DISPLAY lines = [ "##################################################", "#%s#" % (searchTerm.ljust(48, ' '), ), "##################################################", "Google Search I'm feeling Lucky" #" " ] searchData = perform_search_raw(searchTerm) results = process_search_data(searchData) while len(results) < 10: results.append(" ".ljust(80, ' ')) sock = None try: for line in lines: board.write_split(sock, display, row, col, [line]) row += 1 #lines = perform_search(searchTerm) col = 0 for line in results: board.write_split(sock, display, row, col, [line]) row += 1 except: pass board.close_connection(sock) return HttpResponse(content=searchData, content_type="application/json")
def time_stamp(request): secs = time() lastTime = strftime("%a, %d %b %Y %H:%M:%S", localtime(secs) ) timeLen = len('Thu, 28 Jun 2001 14:17:15') sock = None try: # sock = board.get_connection() #TODO: calculate when clearing is necessary (e.g. when formatted string length changes from prev) #board.write_to_board(sock, 4, 0, 0, " ") board.write_to_board(sock, 4, 0, 0, lastTime) msg = "Hi Teke" board.write_to_board(sock, 5, 11, 32 - len(msg), msg) msg = "Hi ROBERT!" board.write_to_board(sock, 5, 9, 32 - len(msg), msg) board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="Written")
def updateAnnouncementBoard(foo, bar): logger.warn("updateAnnouncementBoard called") try: # sock = board.get_connection() board.clear_panel(sock, 3) board.write_to_board( sock, 3, 0, 0, " - - - - - - - - - - - - - - - - Announcements - - - - - - - - - - - - - - - - " ) curRowNum = 1 announcements = list(Announcement.objects.order_by('-creation_date')) for announcement in announcements: color = chr(29) if announcement.priority == 'M': color = chr(31) elif announcement.priority == 'H': color = chr(30) row = " " + announcement.announcement_text while len(row) < 66: # add some padding spaces row = row + " " row = row + " " + announcement.creation_date.strftime("%a %I:%M%p") while len(row) < 81: row = row + " " board.write_to_board(sock, 3, curRowNum, 0, str(color + row)) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return 0
def write_to_board(row, col, msg, **kwargs): try: sock = board.get_connection() board.write_split(sock, 0, row, col, [ msg ]) board.close_connection(sock) except: board.close_connection(sock) # print "Unexpected error:", sys.exc_info()[0] return False return True
def clear_board(row, **kwargs): try: sock = board.get_connection() board.clear_panel(sock, 0) board.clear_panel(sock, 1) board.close_connection(sock) except: board.close_connection(sock) return False return True
def miniWrite(request, row, col, msg): row = int(row) col = int(col) sock = board.get_connection_port('10.1.3.252', 26) try: board.write_to_board(sock, 6, row, col, msg) #board.write_to_board(sock, 7, row, col, "Test 123") board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="MiniWrite " + msg)
def clear_board(request): try: sock = board.get_connection() board.clear_board(sock) board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="Cleared")
def miniTimeTemp(request): timeStamp = strftime("%A, %d %B %I:%M%p", localtime(time())) sock = None try: board.write_to_board(sock, 6, 6, 0, timeStamp) board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="MiniTimeTemp") pass
def rawInterface(request, row, col, msg): row = int(row) col = int(col) try: sock = board.get_connection() board.write_split(sock, 0, row, col, [ msg ]) #board.write_to_board(sock, 0, row, col, msg) board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="Wrote " + msg)
def board_test(request): sock = None # sock = board.get_connection() #board.write_to_board(sock, 0, 5, 15, "You have no chance to survive") #board.write_to_board(sock, 0, 6, 20, "Make your time") # board.write_to_board(sock, 0, 7, 20, "Boom zig") # board.write_to_board(sock, 0, 8, 30, "Boom zig") # board.write_to_board(sock, 0, 9, 40, "Boom zig") # board.write_to_board(sock, 0, 10, 50, "Boom zig") #board.write_split(sock, 0, 2, 30, [ "That's gotta be rough", ]) #board.write_split(sock, 0, 3, 40, [ chr(30) + "Sorry, technical difficulties", ]) #board.write_split(sock, 1, 0, 10, chr(30) + "Vertical Text!") #chr(30) + board.write_split(sock, 1, 0, 0, [ "Demerit Board: ", ]) demerits = [ ("@DonohuePatrickE", 6,), ("@IdeaFood", 1,), ("@donmball", 0,), (" ", ' ',), ] rowIdx = 1 for d in demerits: board.write_split(sock, 1, rowIdx, 0, [ " ", ]) board.write_split(sock, 1, rowIdx, 2, [ chr(31) + d[0], ]) # colorStr = '' # if d[1] > 1: # colorStr = chr(31) # if d[1] >= 3: # colorStr = chr(30) board.write_split(sock, 1, rowIdx, 25, [ chr(30) + str(d[1]) + " ", ]) rowIdx += 1 board.close_connection(sock) #updateTwitterBoard(1, 2) return HttpResponse(content="Okay")
def twitter_panel(request): try: sock = board.get_connection() # tb = twitter_board.TwitterBoard() # board.clear_panel(sock, 2) board.write_to_board(sock, 2, 0, 0, "*************** Tweets ********************************************************") curRowNum = 1 for row in twitter.Twitter().getNewTweets(11, 79): board.write_to_board(sock, 2, curRowNum, 0, str(row + ' ')) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return HttpResponse(content="Twitter Board Updated")
def board_test(request): sock = board.get_connection() #board.write_to_board(sock, 0, 5, 15, "You have no chance to survive") #board.write_to_board(sock, 0, 6, 20, "Make your time") # board.write_to_board(sock, 0, 7, 20, "Boom zig") # board.write_to_board(sock, 0, 8, 30, "Boom zig") # board.write_to_board(sock, 0, 9, 40, "Boom zig") # board.write_to_board(sock, 0, 10, 50, "Boom zig") #board.write_split(sock, 0, 2, 30, [ "That's gotta be rough", ]) #board.write_split(sock, 0, 3, 40, [ chr(30) + "Sorry, technical difficulties", ]) #board.write_split(sock, 1, 0, 10, chr(30) + "Vertical Text!") #chr(30) + board.write_split(sock, 1, 0, 0, [ "Demerit Board: ", ]) demerits = [ ("@DonohuePatrickE", 6,), ("@IdeaFood", 1,), ("@donmball", 0,), (" ", ' ',), ] rowIdx = 1 for d in demerits: board.write_split(sock, 1, rowIdx, 0, [ " ", ]) board.write_split(sock, 1, rowIdx, 2, [ chr(31) + d[0], ]) # colorStr = '' # if d[1] > 1: # colorStr = chr(31) # if d[1] >= 3: # colorStr = chr(30) board.write_split(sock, 1, rowIdx, 25, [ chr(30) + str(d[1]) + " ", ]) rowIdx += 1 board.close_connection(sock) #updateTwitterBoard(1, 2) return HttpResponse(content="Okay")
def char_test(request): sock = None try: # sock = board.get_connection() board.clear_panel(sock, 0) i = 0 while i < 128: row = i / 12 col = (i % 40) + 3 board.write_to_board(sock, 0, row, col, str(chr(i))) i += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return HttpResponse(content="Info Board Updated")
def info_panel(request): try: sock = board.get_connection() # tb = twitter_board.TwitterBoard() board.clear_panel(sock, 4) board.write_to_board(sock, 4, 0, 1, strftime("%a, %d %B %I:%M%p", localtime(time()))) curRowNum = 1 for row in weather.Weather().getCurrentWeather(): print row board.write_to_board(sock, 4, curRowNum, 3, str(row)) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return HttpResponse(content="Info Board Updated")
def calibrate_displays(request): try: sock = board.get_connection() board.calibrate(sock, 0) board.calibrate(sock, 1) board.calibrate(sock, 2) board.calibrate(sock, 3) board.calibrate(sock, 4) board.calibrate(sock, 5) #board.calibrate(sock, 6) board.close_connection(sock) except: board.close_connection(sock) return HttpResponse(content="Calibrated")
def updateInfoBoard(foo, bar): logger.warn("updateInfoBoard called"); weatherRows = weather.Weather().getCurrentWeather() try: sock = board.get_connection() board.clear_panel(sock, 4) board.write_to_board(sock, 4, 0, 1, strftime("%a, %d %B %I:%M%p", localtime(time()))) curRowNum = 1 for row in weatherRows: print row board.write_to_board(sock, 4, curRowNum, 3, str(row)) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return 0
def updateTwitterBoard(foo, bar): logger.warning("updateTwitterBoard called") twitterRows = twitter.Twitter().getNewTweets(11, 79) if len(twitterRows) > 0: try: sock = board.get_connection() board.clear_panel(sock, 2) board.write_to_board(sock, 2, 0, 0, "*************** Tweets ********************************************************") curRowNum = 1 for row in twitterRows: board.write_to_board(sock, 2, curRowNum, 0, str(row + ' ')) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return 0
def updateTwitterBoard(foo, bar): logger.warning("updateTwitterBoard called") twitterRows = twitter.Twitter().getNewTweets(11, 79) if len(twitterRows) > 0: try: sock = board.get_connection() # board.clear_panel(sock, 2) board.write_to_board(sock, 2, 0, 0, "*************** Tweets ********************************************************") curRowNum = 1 for row in twitterRows: board.write_to_board(sock, 2, curRowNum, 0, str(row + ' ')) curRowNum += 1 except: print "Unexpected error:", sys.exc_info()[0] finally: board.close_connection(sock) return 0
def google_search_box(request): row = SEARCH_BOX_ROW col = SEARCH_BOX_COL display = SEARCH_BOX_DISPLAY lines = [ "##################################################", "# #", "##################################################", "Google Search I'm feeling Lucky", ] sock = None try: for line in lines: board.write_split(sock, display, row, col, [line]) row += 1 except: pass board.close_connection(sock) return HttpResponse(content="Drew search box")
def google_do_search(request, searchTerm="Test"): row = SEARCH_BOX_ROW col = SEARCH_BOX_COL display = SEARCH_BOX_DISPLAY lines = [ "##################################################", "#%s#" % (searchTerm.ljust(48, ' '),), "##################################################", "Google Search I'm feeling Lucky" #" " ] searchData = perform_search_raw(searchTerm) results = process_search_data(searchData) while len(results) < 10: results.append(" ".ljust(80, ' ')) sock = None try: for line in lines: board.write_split(sock, display, row, col, [ line ]) row += 1 #lines = perform_search(searchTerm) col = 0 for line in results: board.write_split(sock, display, row, col, [ line ]) row += 1 except: pass board.close_connection(sock) return HttpResponse(content=searchData, content_type="application/json")
def google_search_box(request): row = SEARCH_BOX_ROW col = SEARCH_BOX_COL display = SEARCH_BOX_DISPLAY lines = [ "##################################################", "# #", "##################################################", "Google Search I'm feeling Lucky", ] sock = None try: for line in lines: board.write_split(sock, display, row, col, [ line ]) row += 1 except: pass board.close_connection(sock) return HttpResponse(content="Drew search box")
board.write_line_split(sock, 0, curRowNum, 0, msg) delayNum = float(s['delay']) colorStr = green if delayNum > 250: colorStr = red elif delayNum > 125: colorStr = amber elif delayNum < 0: colorStr = red s['delay'] = "DOWN" delayStr = colorStr + str(s['delay']) + " " board.write_line_split(sock, 0, curRowNum, 20, delayStr) curRowNum += 1 board.write_line_split(sock, 0, curRowNum, 0, " ") except Exception, e: print "Unexpected error:", sys.exc_info()[0] board.write_line_split(sock, 0, curRowNum, 0, "--errors, could not finish") finally: if sock is not None: board.close_connection(sock) return 0
msg = s['name'] + ": " board.write_line_split(sock, 0, curRowNum, 0, msg ) delayNum = float(s['delay']) colorStr = green if delayNum > 250: colorStr = red elif delayNum > 125: colorStr = amber elif delayNum < 0: colorStr = red s['delay'] = "DOWN" delayStr = colorStr + str(s['delay']) + " " board.write_line_split(sock, 0, curRowNum, 20, delayStr ) curRowNum += 1 board.write_line_split(sock, 0, curRowNum, 0, " " ) except Exception, e: print "Unexpected error:", sys.exc_info()[0] board.write_line_split(sock, 0, curRowNum, 0, "--errors, could not finish" ) finally: if sock is not None: board.close_connection(sock) return 0