Revert UTC changes.

This reverts commit 3ebbd4adf6.
This commit is contained in:
Marks Polakovs 2020-04-16 16:37:59 +02:00
parent e6bdb1b1a7
commit 3f737c2328
4 changed files with 6 additions and 17 deletions

View file

@ -12,7 +12,6 @@ MarkupSafe==1.1.1
multidict==4.7.5
mypy==0.770
mypy-extensions==0.4.3
pytz==2019.3
requests==2.23.0
typed-ast==1.4.1
typing-extensions==3.7.4.2

View file

@ -32,10 +32,8 @@ pyee==7.0.1
pylibsrtp==0.6.6
pyls==0.1.6
pyls-mypy==0.1.8
python-dateutil==2.8.1
python-jsonrpc-server==0.3.4
python-language-server==0.31.9
pytz==2019.3
raygun4py==4.3.0
requests==2.23.0
six==1.14.0

View file

@ -2,9 +2,6 @@
key = CHANGEME
enable = False
[time]
local_timezone = Europe/London
[shittyserver]
notify_url = https://example.com
websocket_port = 8079

View file

@ -9,7 +9,6 @@ from flask import Flask, jsonify, request
from flask_cors import CORS # type: ignore
import requests
import datetime
import pytz
import random
from telnetlib import Telnet
import configparser
@ -23,8 +22,6 @@ CORS(app) # Enable Cors access-all
SUSTAINER_AUTONEWS = config.get("stateserver", "sustainer_autonews") == "True"
LOCAL_TIME = pytz.timezone(config.get("time", "local_timezone"))
def do_ws_srv_telnet(source: str) -> None:
HOST = "localhost"
@ -56,7 +53,7 @@ def myradioApiRequest(url: str) -> Any:
def getNextHourTimestamp() -> int:
current = datetime.datetime.utcnow()
current = datetime.datetime.now()
currentPlusHour = current + datetime.timedelta(hours=1)
nextHourStart = currentPlusHour.replace(minute=0, second=0)
nextTimestamp = int(nextHourStart.timestamp())
@ -88,7 +85,7 @@ lastConnectionIDToRegister = -1
def getCurrentShowConnection() -> Optional[Connection]:
for connection in connections:
if (connection["startTimestamp"] <= datetime.datetime.utcnow().timestamp()) and (
if (connection["startTimestamp"] <= datetime.datetime.now().timestamp()) and (
connection["endTimestamp"] >= getNextHourTimestamp()):
return connection
return None
@ -114,7 +111,7 @@ def getNextHourConnection() -> Optional[Connection]:
def cleanOldConnections() -> None:
global connections
for i in range(len(connections)):
if connections[i]["endTimestamp"] < datetime.datetime.utcnow().timestamp():
if connections[i]["endTimestamp"] < datetime.datetime.now().timestamp():
connections.pop(i)
@ -263,14 +260,13 @@ def post_registerCheck() -> Any:
return genPayload(conn)
start_time = datetime.datetime.strptime(timeslot["start_time"], "%d/%m/%Y %H:%M")
start_time = LOCAL_TIME.localize(start_time).astimezone(pytz.utc)
duration = timeslot["duration"].split(":")
duration_time = datetime.timedelta(hours=int(duration[0]), minutes=int(duration[1]))
end_time = start_time + duration_time
now_time = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
now_time = datetime.datetime.now()
if start_time - now_time > datetime.timedelta(hours=1):
return genFail("This show too far away, please try again within an hour of starting your show.")
@ -290,9 +286,8 @@ def post_registerCheck() -> Any:
'wsid': None
}
if "wsid" in content:
print("got wsid from client! {}".format(content["wsid"]))
connection["wsid"] = content["wsid"]
if start_time + datetime.timedelta(minutes=2) < now_time:
if start_time > now_time + datetime.timedelta(minutes=2):
# they're late, bring them live now
print("({}, {}) late, bringing on air now".format(connection["connid"], connection["wsid"]))
do_ws_srv_telnet(connection["wsid"])
@ -366,7 +361,7 @@ def post_wsSessions() -> Any:
print("({}, {}) hello".format(conn["connid"], conn["wsid"]))
if conn["wsid"] in wsids_to_add:
if conn["startTimestamp"] + 120 < datetime.datetime.utcnow().timestamp():
if conn["startTimestamp"] + 120 < datetime.datetime.now().timestamp():
# they're late, bring them on air now
print("({}, {}) late, bringing on air now".format(conn["connid"], conn["wsid"]))
do_ws_srv_telnet(conn["wsid"])