- Error Handling: Crucially includes robust error handling:
FileNotFoundError
for the Excel file.- Checks for the existence of the required columns ('URL' and 'filename').
requests.exceptions.RequestException
to catch network errors (connection errors, timeouts, etc.) during the download.response.raise_for_status()
to check for HTTP errors (4xx or 5xx status codes) and raise an exception if one occurs. This is very important for handling failed downloads.- General
Exception
catch-all for unexpected errors during file processing.
- Command-Line Arguments: Uses
argparse
to handle command-line arguments for the Excel file path and output directory. This makes the script much more flexible and reusable. - Output Directory Creation:
os.makedirs(output_dir, exist_ok=True)
creates the output directory if it doesn't exist.exist_ok=True
prevents an error if the directory already exists.
So I use Emacs because it is a great tool and I am productive with it. I also code on a development box to avoid x86=>aarch64 compatibility issues with many things on the Mac. Lastly I use NixOS and the Nix package manager on the dev server and Mac respectively.
So I hit a problem. I hadn't noticed it until I was screen sharing and needed to grab some text from the file I was looking at and paste it into chat. I couldn't. The problem with running on a remote box via the terminal is the clipboard exists on the remote server and not locally.
I found a solution using something that has been around forever, X11. The workflow is a bit tedious, but definitely scriptable at some point.
First I needed to update my NixOS server to allow X11 forwarding.
Term | Definition |
---|---|
WebDev | General term for web development, its ecosystem and developers |
Frontend | Programming on the web browser (chrome/safari/firefox...), programs which are executed here |
Backend | Programming Web endpoints on the server |
React/Angular/Vue/Svelte | Frontend Frameworks which are popular and worth learning |
#!/bin/bash | |
LP_MODE=$(pmset -g | grep lowpowermode | awk '{print $2}') | |
if [ "$LP_MODE" == "1" ]; then | |
echo "🔌 Low power mode is on turning it off" | |
sudo pmset -a lowpowermode 0 | |
else | |
echo "🔌 Low power mode is off turning it on" | |
sudo pmset -a lowpowermode 1 |
# Save this file as $HOME/.sshrc | |
# This will take your vimrc in your .sshrc and use it for vim as | |
# well as append any scripts in your .sshrc.d into your path on login | |
echo "Hi $USER!" | |
echo "You are on host $(hostname -f)" | |
# use sshrc .vimrc instead of system | |
export VIMINIT="let \$MYVIMRC='$SSHHOME/.sshrc.d/.vimrc' | source \$MYVIMRC" | |
# Path edits | |
# Add the $SSHHOME to the path |
#!/usr/bin/env PYTHONIOENCODING=UTF-8 /path/to/your/python3/bin/python | |
from datadog import initialize, api | |
# For EU the api_host value is different | |
options = { | |
'api_key': '<DD_API_KEY>', | |
'app_key': '<DD_APP_KEY>', | |
'api_host': 'https://api.datadoghq.com' | |
} |
;; Python Black Formatter | |
;; package.el | |
(package! python-black) | |
;; config.el | |
(use-package! python-black | |
:demand t | |
:after python) | |
(add-hook! 'python-mode-hook #'python-black-on-save-mode) |