About a year ago I wanted to learn more about good testing habits and specifically Test Driven Development (TDD) because I had heard about it so much. While reading about these topics I came across Behavior Driven Development (BDD). I came to the conclusion that there is confusion around TDD and especially when compared to BDD, however TDD is simple and a highly effective development strategy when understood correctly.
Read Full Post
This article discusses how to quickly and easily setup a Python CI system using GitHub and Jenkins.
This is useful for anyone who does not have a dedicated CI tool (Travis CI, TeamCity etc.) and just want to get something up and running with minimal effort.
When a GitHub Pull Request is "Opened", "Reopened", or a commit is made, a webhook will be sent to the Jenkins job. The Jenkins job will create a virtual environment, install several tools for running tests and linters, then run those tools against the code base. The output of the tools will be gathered and posted as a comment to the Pull Request via the GitHub API.
This was created to offer Python projects a simple and easy CI system without having to install and maintain dedicated CI software.
Requirements: Jenkins with Python 3.6, GitHub
Read Full Post
This article discusses how to easily create a speedometer / gauge image in Python with only the Pillow library.
View source code and images on GitHub: python-gauge
The gauge graphic is separated into two images. The first image is the needle that points to a number on the gauge. The second image is the gauge without the needle. The final gauge image is generated by rotating the needle image then pasting it on the gauge.
The script is simple. The gauge is half a circle therefore the needle needs to rotate between 0 and 180 degrees. The gauge goes from 0 to 100. So if you want the gauge to point to 20, the script just takes 20% of 180 degrees to rotate the needle.
""" Copyright (C) 2018 FireEye, Inc., created by Andrew Shay. All Rights Reserved. """ import PIL from PIL import Image percent = 20 # Percent for gauge output_file_name = 'new_gauge.png' # X and Y coordinates of the center bottom of the needle starting from the top left corner # of the image x = 825 y = 825 loc = (x, y) percent = percent / 100 rotation = 180 * percent # 180 degrees because the gauge is half a circle rotation = 90 - rotation # Factor in the needle graphic pointing to 50 (90 degrees) dial = Image.open('needle.png') dial = dial.rotate(rotation, resample=PIL.Image.BICUBIC, center=loc) # Rotate needle gauge = Image.open('gauge.png') gauge.paste(dial, mask=dial) # Paste needle onto gauge gauge.save(output_file_name)
To modify the gauge image, modify
gauge.png should be the gauge without the needle (hide the needle layer).
needle.png should only be the needle on a transparent background and should point at 50 (hide all layers except needle).
I recently created by my first Lektor Plugin, read-full-post, and wanted to create a getting starting guide for creating a plugin and debugging it in PyCharm.
In this article we will pull the lektor project, create a plugin that modifies the body of every blog post, debug the plugin in PyCharm and look at some of the data in the debugger.
Read Full Post