Beispiel #1
0
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 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
Beispiel #3
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")
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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
Beispiel #7
0
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
Beispiel #8
0
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")
Beispiel #9
0
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")
Beispiel #10
0
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")
Beispiel #11
0
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")
Beispiel #12
0
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")
Beispiel #13
0
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")
Beispiel #14
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
Beispiel #15
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
Beispiel #16
0
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
Beispiel #17
0
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
Beispiel #18
0
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")
Beispiel #19
0
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")
Beispiel #20
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")
Beispiel #21
0
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 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