PI-HOLE anzeigen geblocketer Webseiten auf Sense Hat
Ich hatte mal wieder Lust etwas mit dem Raspberry Pi zu basteln. Also hab ich mir ein Sense Hat besorgt und mein erstes Projekt war die geblockten Seiten von pi-hole auf der LED Matrix anzuzeigen. Grün heißt die Seite ist ok, rot sie ist geblockt.
Raus gekommen ist das hier :
Hier das Skript dazu :
Quelle : https://pythonhosted.org/sense-hat/
Raus gekommen ist das hier :
Hier das Skript dazu :
#!/usr/bin/python
import tailer
from sense_hat import SenseHat
sense = SenseHat()
sense.set_rotation(180)
sense.clear()
sense.low_light = True
logfile = '/var/log/pihole.log'
searchs = '/etc/pihole/gravity.list'
pix_h = 0
pix_v = 0
def sense_pixel(pixcol):
global pix_h
global pix_v
sense.set_pixel(pix_h, pix_v, pixcol)
pix_h +=1
if pix_h > 7:
pix_h = 0
pix_v +=1
if pix_v > 7:
pix_h = 0
pix_v = 0
def main():
for line in tailer.follow(open(logfile)):
if line.find(searchs) == -1:
# NOT BLOCKED
sense_pixel([5,58,0])
else:
# BLOCKED
sense_pixel([255,0,0])
main()Installation Sense Hat
sudo apt-get update
sudo apt-get install sense-hatdanach einen Neustart machen
Installation tailer für python 2.X
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install tailer
Installation tailer für python 3.X
sudo apt-get install python3-setuptools
sudo easy_install3 pip
sudo pip install tailer
Quelle : https://pythonhosted.org/sense-hat/