they nerfed my swag
This commit is contained in:
+6
-15
@@ -1,37 +1,28 @@
|
|||||||
from urllib import request
|
|
||||||
import json
|
import json
|
||||||
import socket
|
import socket
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
import requests
|
||||||
DEFAULT_SHUTDOWN = "21:00"
|
DEFAULT_SHUTDOWN = "21:00"
|
||||||
|
|
||||||
LAST_VALUE = 0
|
LAST_VALUE = 0
|
||||||
|
|
||||||
machine_name = socket.gethostname()
|
machine_name = socket.gethostname()
|
||||||
|
|
||||||
url = "http://192.168.50.27:5000/lookup"
|
url = "http://192.168.50.27:5000/lookup"
|
||||||
payload = {
|
payload = {
|
||||||
"name": machine_name,
|
"name": machine_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
data = json.dumps(payload).encode("utf-8")
|
|
||||||
|
|
||||||
req = urllib.request.Request(
|
|
||||||
url,
|
|
||||||
headers={"Content-Type": "application/json"},
|
|
||||||
data=data,
|
|
||||||
method="POST"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(req, timeout=10) as response:
|
response = requests.post(url, json=payload, timeout=10)
|
||||||
data = response.read()
|
response.raise_for_status()
|
||||||
json_data = json.loads(data)
|
json_data = response.json()
|
||||||
print(json_data)
|
print(json_data)
|
||||||
return json_data
|
return json_data
|
||||||
except:
|
except requests.RequestException:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def to_seconds(t):
|
def to_seconds(t):
|
||||||
|
|||||||
Reference in New Issue
Block a user