-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
35 lines (21 loc) · 936 Bytes
/
script.py
File metadata and controls
35 lines (21 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
from pydexcom import Dexcom
from datetime import datetime
class ANSI_Compatible:
END = '\x1b[0m'
# If Foreground is False that means color effect on Background
@staticmethod
def Color(ColorNo, Foreground=True): # 0 - 255
FB_G = 38 if Foreground else 48 # Effect on foreground or background
return '\x1b[' + str(FB_G) + ';5;' + str(ColorNo) + 'm'
dexcom = Dexcom(username="YOUR EMAIL", password="YOUR PASSWORD")
bg = dexcom.get_current_glucose_reading()
glucose_number = str(bg.value)
glucose_json = str(bg.json)
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
with open('bg_file.txt', 'a', encoding="utf-8") as f:
# f.write(f'{timestamp} - {glucose_number}\n')
f.write(glucose_json+'\n')
# with open('bg_file.txt', 'w', encoding="utf-8") as f:
# f.write(glucose_number)
print(glucose_number, bg.trend_arrow)