Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upload takes too long.
#12
I have added the correct time ("localdt") in the form WOW like, example: dateutc=2011-02-02+10%3A32%3A55
But the time in that particular line doesnt update...
Here is a partial output from the script beneath.
The upper date time (bold) is good, the power one (bold) isnt and should contain the date and time between those %3A from the above instead of 14:58:09.

Received KNMI WOW 429 The custom error module does not recognize this error.
Thu, 02 Apr 2020 17:10:02
winddir= 299.7
windspeedmph= 0.021
windgustmph= 0.032
windgustdir= 290.9
humidity= 70.68
dewptf= 29.63
tempf= 38.31
rainin= 0
dailyrainin= 0
baromin= 30.12243
solarradiation= 0
&dateutc=2020-04-02+14%3A58%3A09






import requests
import time
import schedule    
import csv
import urllib

date = time.strftime("%Y-%m-%d",time.gmtime())
hours = time.strftime("%H",time.gmtime())
minutes = time.strftime("%M",time.gmtime())
seconds = time.strftime("%S",time.gmtime())
# Save it as a string in a format that WOW likes


WUurl = "https://wow.metoffice.gov.uk/automaticreading?"
siteid = "xxxxxxxx" 
siteAuthenticationKey = "xxxxxxx" 
WUcreds = "siteid=" + siteid + "&siteAuthenticationKey="+ siteAuthenticationKey
action_str = "&action=updateraw"
localdt = "&dateutc="+date+"+"+hours+"%3A"+minutes+"%3A"+seconds

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 +
        localdt +
        "&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)
        
        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)
        print (minutes, flush=True)

while True:
 try:
     task()
     time.sleep(300 - time.time() % 300)
     refresh()
 except:
    pass
    time.sleep(1)

else:
 time.sleep(5)

Hi,

With some changes i managed to get it working.
Now lets see if its uploading the way it supposed to do Smile .

import requests
import csv
import hashlib
import time
import schedule
import urllib
from time import sleep
import sys
starttime=time.time()

def task():

    date = time.strftime("%Y-%m-%d")
    hours = time.strftime("%H")
    minutes = time.strftime("%M")
    seconds = time.strftime("%S")
    localdt = "&dateutc="+date+"+"+hours+"%3A"+minutes+"%3A"+seconds


    WUurl = "https://wow.metoffice.gov.uk/automaticreading?"
    siteid = "" 
    siteAuthenticationKey = "" 
    WUcreds = "siteid=" + siteid + "&siteAuthenticationKey="+ siteAuthenticationKey
    action_str = "&action=updateraw"


    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 +
        localdt +
        "&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)
        
    print("Received KNMI WOW " + str(r.status_code) + " " + str(r.text),flush=True)
    print(time.strftime("%Y%m%d%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)
    print (localdt, flush=True)

while True:
 try:
     task()
     time.sleep(300 - time.time() % 300)
     refresh()
 except:
    pass
    time.sleep(1)

else:
 time.sleep(300)
 refresh()
     
Reply


Messages In This Thread
Upload takes too long. - by Makada - Apr-01-2020, 03:12 PM
RE: Upload takes too long. - by deanhystad - Apr-01-2020, 04:33 PM
RE: Upload takes too long. - by Makada - Apr-01-2020, 04:42 PM
RE: Upload takes too long. - by BrendanD - Apr-01-2020, 05:24 PM
RE: Upload takes too long. - by Makada - Apr-01-2020, 05:49 PM
RE: Upload takes too long. - by BrendanD - Apr-01-2020, 06:06 PM
RE: Upload takes too long. - by Makada - Apr-01-2020, 06:26 PM
RE: Upload takes too long. - by BrendanD - Apr-01-2020, 07:19 PM
RE: Upload takes too long. - by Makada - Apr-01-2020, 07:22 PM
RE: Upload takes too long. - by BrendanD - Apr-01-2020, 08:21 PM
RE: Upload takes too long. - by Makada - Apr-01-2020, 08:29 PM
RE: Upload takes too long. - by Makada - Apr-02-2020, 03:15 PM
RE: Upload takes too long. - by BrendanD - Apr-02-2020, 06:20 PM
RE: Upload takes too long. - by Makada - Apr-02-2020, 07:04 PM
RE: Upload takes too long. - by BrendanD - Apr-02-2020, 07:39 PM
RE: Upload takes too long. - by Makada - Apr-02-2020, 07:49 PM
RE: Upload takes too long. - by BrendanD - Apr-02-2020, 08:32 PM
RE: Upload takes too long. - by Makada - Apr-02-2020, 08:37 PM
RE: Upload takes too long. - by BrendanD - Apr-02-2020, 08:43 PM
RE: Upload takes too long. - by Makada - Apr-02-2020, 08:58 PM
RE: Upload takes too long. - by BrendanD - Apr-02-2020, 10:58 PM
RE: Upload takes too long. - by Makada - Apr-03-2020, 04:07 AM
RE: Upload takes too long. - by Makada - Apr-03-2020, 03:38 PM
RE: Upload takes too long. - by BrendanD - Apr-03-2020, 03:41 PM
RE: Upload takes too long. - by Makada - Apr-03-2020, 04:34 PM
RE: Upload takes too long. - by BrendanD - Apr-03-2020, 05:30 PM
RE: Upload takes too long. - by Makada - Apr-04-2020, 10:17 AM
RE: Upload takes too long. - by BrendanD - Apr-04-2020, 02:12 PM
RE: Upload takes too long. - by Makada - Apr-05-2020, 11:56 AM
RE: Upload takes too long. - by Makada - Apr-06-2020, 08:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Run a timer when a functions starts to see how long the function takes to complete Pedroski55 2 2,795 Apr-19-2020, 06:28 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020