File: testall.py

package info (click to toggle)
python-pymetar 1.2-0.2
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,400 kB
  • sloc: python: 1,014; sh: 14; makefile: 2
file content (85 lines) | stat: -rw-r--r-- 2,137 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python3 -tt

import pymetar
import sys
import os

if __name__ == "__main__":
    if len(sys.argv) > 1:
        repdir=sys.argv[1]
    else:
        repdir=("reports")

    if len(sys.argv) > 2:
        reports = sys.argv[2:]
    else:
        reports = os.listdir(repdir)

    reports.sort()
    count=0
    rf=pymetar.ReportFetcher()

    for reportfile in reports:
        station = reportfile[:-4]
        sys.stdout.write("%s " % (station))
        sys.stdout.flush()

        fd = open("%s/%s" % (repdir, reportfile))
        try:
            report = fd.read().encode()
        except UnicodeDecodeError:
            continue
        fd.close()

        repo = rf.MakeReport(station, report)
        
        rp = pymetar.ReportParser()
        pr = rp.ParseReport(repo)
        
        a=pr.getFullReport()
        a=pr.getTemperatureCelsius()
        a=pr.getTemperatureFahrenheit()
        a=pr.getDewPointCelsius()
        a=pr.getDewPointFahrenheit()
        a=pr.getWindSpeed()
        a=pr.getWindSpeedMilesPerHour()
        a=pr.getWindSpeedBeaufort()
        a=pr.getWindDirection()
        a=pr.getWindCompass()
        a=pr.getVisibilityKilometers()
        a=pr.getVisibilityMiles()
        a=pr.getHumidity()
        a=pr.getPressure()
        a=pr.getPressuremmHg()
        a=pr.getRawMetarCode()
        a=pr.getWeather()
        a=pr.getSkyConditions()
        a=pr.getStationName()
        a=pr.getStationCity()
        a=pr.getStationCountry()
        a=pr.getCycle()
        a=pr.getStationPosition()
        a=pr.getStationPositionFloat()
        a=pr.getStationLatitude()
        a=pr.getStationLatitudeFloat()
        a=pr.getStationLongitude()
        a=pr.getStationLongitudeFloat()
        a=pr.getStationAltitude()
        a=pr.getReportURL()
        a=pr.getTime()
        a=pr.getISOTime()
        a=pr.getPixmap()
        a=pr.getCloudinfo()
        a=pr.getConditions()
        a=pr.getWindchill()
        a=pr.getWindchillF()

        pr._clearallfields()

        count += 1
    
        sys.stdout.write("...ok\n")

    sys.stderr.write("%s station reports check out ok\n" % (count))