Apr-01-2020, 03:12 PM
Hi all,
I have an upload script which uploads data every 5 minutes at every 00:00 00:05 00:10 00:15 and so on during 24/7.
But sometimes the upload takes too long.
The interval must be exactly at every 5 minutes and zero seconds,
Or for example when an upload is at 00:05:01 the next upload has to be at 00:10:01 with the same amount of seconds after the minute.
As you can see in the example upload below, one upload is done at 16:50:11 and the next upload is done at 16:55:01.
So thats shorter then exactly 5 minutes and zero seconds and thats why it gets an error and wont upload.
Ive also tried the "schedule.every(5).minutes.do(task)" but that wont start at exactly every 00:00:00 00:05:00 00:10:00 and has the same non exact interval.
My python script is included.
Received KNMI WOW 200 {}
Wed, 01 Apr 2020 16:50:11
winddir= 329.2
windspeedmph= 9.74
windgustmph= 14.28
windgustdir= 329.9
humidity= 44.24
dewptf= 31.54
tempf= 52.69
rainin= 0
dailyrainin= 0
baromin= 30.16438
solarradiation= 473.0833
Received KNMI WOW 429 The custom error module does not recognize this error.
Wed, 01 Apr 2020 16:55:01
winddir= 329.9
windspeedmph= 6.027
windgustmph= 13.15
windgustdir= 329.9
humidity= 44.29
dewptf= 31.36
tempf= 52.46
rainin= 0
dailyrainin= 0
baromin= 30.16297
solarradiation= 524.5936
I have an upload script which uploads data every 5 minutes at every 00:00 00:05 00:10 00:15 and so on during 24/7.
But sometimes the upload takes too long.
The interval must be exactly at every 5 minutes and zero seconds,
Or for example when an upload is at 00:05:01 the next upload has to be at 00:10:01 with the same amount of seconds after the minute.
As you can see in the example upload below, one upload is done at 16:50:11 and the next upload is done at 16:55:01.
So thats shorter then exactly 5 minutes and zero seconds and thats why it gets an error and wont upload.
Ive also tried the "schedule.every(5).minutes.do(task)" but that wont start at exactly every 00:00:00 00:05:00 00:10:00 and has the same non exact interval.
My python script is included.
Received KNMI WOW 200 {}
Wed, 01 Apr 2020 16:50:11
winddir= 329.2
windspeedmph= 9.74
windgustmph= 14.28
windgustdir= 329.9
humidity= 44.24
dewptf= 31.54
tempf= 52.69
rainin= 0
dailyrainin= 0
baromin= 30.16438
solarradiation= 473.0833
Received KNMI WOW 429 The custom error module does not recognize this error.
Wed, 01 Apr 2020 16:55:01
winddir= 329.9
windspeedmph= 6.027
windgustmph= 13.15
windgustdir= 329.9
humidity= 44.29
dewptf= 31.36
tempf= 52.46
rainin= 0
dailyrainin= 0
baromin= 30.16297
solarradiation= 524.5936
import requests import time import schedule import csv import urllib WUurl = "https://wow.metoffice.gov.uk/automaticreading?" siteid = "xxxxxxxx" siteAuthenticationKey = xxxxxx WUcreds = "siteid=" + siteid + "&siteAuthenticationKey="+ siteAuthenticationKey date_str = "&dateutc=now" action_str = "&action=updateraw" def task(): WeatherUnderground= open("C:\\Campbellsci\\LoggerNet\\CR1000_upload.dat", "r") csvReader = csv.reader(WeatherUnderground) for field in csvReader: a = (field[12]) b = (field[17]) c = (field[19]) d = (field[16]) e = (field[8]) f = (field[7]) g = (field[5]) h = (field[27]) i = (field[25]) j = (field[10]) k = (field[23]) l = (field[16]) winddir=a windspeedmph=b windgustmph=c windgustdir=d humidity=e dewptf=f tempf=g rainin=h dailyrainin=i baromin=j solarradiation=k softwaretype=1 r= requests.get( WUurl + WUcreds + date_str + "&winddir=" + str(winddir)+ "&windspeedmph=" + str(windspeedmph)+ "&windgustmph=" + str(windgustmph)+ "&windgustdir=" + str(windgustdir)+ "&humidity=" + str(humidity)+ "&dewptf=" + str(dewptf)+ "&tempf=" + str(tempf)+ "&rainin=" + str(rainin)+ "&dailyrainin=" + str(dailyrainin)+ "&baromin=" + str(baromin)+ "&solarradiation=" + str(solarradiation)+ str(softwaretype)+ action_str) timeout=60 print("Received KNMI WOW " + str(r.status_code) + " " + str(r.text),flush=True) print (time.strftime("%a, %d %b %Y %H:%M:%S"), flush=True) print ("winddir= " + a, flush=True) print ("windspeedmph= " + b, flush=True) print ("windgustmph= " + c, flush=True) print ("windgustdir= " + d, flush=True) print ("humidity= " + e, flush=True) print ("dewptf= " + f, flush=True) print ("tempf= " + g, flush=True) print ("rainin= " + h, flush=True) print ("dailyrainin= " + i, flush=True) print ("baromin= " + j, flush=True) print ("solarradiation= " + k, flush=True) while True: try: task() time.sleep(300 - time.time() % 300) refresh() except: pass time.sleep(1) else: time.sleep(300)