Use ydotool to just type it into a web field

This commit is contained in:
Jacob Babor 2024-12-15 15:44:54 -06:00
parent 36413aafd0
commit 456f9007b1

View File

@ -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)