Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class Agent(Thread):
  2. def __init__(self, url):
  3. Thread.__init__(self)
  4. self.url = url
  5.  
  6. def run(self):
  7. response = urllib2.urlopen(url)
  8. print float(response.read())/0.00062137
  9.  
  10. class MetarReader:
  11.  
  12. def __init__(self, Config):
  13. self.myConfig = Config
  14. self.visibility_m = self.myConfig.visMaxHighLevel
  15.  
  16. def getVisibility(self):
  17. self.PlaneLat = XPLMFindDataRef("sim/flightmodel/position/latitude")
  18. self.PlaneLon = XPLMFindDataRef("sim/flightmodel/position/longitude")
  19. latitude = XPLMGetDataf(self.PlaneLat)
  20. longitude = XPLMGetDataf(self.PlaneLon)
  21. url="http://openvfr.freyt.de/openWeather/getMetar.php?lat="+str(latitude)+"&lon="+str(longitude)+"&out=visibility_statute_mi"
  22. #print str(url)
  23. #response = urllib2.urlopen(url)
  24. #self.visibility_m = float(response.read())/0.00062137
  25. print "METAR: visibility_m:" + str(self.visibility_m)
  26.  
  27. t = Agent(url)
  28. t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement