diff options
author | Franck Cuny <franck@fcuny.net> | 2024-01-25 17:47:36 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2024-01-25 17:47:36 -0800 |
commit | 5a7f4b5dc1ee9ff454f0a055d413cba2f803923d (patch) | |
tree | 454d3ad64365b15c3541a49a90e51cf1c55eb950 | |
parent | bump the version of go (diff) | |
download | world-5a7f4b5dc1ee9ff454f0a055d413cba2f803923d.tar.gz |
delete some unused code
-rw-r--r-- | tools/default.nix | 2 | ||||
-rw-r--r-- | tools/gha-billing/default.nix | 35 | ||||
-rwxr-xr-x | tools/gha-billing/gha-billing.py | 40 | ||||
-rw-r--r-- | tools/waybar-systemd-units/default.nix | 27 | ||||
-rwxr-xr-x | tools/waybar-systemd-units/waybar-systemd.py | 75 |
5 files changed, 0 insertions, 179 deletions
diff --git a/tools/default.nix b/tools/default.nix index 368ce4f..cc20040 100644 --- a/tools/default.nix +++ b/tools/default.nix @@ -2,11 +2,9 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: { dnsmasq-to-html = pkgs.callPackage ./dnsmasq-leases-html { }; - gha-billing = pkgs.callPackage ./gha-billing { }; git-blame-stats = pkgs.callPackage ./git-blame-stats { }; git-broom = pkgs.callPackage ./git-broom { }; ipconverter = pkgs.callPackage ./ipconverter { }; perf-flamegraph-pid = pkgs.callPackage ./perf-flamegraph-pid { }; seqstat = pkgs.callPackage ./seqstat { }; - waybar-systemd-units = pkgs.callPackage ./waybar-systemd-units { }; }) diff --git a/tools/gha-billing/default.nix b/tools/gha-billing/default.nix deleted file mode 100644 index 73ea63e..0000000 --- a/tools/gha-billing/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ lib, stdenvNoCC, pkgs }: - -stdenvNoCC.mkDerivation rec { - pname = "gha-billing"; - src = ./gha-billing.py; - version = "0.1.0"; - - buildInputs = [ - (pkgs.python310.withPackages (ps: with ps; [ - requests - ])) - ]; - - propagatedBuildInputs = [ - (pkgs.python310.withPackages (ps: with ps; [ - requests - ])) - ]; - - dontUnpack = true; - dontBuild = true; - - installPhase = '' - mkdir -p $out/bin - cp $src $out/bin/${pname} - ''; - - - meta = with pkgs.lib; { - description = "CLI to get billing information for GHA."; - license = licenses.mit; - platforms = platforms.unix; - maintainers = [ ]; - }; -} diff --git a/tools/gha-billing/gha-billing.py b/tools/gha-billing/gha-billing.py deleted file mode 100755 index c9c09ba..0000000 --- a/tools/gha-billing/gha-billing.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import os -import sys - -import requests - -API_URL = "https://api.github.com" - - -def main(api_token: str, user: str) -> None: - s = requests.Session() - s.headers.update({"Authorization": f"token {api_token}"}) - s.headers.update({"Accept": "application/vnd.github.v3+json"}) - - res = s.get(f"{API_URL}/users/{user}/settings/billing/actions", timeout=5) - res.raise_for_status() - - billing = res.json() - - time_remaining = billing["included_minutes"] - billing["total_minutes_used"] - print( - f"this cycle, {billing['total_minutes_used']} minutes have been used, and {time_remaining} minutes are remaining" - ) - - -if __name__ == "__main__": - argp = argparse.ArgumentParser() - argp.add_argument("-t", "--token-file", nargs=1, type=argparse.FileType("r")) - argp.add_argument("-u", "--user", type=str, default="fcuny") - args = argp.parse_args() - - if args.token_file: - api_token = args.token_file[0].readline().strip() - else: - print("Must pass token file with -t/--token_file", file=sys.stderr) - sys.exit(os.EX_USAGE) - - main(api_token, args.user) diff --git a/tools/waybar-systemd-units/default.nix b/tools/waybar-systemd-units/default.nix deleted file mode 100644 index 086fba1..0000000 --- a/tools/waybar-systemd-units/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ lib, stdenvNoCC, pkgs }: - -stdenvNoCC.mkDerivation rec { - pname = "waybar-systemd-units"; - src = ./waybar-systemd.py; - version = "0.1.0"; - - buildInputs = [ (pkgs.python310.withPackages (ps: with ps; [ click ])) ]; - - propagatedBuildInputs = - [ (pkgs.python310.withPackages (ps: with ps; [ click ])) ]; - - dontUnpack = true; - dontBuild = true; - - installPhase = '' - mkdir -p $out/bin - cp $src $out/bin/${pname} - ''; - - meta = with lib; { - description = "Get a list of systemd units that have failed."; - license = with licenses; [ mit ]; - platforms = platforms.unix; - maintainers = with maintainers; [ fcuny ]; - }; -} diff --git a/tools/waybar-systemd-units/waybar-systemd.py b/tools/waybar-systemd-units/waybar-systemd.py deleted file mode 100755 index de5c2e0..0000000 --- a/tools/waybar-systemd-units/waybar-systemd.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python3 -import json -import subprocess -from typing import List - -import click - - -def _get_failed_units(cmd) -> List[str]: - res = subprocess.run(cmd, capture_output=True, check=True) - if res.returncode == 0: - units = json.loads(res.stdout) - return [unit.get("unit") for unit in units] - else: - click.echo(f"failed to run {cmd}", err=True) - return [] - - -@click.command() -@click.version_option(version="0.1.0") -def cli() -> int: - """ - Get a list of systemd units (system and users) that have - failed, and print the output in JSON, in a format compatible to - waybar. - """ - failed_system_units = _get_failed_units( - [ - "systemctl", - "list-units", - "-o", - "json", - "--state=failed", - ], - ) - - failed_user_units = _get_failed_units( - [ - "systemctl", - "--user", - "list-units", - "-o", - "json", - "--state=failed", - ], - ) - - failed_units = len(failed_user_units) + len(failed_system_units) - - # The output format documentation: - # https://github.com/Alexays/Waybar/wiki/Module:-Custom - output = {"text": failed_units, "class": "success"} - - if failed_units > 0: - output["class"] = "errors" - - tooltip = [] - - if len(failed_user_units) > 0: - tooltip.append("failed user units: {}".format(", ".join(failed_user_units))) - - if len(failed_system_units) > 0: - tooltip.append( - "failed system units: {}".format(", ".join(failed_system_units)) - ) - - output["tooltip"] = "\n".join(tooltip) - - click.echo(json.dumps(output)) - - return 0 - - -if __name__ == "__main__": - cli() |