Changeset 963:35b2e35e9e07
- Timestamp:
- 05/14/19 18:02:30 (6 years ago)
- Branch:
- python3
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/web.py
r962 r963 1052 1052 ("hoursBeforeNow", "24"), 1053 1053 ("mostRecentForEachStation", "constraint")]) 1054 url += data1055 f = urllib.request.urlopen(url, timeout = 10.0, cafile=certifi.where())1054 result = Result() 1055 result.metars = {} 1056 1056 try: 1057 result = Result() 1058 result.metars = {} 1059 for line in f.readlines(): 1060 line = str(line, "iso-8859-1") 1061 if len(line)>5 and line[4]==' ': 1062 icao = line[0:4] 1063 if icao in self._airports: 1064 result.metars[icao] = line.strip().split(",")[0] 1065 finally: 1066 f.close() 1057 url += data 1058 f = urllib.request.urlopen(url, timeout = 10.0, cafile = certifi.where()) 1059 try: 1060 for line in f.readlines(): 1061 line = str(line, "iso-8859-1") 1062 if len(line)>5 and line[4]==' ': 1063 icao = line[0:4] 1064 if icao in self._airports: 1065 result.metars[icao] = line.strip().split(",")[0] 1066 finally: 1067 f.close() 1068 except Exception as e: 1069 traceback.print_exc() 1070 print("mlx.web.GetMETARs.run: failed to get METARs for %s: %s" % \ 1071 (self._airports, str(e))) 1067 1072 1068 1073 return result
Note:
See TracChangeset
for help on using the changeset viewer.