Clean dupes and updates from last few weeks

This commit is contained in:
Ian Keane 2022-06-25 06:10:37 -04:00
parent 2da7c637c1
commit 70bc80bb28
36 changed files with 200 additions and 933 deletions

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/python3
#!/usr/bin/python3
import sys
import requests
import json
@ -27,6 +27,7 @@ from termcolor import colored
# ]
tmux = '--tmux' in sys.argv
lemonbar = '--lb' in sys.argv
down = '\u2193' # ↓
falling = '\u2798' # ➘
@ -37,9 +38,14 @@ up = '\u2191' # ↑
url = 'http://blood.dump.town'
options = '/api/v1/entries.json?count=1&token=phone-7631d7eebc79825b'
res = requests.get(url + options)
try:
res = requests.get(url + options)
except:
sys.exit()
sugar = res.json()[0]
delta = sugar['delta']
sgv = sugar['sgv']
direction = sugar['direction']
@ -63,14 +69,19 @@ elif ((sgv >= 180 and sgv <= 225)
else:
color = 'green'
if not tmux:
print(colored(str(sugar['sgv']) +
' ' + arrow + ' ' +
'(' + str(delta) + ')',
color))
else:
if tmux:
print(f'#[bg={color}] ' +
str(round(sugar['sgv'], 1)) + ' ' +
str(round(sugar['sgv'], 1)) + ' ' +
arrow + ' ' +
'(' + str(delta) + ')'
)
elif lemonbar:
print(str(round(sugar['sgv'], 1)) + ' ' +
arrow + ' ' +
'(' + str(delta) + ')'
)
)
else:
print(colored(str(sugar['sgv']) +
' ' + arrow + ' ' +
'(' + str(delta) + ')',
color))