UnicodeError when running Python script via macOS LaunchAgent

If you are getting UnicodeErrors when reading/manipulating files using a Python script launched by a LaunchAgent or crontab, the problem might lie in the “current locale encoding”. Sample script Let’s assume you have the following code in a script set up to be launched by a LaunchAgent (also see my article on LaunchAgents): with open(some_path_to_file) as f: f.read() Let’s also assume that some_path_to_file points to a txt file containing some emojis (hey, why not? 😎) or some other unicode characters. ...

December 7, 2018 · David Hamann

Watch a log file and send new lines to an HTTP endpoint – with log2http

Recently, I wanted to watch a couple of log files for new entries and have them sent to an http endpoint for collection and later analysis. I did a quick research on what tools exist, but eventually decided to create a small Python app myself which doesn’t require a complicated setup. I thought of something along the lines of: pip install <the module> Define which log files to watch and where to send the contents to Run it from the terminal. And so I built it. ...

October 20, 2018 · David Hamann

Debugging stories: What's that 404 error?

Here is a little story about resolving an issue with a web site that turned out not to be an issue with a web site :-) A client approached me and asked, if I could look into an issue they were having with their web app. Multiple users, mainly from mobile devices, were reporting 404 Not Found errors when accessing the site’s domain. Server error for some devices? 🤨 It sounded like a strange thing that the server would give a 404 for some mobile devices. I tried to reproduce the issue, but was not able to do so, neither on one of my devices (mobile or not) nor on devices from an external device farm. ...

October 7, 2018 · David Hamann

Fix error 853 when encrypting FileMaker databases

Have you ever gotten the following error after trying to encrypt your FileMaker databases? Due to an error encountered, File encryption/decryption was skipped. File:my_file.fmp12 [853] Error 853 refers to One or more containers failed to transfer in the error code listing and herein usually lies the problem. When you encrypt your database, make sure to place the existing external container data into the same folder as the database you want to encrypt. It is not enough to copy the RC_Data_FMS directory straight from the server. You need to have the external container data in a folder called Files. ...

August 19, 2018 · David Hamann

Running a script in the Windows Local System account

Today I needed to debug a scheduled script and test its behavior when run in the Windows Local System account instead of my regular domain user’s (this was on Windows Server 2016 but should work the same in (much) older versions). I did a bit of research and found a tool from the PsTools suite on sysinternals called PsExec. It is mainly for executing programs on remote machines and gives you the ability to launch interactive command prompts. Good stuff, even though we only need a tiny portion of its capabilities. ...

August 17, 2018 · David Hamann