SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
CI
AMPEL
T H O M A S K O C H - @ T O M Y _ K O C H
P Y C O L O G N E - A U G U S T 2 0 1 5
WTF
CI = CONTINOUS INTEGRATION
• Continous Integration
– umfasst die automatisierte,regelmäßige Erstellung von Builds sowieAusführung von Tests
• Vorgang wird automatisch ausgelöst durch Einchecken in dieVersionsverwaltung (SVN, git etc.)
– Ziel ist Qualitätssicherung bei der Software-Entwicklung
• Integrations-Probleme werden laufend entdeckt und (möglichst zeitnah) behoben
• frühzeitigeWarnungen bei Fehlern (z.B. in Unittests)
• Tools: CI-Server
– z.B. Jenkins (Java) https://jenkins-ci.org
– oder buildbot (Python)
JENKINS CI
Q: https://maestrano.com/apps/1-jenkins
RELATED WORK
• Build-Ampel
– Arduino, RSS-Feed, Build-Ampel (USB-device – 99 EUR)
– http://www.agile-hardware.de/tag/ampel/
• Using a Raspberry PI to control an extreme feedback device
– Verwendet Cleware USB traffic light
• http://www.cleware-shop.de/ (ca. 50 EUR)
– Shell-script auf Basis curl und awk
• Sowie Clewarecontrol
https://blog.codecentric.de/en/2013/07/using-a-raspberry-pi-to-control-an-extreme-feedback-devices/
RELATED WORK
• Raspberry Pi Internet Monitor
– Steuerung Industrie-Signallampe über Raspi
– http://www.instructables.com/id/Raspberry-Pi-Internet-Monitor
ZUTATEN
• Raspberry Pi (Modell B 512MB RAM) http://www.raspberrypi.org
• SD Card 8GB für Raspian https://www.raspbian.org
• Netzteil (5v Micro USB), USB keyboard
• Rot Grün LED IndustrialTower Signalleuchte (24v) - www.ebay.de
• Netzteil (24v)
• Netzwerklabel (oder Wireless 802.11b/g/n USB Adapter)
• 2Widerstände 180 Ohm
• 1 Optokoppler LTV847
• breakout board,Steckkabel
• ca. 100 EUR insgesamt
RASPBERRY PI
GPIO
SOFTWARE
<100 LOC
• CI-checker.py
– Polling des Jenkins-Servers via Jenkins-API
– verwendet Python-Wrapper http://python-jenkins.readthedocs.org
$ pip install python-jenkins
• Light.py
• Steuerung der Ampel via GPIO Pins und Optokoppler-Schaltung
• verwendet GPIO Python Wrapper RPi.GPIO https://pypi.python.org/pypi/RPi.GPIO
• Controller.py
• Integriert checker und light
• Einfacher check-control-sleep Zyklus
SOFTWARE
CI-CHECKER.PY
class CIChecker(object):
def __init__(self, url=JENK_URL, user=JENK_USER, token=JENK_TOKEN, verbose=False):
self.jenkins = jenkins.Jenkins(url, user, token)
self.verbose = verbose
def log(self, msg):
if self.verbose:
print(msg)
def check(self):
"""check all jobs and return True if all is 'green'
False otherwise
"""
jobs = self.jenkins.get_jobs()
self.log("checking %d jobs" % len(jobs))
i = 0
checked = True
for (num, job) in enumerate(jobs):
name = job['name']
color = job['color']
status = (color == 'blue')
self.log("%d: '%s' - job '%s'" % (num, "OK" if status else "--", name))
if not status:
checked = False
break
self.log("checked all jobs - result is '%s'" % ("OK" if checked else "Failed"))
return checked
SOFTWARE
LIGHT.PY
import RPi.GPIO as GPIO
PIN_GREEN = 27
PIN_RED = 22
class Light(object):
def __init__(self, pingreen=PIN_GREEN,pinred=PIN_RED):
self.pingreen = pingreen
self.pinred = pinred
GPIO.setmode(GPIO.BCM)
GPIO.setup([pinred,pingreen], GPIO.OUT)
def __del__(self):
GPIO.cleanup()
def red(self):
GPIO.output(self.pingreen, GPIO.LOW)
GPIO.output(self.pinred, GPIO.HIGH)
def green(self):
GPIO.output(self.pinred, GPIO.LOW)
GPIO.output(self.pingreen, GPIO.HIGH)
def off(self):
GPIO.output(self.pinred, GPIO.LOW)
GPIO.output(self.pingreen, GPIO.LOW)
SOFTWARE
CONTROLLER.PY
from cichecker import CIChecker
from light import Light
import time
class LightController(object):
def __init__(self, delay=60, verbose=False):
self.checker = CIChecker(verbose=verbose)
self.light = Light(verbose=verbose)
self.delay = delay
def wakeup(self):
if self.checker.check():
self.light.green()
else:
self.light.red()
def sleep(self):
time.sleep(self.delay)
def loop(self):
while True:
self.wakeup()
self.sleep()
if __name__ == "__main__":
controller = LightController(verbose=True)
controller.loop()
NEXT
• Vom Prototyp zum „Produkt“
– Aufbau auf Platine
– Gehäuse
– 24/7 Betrieb

