Thursday, August 10, 2017

Python Windows Toast Notifications

Started working with Microsoft Life Cycle Services recently deploying some cloud hosted environments. Wanted a way to get notified when an environment was finished deploying. I am sure there are better ways, but I wanted something quick and easy.

Double bonus is that you can use this for other Python projects where you want a Windows Toaster notification. Windows Toaster notifications are those little pop ups that appear in the bottom right corner of your screen.

I fired up Fiddler hoping to find that LCS would give me some sweet JSON action. At first I was a little bummed because the return application type showed javascript instead of JSON

When I clicked JSON view the response looked like JSON, but when I tried to load it into Python as JSON I kept receiving the "is not JSON serializable error".

After some searching I stumbled on some stack overflow articles mentioning this was JSONP not normal JSON. I finally landed at this article that gave me a really simple solution.  Here is my final script to generate the Toast Messages for the LCS deployment status.

You can see where I convert the JSONP to JSON by just removing the first and last character (Line 16) of the response. It is really that simple, just remove the ( and the ) and we now have valid JSON we can feed in.

We loop every 5 minutes checking status and pop up a toast notification giving the status. Here is a screen shot showing the result (I stopped all my environments for some maintenance thus all are Stopped status).

One thing to keep in mind is you are limited on height of the toast message. So your message will be cut off if your message cannot fit in the toast notification window size.

Friday, August 4, 2017

Raspberry Pi Sound Board

I have wanted to create a sound board for some time. I finally got around to getting it done. This project took way longer than I wanted mostly because I did not make time to work on it. I created a really simple wood structure to mount the arcade buttons to.

I wanted a solderless solution so I ordered some female spade connectors so I could just crimp the wires instead of soldering. Turned out pretty good.


  • Raspberry Pi 3
  • Female Spade Connectors 2.8mm width. Make sure you get the size that matches your arcade buttons.
  • 10 x 30mm arcade buttons
  • Jumper Wires
  • Bore Bit to cut your holes for arcade buttons

My first mistake was buying a bore bit that was too small. My buttons were 30mm and my bore bit was 28mm. Not sure where I got 28mm from but the holes were too small. I was able to use a Dremel to make the holes bigger but it sure wasn't as pretty as clean 30mm holes. 

I used common ground lines for the buttons so I had 4 buttons one one and 5 buttons on the other. I used a wire nut to ground them and attached them to two separate ground ports on the Raspberry Pi. 


I spent way too long trying to figure out the Python code to detect a button push. Finally found the right combo. Here is my code.

So the jist is to wait for a button to be pushed then call the Command line version of VLC to play the MP3 specified. Not that elegant but works great. You will see here that this version of the sound board is my Dr. Phil quotes soundboard. Good times. You can SCP to copy the files you need to the Pi or use a USB stick as pictured in my pics below. I didn't really plan my project well so I had to run the jumper cables out to the side of box so I could plug stuff into the pi. It works fine and gives the project that hacker feel.

This of course can be used for anything really. You can launch python scripts to do whatever you want.