Uploading files to FileMaker Server without a Pro client

Back in the dark ages the FileMaker Server admin console (then Java Web Start) allowed you to remotely upload new fmp12 files to the server. For some reason this feature did not survive the admin console rewrite a decade (?) ago. Rather, the upload feature was integrated into the Pro client. Later, as the Admin REST API was released, the upload feature was still missing. The only two options to upload fmp12 files to the server are thus: ...

March 16, 2023 · David Hamann

Beware of wilcards paths in sudo commands

Say you want to allow a non-root user on Linux to execute a couple of scripts as root or another user with more privileges. A common way of doing this is to make an entry in the sudoers file. If the scripts are written in Python, it could look something like this: johndoe ALL=(ALL) /usr/bin/python3 /opt/utils/*.py Essentially, this means that the user johndoe can execute /usr/bin/python3 /opt/utils/*.py on any machine (ALL) as any user ((ALL)). ...

February 24, 2023 · David Hamann

Reading Aranet4 sensor data from Python

I got myself an Aranet4 device to monitor CO2 levels in my office. The monitor gives pretty accurate readings and has very low energy demands (due to the e-ink display) (here’s the datasheet). While the intended way to read the measurements is to use the mobile app, it’s always good to be able to access the raw data yourself; you get to store as many readings as you like (otherwise limited to past 7 days) and can analyse them in any way you want. ...

February 5, 2023 · David Hamann

SVG and JavaScript: transform viewport coordinates into element coordinates

A couple of months ago I built a JavaScript application that allows adding points and labels to locations on a building floorplan. The whole canvas (not HTML <canvas>) is a SVG document inside an HTML document and points/objects/labels/etc. are added to that canvas as native SVG elements. Users can add/move objects on the floorplan but also zoom and pan the floorplan itself. When performing these actions it is important to transform coordinates from the screen or viewport (like the position of your mouse/fingers) into coordinates that make sense in your SVG element’s coordinate system. ...

January 13, 2023 · David Hamann

Handling and confirming (interrupt) signals in Python

Let’s say you have a long-running Python script that should run uninterrupted or perform a graceful shutdown should a user decide to terminate it ahead of completion. By default, sending an interrupt (usually by pressing <Control-C>) to a running Python program will raise a KeyboardInterrupt exception. One way of (gracefully or not) handling interrupts is to catch this specific exception. For example like this: while True: try: do_your_thing() except KeyboardInterrupt: clean_up() sys.exit(0) This generally works fine. However, you can still trigger another KeyboardInterrupt while the clean_up is running and thus interrupt the clean-up process. Also, as interrupts might be sent accidentally (ever cancelled the wrong script because you thought you were in a different pane?), it would be nice to let the user confirm that the script should indeed be interrupted. ...

September 29, 2022 · David Hamann