Mais conteúdo relacionado

Semelhante a CI-Ampel für Jenkins mit RaspberryPi und Python

OpenShift-Build-Pipelines: Build ► Test ► Run!
OpenShift-Build-Pipelines: Build ► Test ► Run!OpenShift-Build-Pipelines: Build ► Test ► Run!
OpenShift-Build-Pipelines: Build ► Test ► Run!Tobias Schneck
 
Continous Deployment - Schneller entwickeln
Continous Deployment - Schneller entwickelnContinous Deployment - Schneller entwickeln
Continous Deployment - Schneller entwickelnMartin Seibert
 
Python-IDEs - PyDev und Eclipse
Python-IDEs - PyDev und EclipsePython-IDEs - PyDev und Eclipse
Python-IDEs - PyDev und EclipseThomas Koch
 
Agile Breakfast - If it hurts do it more often
Agile Breakfast - If it hurts do it more oftenAgile Breakfast - If it hurts do it more often
Agile Breakfast - If it hurts do it more oftenpingworks
 
OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...
OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...
OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...NETWAYS
 
Agile Bodensee - Introducing Continuous Delivery
Agile Bodensee - Introducing Continuous DeliveryAgile Bodensee - Introducing Continuous Delivery
Agile Bodensee - Introducing Continuous Deliverypingworks
 
OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...
OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...
OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...NETWAYS
 
OSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol Ülükmen
OSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol ÜlükmenOSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol Ülükmen
OSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol ÜlükmenNETWAYS
 
Opensource Tools für das Data Center Management
Opensource Tools für das Data Center ManagementOpensource Tools für das Data Center Management
Opensource Tools für das Data Center Managementinovex GmbH
 
Integration von Security-Checks in die CI-Pipeline
Integration von Security-Checks in die CI-PipelineIntegration von Security-Checks in die CI-Pipeline
Integration von Security-Checks in die CI-PipelineOPEN KNOWLEDGE GmbH
 
OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...
OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...
OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...NETWAYS
 
DACH - Continuous delivery for Puppet Enterprise 08/09/2018
DACH - Continuous delivery for Puppet Enterprise 08/09/2018DACH - Continuous delivery for Puppet Enterprise 08/09/2018
DACH - Continuous delivery for Puppet Enterprise 08/09/2018Puppet
 
GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018
GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018
GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018Christian Mücke
 
Raspberry Pi im Embedded Testing - „tool“ oder „toy“?
Raspberry Pi im Embedded Testing - „tool“ oder „toy“?Raspberry Pi im Embedded Testing - „tool“ oder „toy“?
Raspberry Pi im Embedded Testing - „tool“ oder „toy“?Michel Lawaty
 
Mehr Sicherheit durch Automatisierung
Mehr Sicherheit durch AutomatisierungMehr Sicherheit durch Automatisierung
Mehr Sicherheit durch AutomatisierungOPEN KNOWLEDGE GmbH
 
Foreman: Provisionierungswege (Webinar vom 31. März 2016)
Foreman: Provisionierungswege (Webinar vom 31. März 2016)Foreman: Provisionierungswege (Webinar vom 31. März 2016)
Foreman: Provisionierungswege (Webinar vom 31. März 2016)NETWAYS
 
PyLucene@PyCon DE 2011
PyLucene@PyCon DE 2011PyLucene@PyCon DE 2011
PyLucene@PyCon DE 2011Thomas Koch
 
Test-driven Development mit TYPO3
Test-driven Development mit TYPO3Test-driven Development mit TYPO3
Test-driven Development mit TYPO3Oliver Klee
 
DevOps Prinzipien im Zusammenspiel mit Kubernetes
DevOps Prinzipien im Zusammenspiel mit Kubernetes DevOps Prinzipien im Zusammenspiel mit Kubernetes
DevOps Prinzipien im Zusammenspiel mit Kubernetes QAware GmbH
 
