52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import httplib
|
|
#import requests
|
|
import urllib
|
|
import json
|
|
import sys
|
|
|
|
# VBR (23x7)
|
|
#board_id = '700df57c-8b0a-4166-8758-b9de6e900cb8'
|
|
# VB (22x6)
|
|
#board_id = 'demo-a3c6ed9d-0499-4368-a3e9-b132cfc94305'
|
|
# Testaboard
|
|
board_id = 'demo-6a439bfd-fe37-4d82-af76-9cbf4fbd6367'
|
|
board_name = 'Testaboard'
|
|
firmware_version = 'Post update, pre AP'
|
|
|
|
def get_board_content():
|
|
url1 = 'https://app.vestaboard.com/api/v1/board/'
|
|
url2 = '/describe'
|
|
full_url = url1 + board_id + url2
|
|
page = urllib.urlopen(full_url)
|
|
#conn = httplib.HTTPSConnection('app.vestaboard.com')
|
|
try:
|
|
#conn.request('GET', '/api/v1/board/%s/describe' % board_id)
|
|
contents = page.read()
|
|
#conn = requests.get(full_url, verify=True)
|
|
#contents = conn.text
|
|
except httplib.ssl.SSLError as e:
|
|
print 'Error: ' + str(e)
|
|
sys.exit(-1)
|
|
#response = conn.getresponse()
|
|
#print response.status, response.reason
|
|
print page.getcode()
|
|
#conn.close()
|
|
page.close()
|
|
#return response
|
|
return contents
|
|
|
|
|
|
print('* * * * * * * * * *')
|
|
print ('Board:'), board_name, ('/ Firmware:'), firmware_version
|
|
print('* * * * * * * * * *')
|
|
r = get_board_content()
|
|
data = json.loads(r)
|
|
print data
|
|
ulines = data['message']['lines']
|
|
lines = [l.encode('ascii', 'ignore') for l in ulines]
|
|
print lines
|
|
|