Skip to content

Instantly share code, notes, and snippets.

@spynappels
spynappels / moonstate.py
Created January 12, 2018 08:19
Training Python App for Distelli Exercise. Requests Module has to be installed using pip3 as a pre-req.
#!/usr/bin/env python
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import requests
# HTML to send to browser
html = """<!DOCTYPE html>
<html>
<head> <title>Moon State</title> </head>
@spynappels
spynappels / moonstate.py
Created January 12, 2018 08:19
Training Python App for Distelli Exercise
#!/usr/bin/env python
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import requests
# HTML to send to browser
html = """<!DOCTYPE html>
<html>
<head> <title>Moon State</title> </head>
@spynappels
spynappels / puppet_enc_python.py
Created January 10, 2018 14:24
This is a very basic External Node Classifier script for Puppet Enterprise (or Puppet OpenSource with some changes) written in Python. It is mostly well commented, but I will add some additional points in a Github comment.
#!/usr/bin/python3
# An example Puppet External Node Classifier written in Python3
# This supposes a PE Installation, as I've used PE Classes for the Master config.
# ***NOTICE*** This is not supported by Puppet Support and will likely cause issues
# if you try to raise Support Tickets on it!!
import sys
import yaml
node_fqdn = sys.argv[1]
@spynappels
spynappels / simple_avmon.py
Created November 30, 2017 08:05
Simple ping based host monitor with option to disable checks by toggling a push button. Pin numbers to suit Pi Hut StatusBoard.
#!/usr/bin/python3
import RPi.GPIO as GPIO
from time import sleep
import os
# Define Pin Numbers
red1 = 4
green1 = 17
button1 = 14
red2 = 27
@spynappels
spynappels / rept_monitor_api.py
Created November 28, 2017 21:49
Equally simple and dirty Python3 monitoring script for Brandmeister Repeaters, using the Brandmeister API rather than querying a Master server directly. It check whether the last_updated timestamp occurred within the last 5 minutes. This could probably be tuned down.
#!/usr/bin/python3
from gpiozero import StatusBoard
import requests
import datetime
import time
# instantiate a StatusBoard instance
status = StatusBoard('gb7ny', 'gb7hi', 'gb7mw','gb7ah','gb7ni')
# define the check function
@spynappels
spynappels / rept_monitor.py
Last active November 28, 2017 21:57
Simple and dirty monitoring script for repeaters connected to a Brandmeister Master server, written in Python3 and using the Pi Hut Status Board (https://thepihut.com/products/status-board-pro)
#!/usr/bin/python3
from gpiozero import StatusBoard
import requests
import time
# instantiate a StatusBoard instance
status = StatusBoard('gb7ny', 'gb7hi', 'gb7mw','gb7ah','gb7ni')
# define the check function
def bmcheck():
@spynappels
spynappels / inky_btc_wallet.py
Created July 3, 2017 07:28
A Python3 script to fetch and display the balance and value of a specified BTC wallet, as well as current USD price and percentage change since a specified date, defaulting to last entry in blockchain.info Market Price chart. Display used is Pimoroni inky pHAT.
#!/usr/bin/env python3
# Stefan Pynappels, 2017
# v0.1
# Due to the slow refresh rate of the Pimoroni inky pHAT, this is best called at
# intervals from cron. I use a 15min interval on my test system.
# Import pre-requisite modules
import json
@spynappels
spynappels / btc_wallet_scroller.py
Created June 29, 2017 19:35
Python script to display balance and value of a Bitcoin wallet on a 128x32 SSD1306 OLED
#!/usr/bin/python3
import time
import json
import requests
import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
from PIL import ImageFont