DevOps: Automatisieren, was wir predigen
DevOps: Automatisieren, was wir predigenDevOps: Automatisieren, was wir predigen
DevOps: Automatisieren, was wir predigenFotiosKaramitsos
 

Semelhante a CI-Ampel für Jenkins mit RaspberryPi und Python (20)

OpenShift-Build-Pipelines: Build ► Test ► Run!
OpenShift-Build-Pipelines: Build ► Test ► Run!OpenShift-Build-Pipelines: Build ► Test ► Run!
OpenShift-Build-Pipelines: Build ► Test ► Run!
 
Continous Deployment - Schneller entwickeln
Continous Deployment - Schneller entwickelnContinous Deployment - Schneller entwickeln
Continous Deployment - Schneller entwickeln
 
Python-IDEs - PyDev und Eclipse
Python-IDEs - PyDev und EclipsePython-IDEs - PyDev und Eclipse
Python-IDEs - PyDev und Eclipse
 
Agile Breakfast - If it hurts do it more often
Agile Breakfast - If it hurts do it more oftenAgile Breakfast - If it hurts do it more often
Agile Breakfast - If it hurts do it more often
 
OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...
OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...
OSMC 2013 | Enterprise Platforms Monitoring at s IT Solutions AT by Johannes ...
 
Agile Bodensee - Introducing Continuous Delivery
Agile Bodensee - Introducing Continuous DeliveryAgile Bodensee - Introducing Continuous Delivery
Agile Bodensee - Introducing Continuous Delivery
 
OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...
OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...
OSMC 2015: Nagios3 /Icinga 2 Anbindung an OPSI by Detlef Krummel und Erol Ülü...
 
OSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol Ülükmen
OSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol ÜlükmenOSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol Ülükmen
OSMC 2015 | Nagios 3/Icinga 2-Anbindung an OPSI by Detlef Krummel / Erol Ülükmen
 
Opensource Tools für das Data Center Management
Opensource Tools für das Data Center ManagementOpensource Tools für das Data Center Management
Opensource Tools für das Data Center Management
 
Integration von Security-Checks in die CI-Pipeline
Integration von Security-Checks in die CI-PipelineIntegration von Security-Checks in die CI-Pipeline
Integration von Security-Checks in die CI-Pipeline
 
OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...
OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...
OSMC 2008 | Einsatz von check_multi in einfachen bis hochkomplexen Monitoring...
 
DACH - Continuous delivery for Puppet Enterprise 08/09/2018
DACH - Continuous delivery for Puppet Enterprise 08/09/2018DACH - Continuous delivery for Puppet Enterprise 08/09/2018
DACH - Continuous delivery for Puppet Enterprise 08/09/2018
 
GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018
GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018
GitLab: CI-Pipelines | PHP Usergroup Hamburg 20.03.2018
 
Raspberry Pi im Embedded Testing - „tool“ oder „toy“?
Raspberry Pi im Embedded Testing - „tool“ oder „toy“?Raspberry Pi im Embedded Testing - „tool“ oder „toy“?
Raspberry Pi im Embedded Testing - „tool“ oder „toy“?
 
Mehr Sicherheit durch Automatisierung
Mehr Sicherheit durch AutomatisierungMehr Sicherheit durch Automatisierung
Mehr Sicherheit durch Automatisierung
 
Foreman: Provisionierungswege (Webinar vom 31. März 2016)
Foreman: Provisionierungswege (Webinar vom 31. März 2016)Foreman: Provisionierungswege (Webinar vom 31. März 2016)
Foreman: Provisionierungswege (Webinar vom 31. März 2016)
 
PyLucene@PyCon DE 2011
PyLucene@PyCon DE 2011PyLucene@PyCon DE 2011
PyLucene@PyCon DE 2011
 
Test-driven Development mit TYPO3
Test-driven Development mit TYPO3Test-driven Development mit TYPO3
Test-driven Development mit TYPO3
 
DevOps Prinzipien im Zusammenspiel mit Kubernetes
DevOps Prinzipien im Zusammenspiel mit Kubernetes DevOps Prinzipien im Zusammenspiel mit Kubernetes
DevOps Prinzipien im Zusammenspiel mit Kubernetes
 
DevOps: Automatisieren, was wir predigen
DevOps: Automatisieren, was wir predigenDevOps: Automatisieren, was wir predigen
DevOps: Automatisieren, was wir predigen
 

