Iqbal´s DLQ Help

Python scripting (cheatsheet)

Occasionally, you might need to resort to some scripting for bulk changes, due to various reasons.

For instance, a recent encounter for me was bulk deletion of targets in Snyk.

Snyk UI provides a good way to bulk delete projects, but not their targets.

I came across this awesome snyk-cx-tools that did exactly that.

Other use cases are side quests your team might come across, like grabbing specific data from Datadog APIs, etc.

I would like to just keep track of a process that helps keep Python.

So, one of the challenges you'll come across in Python is to have some proper isolation.

I like what Conda does with virtual environments. It is one step ahead of what out-of-the-box venv provides.

How to

conda / venv for clean envs

Create a conda env w/ pip

You can list envs with:

conda env list

Create a new one with pip and Python 3.10, for example:

conda create -n demo python=3.10 pip

Activate env

Switch env simply with:

conda activate demo

Install deps

Congrats, you have an isolated env tailored to your Python script needs:

Install deps with:

pip install -r requirements.txt

Profit

Run script with:

python rm-empty-targets.py
15 May 2025