Révision 417bebc3
Plugin weather_press_: fix style issues
| plugins/weather/weather_press_ | ||
|---|---|---|
| 18 | 18 |
|
| 19 | 19 |
url = 'http://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT' |
| 20 | 20 |
|
| 21 |
re_hPa = re.compile('Pressure.*\((\d+) hPa\)')
|
|
| 21 |
re_hpa = re.compile('Pressure.*\((\d+) hPa\)')
|
|
| 22 | 22 |
|
| 23 | 23 |
|
| 24 | 24 |
code = sys.argv[0][(sys.argv[0].rfind('_')+1):]
|
| 25 |
if code == None: sys.exit(1) |
|
| 26 |
|
|
| 27 |
if len(sys.argv) == 2 and sys.argv[1] == "autoconf": |
|
| 28 |
|
|
| 29 |
print "yes" |
|
| 30 |
|
|
| 25 |
if not code: |
|
| 26 |
sys.exit(1) |
|
| 27 |
elif len(sys.argv) == 2 and sys.argv[1] == "autoconf": |
|
| 28 |
print("yes")
|
|
| 31 | 29 |
elif len(sys.argv) == 2 and sys.argv[1] == "config": |
| 32 |
|
|
| 33 |
print 'graph_title Atmospheric pressure at code %s' % code |
|
| 34 |
print 'graph_vlabel Pressure in hPa' |
|
| 35 |
print 'graph_category sensors' |
|
| 36 |
|
|
| 37 |
print 'pressure.label Pressure' |
|
| 38 |
print 'pressure.type GAUGE' |
|
| 39 |
print 'graph_args --base 1000 -l 850 -u 1050 --rigid' |
|
| 40 |
print 'graph_scale no' |
|
| 41 |
|
|
| 30 |
print('graph_title Atmospheric pressure at code %s' % code)
|
|
| 31 |
print('graph_vlabel Pressure in hPa')
|
|
| 32 |
print('graph_category sensors')
|
|
| 33 |
|
|
| 34 |
print('pressure.label Pressure')
|
|
| 35 |
print('pressure.type GAUGE')
|
|
| 36 |
print('graph_args --base 1000 -l 850 -u 1050 --rigid')
|
|
| 37 |
print('graph_scale no')
|
|
| 42 | 38 |
else: |
| 39 |
u = urllib.urlopen(url % code) |
|
| 40 |
txt = u.read() |
|
| 41 |
u.close() |
|
| 43 | 42 |
|
| 44 |
u = urllib.urlopen(url % code) |
|
| 45 |
txt = u.read() |
|
| 46 |
u.close() |
|
| 47 |
|
|
| 48 |
hPa = re_hPa.findall(txt)[0] |
|
| 49 |
|
|
| 50 |
print 'pressure.value %s' % hPa |
|
| 43 |
hpa = re_hpa.findall(txt)[0] |
|
| 44 |
print('pressure.value %s' % hpa)
|
|
Formats disponibles : Unified diff