Mais de Thomas Koch

CI Signal Light in less than 100 Line of Python Code
CI Signal Light in less than 100 Line of Python CodeCI Signal Light in less than 100 Line of Python Code
CI Signal Light in less than 100 Line of Python CodeThomas Koch
 
Facettensuche mit Lucene und Solr
Facettensuche mit Lucene und SolrFacettensuche mit Lucene und Solr
Facettensuche mit Lucene und SolrThomas Koch
 
BSCW - Teamarbeit leicht gemacht
BSCW - Teamarbeit leicht gemachtBSCW - Teamarbeit leicht gemacht
BSCW - Teamarbeit leicht gemachtThomas Koch
 
Pandas und matplotlib im praktischen Einsatz
Pandas und matplotlib im praktischen EinsatzPandas und matplotlib im praktischen Einsatz
Pandas und matplotlib im praktischen EinsatzThomas Koch
 
EnArgus – ein ontologiebasiertes Forschungsinformationssystem
EnArgus – ein ontologiebasiertes ForschungsinformationssystemEnArgus – ein ontologiebasiertes Forschungsinformationssystem
EnArgus – ein ontologiebasiertes ForschungsinformationssystemThomas Koch
 
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...Thomas Koch
 
Volltextsuche mit Lucene und Solr
Volltextsuche mit Lucene und SolrVolltextsuche mit Lucene und Solr
Volltextsuche mit Lucene und SolrThomas Koch
 
Getting Started with Dojo Toolkit
Getting Started with Dojo ToolkitGetting Started with Dojo Toolkit
Getting Started with Dojo ToolkitThomas Koch
 
Teamarbeit 2.0 (PTF 2008)
Teamarbeit 2.0 (PTF 2008) Teamarbeit 2.0 (PTF 2008)
Teamarbeit 2.0 (PTF 2008) Thomas Koch
 
Suche und PyLucene
Suche und PyLuceneSuche und PyLucene
Suche und PyLuceneThomas Koch
 

Mais de Thomas Koch (10)

CI Signal Light in less than 100 Line of Python Code
CI Signal Light in less than 100 Line of Python CodeCI Signal Light in less than 100 Line of Python Code
CI Signal Light in less than 100 Line of Python Code
 
Facettensuche mit Lucene und Solr
Facettensuche mit Lucene und SolrFacettensuche mit Lucene und Solr
Facettensuche mit Lucene und Solr
 
BSCW - Teamarbeit leicht gemacht
BSCW - Teamarbeit leicht gemachtBSCW - Teamarbeit leicht gemacht
BSCW - Teamarbeit leicht gemacht
 
Pandas und matplotlib im praktischen Einsatz
Pandas und matplotlib im praktischen EinsatzPandas und matplotlib im praktischen Einsatz
Pandas und matplotlib im praktischen Einsatz
 
EnArgus – ein ontologiebasiertes Forschungsinformationssystem
EnArgus – ein ontologiebasiertes ForschungsinformationssystemEnArgus – ein ontologiebasiertes Forschungsinformationssystem
EnArgus – ein ontologiebasiertes Forschungsinformationssystem
 
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
Wissenserschließung und –Modellierung: Ontologie vs. Volltextsuche am Beispie...
 
Volltextsuche mit Lucene und Solr
Volltextsuche mit Lucene und SolrVolltextsuche mit Lucene und Solr
Volltextsuche mit Lucene und Solr
 
Getting Started with Dojo Toolkit
Getting Started with Dojo ToolkitGetting Started with Dojo Toolkit
Getting Started with Dojo Toolkit
 
Teamarbeit 2.0 (PTF 2008)
Teamarbeit 2.0 (PTF 2008) Teamarbeit 2.0 (PTF 2008)
Teamarbeit 2.0 (PTF 2008)
 
Suche und PyLucene
Suche und PyLuceneSuche und PyLucene
Suche und PyLucene
 

