about summary refs log tree commit diff
path: root/src/cli
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-10-05 10:34:31 -0700
committerFranck Cuny <franck@fcuny.net>2024-10-05 10:34:31 -0700
commitc4b455e7a6048151806dcc9f45844c1b43de06e8 (patch)
tree9b83174f54207fc9d09073f46f5c93e3ae0e31cb /src/cli
parentenable tmux (diff)
downloadworld-c4b455e7a6048151806dcc9f45844c1b43de06e8.tar.gz
more scripts to delete
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/gha_billing.py45
-rwxr-xr-xsrc/cli/ipconverter.py25
2 files changed, 0 insertions, 70 deletions
diff --git a/src/cli/gha_billing.py b/src/cli/gha_billing.py
deleted file mode 100644
index a501890..0000000
--- a/src/cli/gha_billing.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""
-Print information about how many free minutes of GitHub actions are left for this cycle.
-
-The API for this is documented [here](https://docs.github.com/en/rest/billing/billing?apiVersion=2022-11-28#get-github-actions-billing-for-an-organization).
-
-For this you need a [token](https://github.com/settings/personal-access-tokens) with the following permissions:
-- [plan](https://docs.github.com/en/rest/authentication/permissions-required-for-fine-grained-personal-access-tokens?apiVersion=2022-11-28#user-permissions-for-plan)
-"""
-
-import sys
-
-import click
-import requests
-
-API_URL = "https://api.github.com"
-
-
-@click.command()
-@click.option("-t", "--token", required=True, help="GitHub API token")
-@click.option("-u", "--user", default="fcuny", help="GitHub username")
-def cli(token, user):
-    # https://docs.github.com/en/rest/billing/billing?apiVersion=2022-11-28#get-github-actions-billing-for-an-organization
-    url = f"{API_URL}/users/{user}/settings/billing/actions"
-    headers = {"Authorization": f"token {token}", "Accept": "application/vnd.github.v3+json"}
-    try:
-        response = requests.get(url, headers=headers, timeout=30)
-        response.raise_for_status()
-    except requests.exceptions.RequestException as err:
-        click.echo(f"Error making HTTP request: {err}", err=True)
-        sys.exit(1)
-
-    try:
-        billing_info = response.json()
-    except ValueError as err:
-        click.echo(f"Error parsing the JSON response: {err}", err=True)
-        sys.exit(1)
-
-    time_remaining = billing_info["included_minutes"] - billing_info["total_minutes_used"]
-    click.echo(
-        f"This cycle, {int(billing_info['total_minutes_used'])} minutes have been used, and {int(time_remaining)} minutes are remaining"
-    )
-
-
-if __name__ == "__main__":
-    cli()
diff --git a/src/cli/ipconverter.py b/src/cli/ipconverter.py
deleted file mode 100755
index 4e6906b..0000000
--- a/src/cli/ipconverter.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python3
-
-"""
-Utility to convert an IPv4 address to an int, or an int to an IPv4 address.
-"""
-
-import ipaddress
-
-import click
-
-
-@click.command()
-@click.argument("ips", nargs=-1, type=int)
-def int2ip(ips):
-    for ip in ips:
-        convip = ipaddress.ip_address(ip)
-        print(f"{ip} → {convip}")
-
-
-@click.command()
-@click.argument("ips", nargs=-1, type=str)
-def ip2int(ips):
-    for ip in ips:
-        convip = int(ipaddress.ip_address(ip))
-        print(f"{ip} → {convip}")