1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: include machine name in sample data script

This commit is contained in:
Ferdinand Mütsch 2021-01-21 22:17:46 +01:00
parent 189a09d91f
commit c39538db13

View File

@ -11,6 +11,7 @@ from typing import List, Union
import requests import requests
from tqdm import tqdm from tqdm import tqdm
MACHINE = "devmachine"
UA = 'wakatime/13.0.7 (Linux-4.15.0-91-generic-x86_64-with-glibc2.4) Python3.8.0.final.0 generator/1.42.1 generator-wakatime/4.0.0' UA = 'wakatime/13.0.7 (Linux-4.15.0-91-generic-x86_64-with-glibc2.4) Python3.8.0.final.0 generator/1.42.1 generator-wakatime/4.0.0'
LANGUAGES = { LANGUAGES = {
'Go': 'go', 'Go': 'go',
@ -75,7 +76,8 @@ def post_data_sync(data: List[Heartbeat], url: str, api_key: str):
for h in tqdm(data): for h in tqdm(data):
r = requests.post(url, json=[h.__dict__], headers={ r = requests.post(url, json=[h.__dict__], headers={
'User-Agent': UA, 'User-Agent': UA,
'Authorization': f'Basic {encoded_key}' 'Authorization': f'Basic {encoded_key}',
'X-Machine-Name': MACHINE,
}) })
if r.status_code != 201: if r.status_code != 201:
print(r.text) print(r.text)