CI-Ampel für Jenkins mit RaspberryPi und Python

  • 1. CI AMPEL T H O M A S K O C H - @ T O M Y _ K O C H P Y C O L O G N E - A U G U S T 2 0 1 5
  • 2. WTF
  • 3. CI = CONTINOUS INTEGRATION • Continous Integration – umfasst die automatisierte,regelmäßige Erstellung von Builds sowieAusführung von Tests • Vorgang wird automatisch ausgelöst durch Einchecken in dieVersionsverwaltung (SVN, git etc.) – Ziel ist Qualitätssicherung bei der Software-Entwicklung • Integrations-Probleme werden laufend entdeckt und (möglichst zeitnah) behoben • frühzeitigeWarnungen bei Fehlern (z.B. in Unittests) • Tools: CI-Server – z.B. Jenkins (Java) https://jenkins-ci.org – oder buildbot (Python)
  • 5. RELATED WORK • Build-Ampel – Arduino, RSS-Feed, Build-Ampel (USB-device – 99 EUR) – http://www.agile-hardware.de/tag/ampel/ • Using a Raspberry PI to control an extreme feedback device – Verwendet Cleware USB traffic light • http://www.cleware-shop.de/ (ca. 50 EUR) – Shell-script auf Basis curl und awk • Sowie Clewarecontrol https://blog.codecentric.de/en/2013/07/using-a-raspberry-pi-to-control-an-extreme-feedback-devices/
  • 6. RELATED WORK • Raspberry Pi Internet Monitor – Steuerung Industrie-Signallampe über Raspi – http://www.instructables.com/id/Raspberry-Pi-Internet-Monitor
  • 7. ZUTATEN • Raspberry Pi (Modell B 512MB RAM) http://www.raspberrypi.org • SD Card 8GB für Raspian https://www.raspbian.org • Netzteil (5v Micro USB), USB keyboard • Rot Grün LED IndustrialTower Signalleuchte (24v) - www.ebay.de • Netzteil (24v) • Netzwerklabel (oder Wireless 802.11b/g/n USB Adapter) • 2Widerstände 180 Ohm • 1 Optokoppler LTV847 • breakout board,Steckkabel • ca. 100 EUR insgesamt
  • 9. SOFTWARE <100 LOC • CI-checker.py – Polling des Jenkins-Servers via Jenkins-API – verwendet Python-Wrapper http://python-jenkins.readthedocs.org $ pip install python-jenkins • Light.py • Steuerung der Ampel via GPIO Pins und Optokoppler-Schaltung • verwendet GPIO Python Wrapper RPi.GPIO https://pypi.python.org/pypi/RPi.GPIO • Controller.py • Integriert checker und light • Einfacher check-control-sleep Zyklus
  • 10. SOFTWARE CI-CHECKER.PY class CIChecker(object): def __init__(self, url=JENK_URL, user=JENK_USER, token=JENK_TOKEN, verbose=False): self.jenkins = jenkins.Jenkins(url, user, token) self.verbose = verbose def log(self, msg): if self.verbose: print(msg) def check(self): """check all jobs and return True if all is 'green' False otherwise """ jobs = self.jenkins.get_jobs() self.log("checking %d jobs" % len(jobs)) i = 0 checked = True for (num, job) in enumerate(jobs): name = job['name'] color = job['color'] status = (color == 'blue') self.log("%d: '%s' - job '%s'" % (num, "OK" if status else "--", name)) if not status: checked = False break self.log("checked all jobs - result is '%s'" % ("OK" if checked else "Failed")) return checked
  • 11. SOFTWARE LIGHT.PY import RPi.GPIO as GPIO PIN_GREEN = 27 PIN_RED = 22 class Light(object): def __init__(self, pingreen=PIN_GREEN,pinred=PIN_RED): self.pingreen = pingreen self.pinred = pinred GPIO.setmode(GPIO.BCM) GPIO.setup([pinred,pingreen], GPIO.OUT) def __del__(self): GPIO.cleanup() def red(self): GPIO.output(self.pingreen, GPIO.LOW) GPIO.output(self.pinred, GPIO.HIGH) def green(self): GPIO.output(self.pinred, GPIO.LOW) GPIO.output(self.pingreen, GPIO.HIGH) def off(self): GPIO.output(self.pinred, GPIO.LOW) GPIO.output(self.pingreen, GPIO.LOW)
  • 12. SOFTWARE CONTROLLER.PY from cichecker import CIChecker from light import Light import time class LightController(object): def __init__(self, delay=60, verbose=False): self.checker = CIChecker(verbose=verbose) self.light = Light(verbose=verbose) self.delay = delay def wakeup(self): if self.checker.check(): self.light.green() else: self.light.red() def sleep(self): time.sleep(self.delay) def loop(self): while True: self.wakeup() self.sleep() if __name__ == "__main__": controller = LightController(verbose=True) controller.loop()
  • 13. NEXT • Vom Prototyp zum „Produkt“ – Aufbau auf Platine – Gehäuse – 24/7 Betrieb