From 456f9007b14ec638cd91ad7feda40de19f208978 Mon Sep 17 00:00:00 2001 From: Jacob Babor Date: Sun, 15 Dec 2024 15:44:54 -0600 Subject: [PATCH] Use ydotool to just type it into a web field --- invoice.py | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/invoice.py b/invoice.py index 40cb117..eb69dc2 100755 --- a/invoice.py +++ b/invoice.py @@ -12,8 +12,9 @@ import glob import json import os import re -import requests +import subprocess import textwrap +import time # Config globals rate = float(41.00) @@ -41,38 +42,12 @@ with open(csv[0], 'r') as csv: timesheet[date][issue] += hours -# Next, construct args for the request we'll make to invoice-generator.com's API -requestbody = { - "from": "JACOB", - "to": "CLIENT", - "number": 9999, - "date": "CURRENT_DATE", - "due_date": "DUE_DATE", - "terms": "Net 14 days", - "items": [] -} for k,v in timesheet.items(): print(k) for i,h in v.items(): - requestbody["items"].append({ - "name": f"{ k } - { i }", - "quantity": h, - "unit_cost": rate - }) print(f' { i } - { h }') - -# Submit said request -resp = requests.post( - url = 'https://invoice-generator.com', - json = json.dumps(requestbody), - headers = { - "Authorization": f"Bearer { os.environ['INVOICE_GENERATOR_APIKEY'] }" - } -) - -if not resp.status_code == 200: - print(resp) - quit() - -with open('out.pdf', 'w') as f: - f.write(resp.text) + # Now actually do the work + subprocess.run(["ydotool", "type", f"{k} - {i}\t{round(h,2)}\t{rate}\t"]) + time.sleep(0.10) + subprocess.run(["ydotool", "type", "\n"]) + time.sleep(0.10)