Live data from Hacker News

Ask HN: What Python automation scripts do you reuse frequently at work?

news.ycombinator.com

1–10 of 12 posts

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#2
With python, it's more about simplifying the entire process (a.k.a. making it pythonic). In my experience, it tends to be a wrapping mechanism around some binary or api so it's hard to pin point "an exact script everyone runs". Some are clean up scripts that clear out caches manually (until a fix can be pushed), others (like this one https://gitlab.com/sunset-crew/nextrelease) wrap git so you don't need to remember all the things associated with pushing a release and/or tag. Ansible, though it's made in python it's kinda it's own langauge, might be a good place to look if you want scripts that are generic enough for everyone to use. I've written for teams and myself.

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#3
post #2

With python, it's more about simplifying the entire process (a.k.a. making it pythonic). In my experience, it tends to be a wrapping mechanism around some binary or api so it's hard to pin point "an exact script everyone runs". Some are clean up scripts that clear out caches manually (until a fix can be pushed), others (like this one https://gitlab.com/sunset-crew/nextrelease ) wrap git so you don't need to remember…

How do you usually trigger scripts? Do you do it via Ansible or manually via terminal?

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#4
post #2

With python, it's more about simplifying the entire process (a.k.a. making it pythonic). In my experience, it tends to be a wrapping mechanism around some binary or api so it's hard to pin point "an exact script everyone runs". Some are clean up scripts that clear out caches manually (until a fix can be pushed), others (like this one https://gitlab.com/sunset-crew/nextrelease ) wrap git so you don't need to remember…

How do you usually trigger scripts? Do you do it via Ansible or manually via terminal?

Not OP, but I usually trigger Python scripts from cron.

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#5
Python is my default language, so... everything.

The static site generator on which my websites are built is Python. The linters for those websites' content? Also Python. The UI tests for those websites? Playwright and Python. The code to rebuild the production site when new changes are pushed? Python.

I have a script to start my projects. It puts me in the right directory, sets up the environment, launches the IDE, etc.

I have a lot of small one-time scripts to export, transform and import data.

Basically, if it's more than a few lines of bash, I'll use Python. It's a wonderful language.

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#6
post #5

Python is my default language, so... everything. The static site generator on which my websites are built is Python. The linters for those websites' content? Also Python. The UI tests for those websites? Playwright and Python. The code to rebuild the production site when new changes are pushed? Python. I have a script to start my projects. It puts me in the right directory, sets up the environment, launches the IDE,…

Woa! That's quite a bit. What do you use for your static site generator? Or is a custom tool you built for yourself?

Curious, how do you organize or keep track of all your scripts? I assume you have them easily accessible so you can trigger them quickly?

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#7

Earlier quoted context omitted.

How do you usually trigger scripts? Do you do it via Ansible or manually via terminal?

Not OP, but I usually trigger Python scripts from cron.

Is your cron running locally or do you have it set up on a server?

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#8
I'm lazy as f... so, I automate everything that I can. Mostly in Python, others with bash/powershell, even SQL, no matter if I'm at work or my homelab.

Not only to make specific tasks, but also, to remove the burden in some of them, why ssh/rdp to a server to execute something if we can quickly create a script and run it with a click?

At home? domotics, remembering to close the blinds or turn off apliances? no thanks, HA takes care of it with schedules and conditions. Leaving home and remembering to turn on the alarm? no thanks, geolocation + condition, if away for more than 5 minutes, assume that I left and close everything, shut down stuff, turn on the alarm, start the vacuum and get a notification on the mobile.

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#9
post #5

Python is my default language, so... everything. The static site generator on which my websites are built is Python. The linters for those websites' content? Also Python. The UI tests for those websites? Playwright and Python. The code to rebuild the production site when new changes are pushed? Python. I have a script to start my projects. It puts me in the right directory, sets up the environment, launches the IDE,…

Woa! That's quite a bit. What do you use for your static site generator? Or is a custom tool you built for yourself? Curious, how do you organize or keep track of all your scripts? I assume you have them easily accessible so you can trigger them quickly?

It’s my own SSG: https://github.com/nicbou/ursus/. I edit text for a living so the effort was worth it.

As for organisation, they are usually in the ./scripts directory of their respective projects. Generic ones are in my dotfiles: https://github.com/nicbou/dotfiles

Re: Ask HN: What Python automation scripts do you reuse frequently at work?

#10
post #2

With python, it's more about simplifying the entire process (a.k.a. making it pythonic). In my experience, it tends to be a wrapping mechanism around some binary or api so it's hard to pin point "an exact script everyone runs". Some are clean up scripts that clear out caches manually (until a fix can be pushed), others (like this one https://gitlab.com/sunset-crew/nextrelease ) wrap git so you don't need to remember…

How do you usually trigger scripts? Do you do it via Ansible or manually via terminal?

Both. Terminal, and some sort of automation. With Ansible, there's awx and semaphore. I think someone mentioned cronjobs, also systemd-timers. I think kubernetes has a cronjobs feature as well.
Post reply on HN