Reformatted with black -l 120 -t py35 .

This commit is contained in:
D0han
2019-07-21 19:40:28 +02:00
parent 79062ff3d6
commit e15dc1ce11
17 changed files with 681 additions and 462 deletions

View File

@ -4,23 +4,26 @@ import time
from owrx.config import PropertyManager
import logging
logger = logging.getLogger(__name__)
class SdrHuUpdater(threading.Thread):
def __init__(self):
self.doRun = True
super().__init__(daemon = True)
super().__init__(daemon=True)
def update(self):
pm = PropertyManager.getSharedInstance()
cmd = "wget --timeout=15 -4qO- https://sdr.hu/update --post-data \"url=http://{server_hostname}:{web_port}&apikey={sdrhu_key}\" 2>&1".format(**pm.__dict__())
cmd = 'wget --timeout=15 -4qO- https://sdr.hu/update --post-data "url=http://{server_hostname}:{web_port}&apikey={sdrhu_key}" 2>&1'.format(
**pm.__dict__()
)
logger.debug(cmd)
returned=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()
returned=returned[0].decode('utf-8')
returned = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()
returned = returned[0].decode("utf-8")
if "UPDATE:" in returned:
retrytime_mins = 20
value=returned.split("UPDATE:")[1].split("\n",1)[0]
value = returned.split("UPDATE:")[1].split("\n", 1)[0]
if value.startswith("SUCCESS"):
logger.info("Update succeeded!")
else:
@ -33,4 +36,4 @@ class SdrHuUpdater(threading.Thread):
def run(self):
while self.doRun:
retrytime_mins = self.update()
time.sleep(60*retrytime_mins)
time.sleep(60 * retrytime_mins)