Skip to content

Instantly share code, notes, and snippets.

@choffee
Created August 9, 2013 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choffee/6192320 to your computer and use it in GitHub Desktop.
Save choffee/6192320 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Script to upload the human calendar to an lcdstatus screen
# Requires the python lcdstatus screen library at:
# https://github.com/dangardner/pylcdsysinfo
# Written by John Cooper 2013
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import requests
from BeautifulSoup import BeautifulSoup
#from PIL import Image
from StringIO import StringIO
import pylcdsysinfo
from pylcdsysinfo import LCDSysInfo, TextAlignment, TextColours, large_image_indexes
r = requests.get("http://api.humancalendar.com/iframe.php?t=2x2&s=250")
page = BeautifulSoup( r.text)
img = page.findAll('img')
print img[0]['src']
r = requests.get(img[0]['src'])
calendar_image = pylcdsysinfo.Image.open(StringIO(r.content))
calendar_image = pylcdsysinfo.simpleimage_resize(calendar_image)
rawfile = pylcdsysinfo.image_to_raw(calendar_image)
d = LCDSysInfo()
#d.write_rawimage_to_flash(1, rawfile)
slot=1
d.write_rawimage_to_flash(large_image_indexes[slot], rawfile)
d.display_icon(0, large_image_indexes[slot])
@kieronmiddleton
Copy link

I receive the following error when trying to run this:
line 35 in
calendar_image = pylcdsysinfo.image.open(StringIO(r.content))
AttributeError: 'NoneType' object has no attribute 'open'

I'm not a huge python expert so am struggling to resolve this. It looks like a great calendar though. Would love to try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment