Automate with Python using the Python task automation scripts explained in this post. Download and install the “Top 10 Automatable Tasks” build, which contains a version of Python and all the tools listed in this post.
As a developer, there are always more tasks to complete than you have time for in a day. While it’s important to prioritize time-sensitive, impactful or blocking issues, they’re usually not the kind of things that can be knocked off your list quickly. If you try breaking down bigger tasks into smaller subtasks, you just end up increasing the list of things that still need to get done. But what if you could knock off some of these subtasks in no time at all? That’s where Python comes in.
Python is an incredibly powerful and flexible open-source language that is used in all layers of the application stack across the technology industry: from data manipulation processing real-time data feeds, to serverless applications processing commands from your personal voice assistant to being a rock-solid, general-purpose language for traditional applications.
Because of this flexibility and breadth of capabilities – extended by its extensive library of plugins – Python is an amazing tool. It can be used to build all the little scripts and utilities that simplify and automate with Python, your life as a software developer or system administrator.
- Learn Python: Programiz is a free, interactive iOS app that makes it easy to learn to program and write code in Python 3. Move progressively through bit-size lessons step-by-step, experiment with Python code in each lesson, take quizzes and more to learn fundamental concepts of Python programming from beginning to advanced.
- Create a Python project with GUI on Mac. Stay tuned for the Part 2 of this tutorial where I will make my own Python application with GUI. Thanks for reading!
Automate with Python: Getting Started
This post goes through a series of scripts that can be run on multiple platforms (Windows, Mac and Linux) to accomplish common tasks. To get started, you can:
Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you are invited to install the most recent version of Python 3 from the Python website ( ). A current “universal binary” build of Python, which runs natively on the Mac’s new Intel and legacy PPC CPU’s, is available there. Installing Python 3 on Mac OS X. The version of Python that ships with OS X is great for learning, but it’s not good for development. The version shipped with OS X may be out of date from the official current Python release, which is considered the stable production version.
- Download and install the “Top 10 Automatable Tasks” build, which contains a version of Python and all the tools listed in this post so you can test them out for yourself:
- Install the State Tool on Windows using Powershell:
IEX(New-Object Net.WebClient).downloadString('https://platform.activestate.com/dl/cli/install.ps1')
- Or install the State Tool on Linux / Mac:
sh <(curl -q https://platform.activestate.com/dl/cli/install.sh)
- Install the State Tool on Windows using Powershell:
- Run the following command to download the build and automatically install it into a virtual environment:
state activate Pizza-Team/Top-10-automatable-tasks
You can review all the relevant source code in my Python Scripts GitHub repo.
All set? Let’s go.
Top 10 Python Task Automation Scripts
#1 checkjson
Python Mac App Store
This script will read a file and either pass the file as being a valid JSON file, or die a horrible death. But for all practical reasons, it tells me if the error is in the file or the program that I am trying to load the file into.
![Download Download](/uploads/1/3/4/2/134279756/181871890.png)
To run it:
That’s all you need to validate JSON, but it can easily be modified to validate YAML, as well.
#2 checkyaml
Kubernetes is difficult enough without having YAML fail to parse. This utility is a way to validate that the YAML is valid. Use it before ripping apart the program you are trying to load it into.
To run it:
Now that we’ve validated that we’re dealing with JSON and YAML, how can we convert between them?
#3 json2yaml
If you work with config files or need to expose YAML via an API, you’ll probably find yourself needing to convert a file from JSON to YAML. The output can either be sent to stdout or to a specified file.
To run it:
But what if you need to go in the other direction, from YAML to JSON?
#4 yaml2json
This script converts a file from YAML to JSON. The output can either be sent to stdout or to a specified file.
To run it:
Manipulating JSON and YAML are great options for dealing with text input, but what if your input is a graphic file instead?
#5 convert2jpg
When dealing with older systems that require you to upload images, such as defect tracking applications or expense management solutions, it seems like they all accept JPEG images but rarely accept newer formats, such as PNG or HEIC.
To resolve this issue, here’s a quick utility that will take the input file and convert it to a .jpg version using the same base name.
To run it:
Even more common than dealing with graphic files is copying and pasting info to/from the clipboard. But is there a way to do it without having to open an editor every time?
#6 copy2clip
Copying the contents of a text file to the clipboard is an all-too-frequent task, whether it’s a log file someone wants to see, a configuration file you need to share, or even an ssh key. Getting to the file is easy enough on the command line, but then having to open it in an editor just to copy-and-paste takes time you don’t need to waste.
The following copy2clip script works on both Windows and Mac, and uses native functionality that is wrapped in a little bit of Python code to load the files into the clipboard.
To run it:
So now that we know how to copy and paste file content quicker and easier, let’s apply it to file names.
#7 cwd
Getting the present working directory is easy on Linux and Mac because it’s built into the shell as the pwd command. But pwd is a POSIX environmental variable, which means it won’t work on Windows. As a result, we can use the command called cwd so it will not interfere if you choose to use it on either Mac or Linux, but is primarily aimed at Windows. https://hmpotent439.weebly.com/speech-app-missing-on-mac.html.
Running cwd on its own will display the current working directory. If you pass the -c flag it automatically copies the current working directory to the clipboard on Mac or Windows, which saves a lot of retyping and mouse movements.
In addition, you can pass a filename as an argument and have its full path copied to the clipboard, which is something I need to do often when running test cases.
To run it:
Let’s change tack and talk math.
#8 quickmath
This script is used to add (or multiply or divide or subtract) multiple numbers in a single command line. The task of calculating values is needed more often than you think, and who wants to open Excel just for that? This automation comes in handy.
To run it:
Now that we can automate math, let’s apply it to currency conversion.
#9 currency
You’ve probably looked up conversion rates using your browser, but here’s how to automate the task of finding the current exchange rate between any two currencies.
Py2applet
To run it:
Empire total war darthmod mac download. Now we know that $1 CDN is currently only worth $0.71 USD. Great for Americans; not so great for Canadians, but what about the other NATO countries?
#10 nato-alphabet
Okay, this one is just for fun. This script spells out a word using the NATO phonetic alphabet. How to download movie box on mac.
To run it:
Automate with Python: Scripts for Every Developer’s Toolbox
Py2app Tkinter
My scripts just scratch the surface of what’s automatable with Python. If you have a function or routine task you want to automate, there are multiple resources online to aid in that pursuit, including:
Python Coding App Mac
- Python Package Index which is the vast library of third party packages used by pip
- Automate the Boring Stuff, which is an entire book on the subject of automation with Python.
Next Steps: Download winrar 5.40 for mac.
- Review the scripts in my GitHub repository
- Sign up for a free ActiveState Platform account so you can download and install the Top 10 Automatable Tasks runtime in order to build your very own predictive models.