File: testpixmap.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 (48 lines) | stat: -rw-r--r-- 999 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
#!/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.getPixmap()
        b=pr.getCloudinfo()
        c=pr.getConditions()

        print(a, b, c)

        count += 1

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