[41] | 1 |
|
---|
| 2 | import const
|
---|
[97] | 3 | import util
|
---|
[41] | 4 |
|
---|
| 5 | import threading
|
---|
| 6 | import sys
|
---|
[51] | 7 | import urllib
|
---|
[41] | 8 | import urllib2
|
---|
| 9 | import hashlib
|
---|
[66] | 10 | import time
|
---|
[41] | 11 | import datetime
|
---|
| 12 | import codecs
|
---|
[106] | 13 | import traceback
|
---|
[63] | 14 | import xml.sax
|
---|
[41] | 15 |
|
---|
| 16 | #---------------------------------------------------------------------------------------
|
---|
| 17 |
|
---|
[298] | 18 | ## @package mlx.web
|
---|
| 19 | #
|
---|
| 20 | # Web interface.
|
---|
| 21 | #
|
---|
| 22 | # This module implements a thread that can perform (HTTP) requests
|
---|
| 23 | # asynchronously. When the request is performed, a callback is called. The main
|
---|
| 24 | # interface is the \ref Handler class. Each of its functions creates a \ref
|
---|
| 25 | # Request subclass instance and puts it to the request queue. The handler
|
---|
| 26 | # thread then takes the requests one by one, and executes them.
|
---|
| 27 | #
|
---|
| 28 | # This module also defines some data classes the contents of which are
|
---|
| 29 | # retrieved or sent via HTTP. \ref BookedFlight contains data of a flight
|
---|
| 30 | # booked on the MAVA website, \ref Fleet and \ref Plane represents the MAVA
|
---|
| 31 | # fleet and the gates at Ferihegy and \ref NOTAM is a NOTAM.
|
---|
| 32 |
|
---|
| 33 | #---------------------------------------------------------------------------------------
|
---|
| 34 |
|
---|
[41] | 35 | def readline(f):
|
---|
| 36 | """Read a line from the given file.
|
---|
| 37 |
|
---|
| 38 | The line is stripped and empty lines are discarded."""
|
---|
| 39 | while True:
|
---|
| 40 | line = f.readline()
|
---|
| 41 | if not line: return ""
|
---|
| 42 | line = line.strip()
|
---|
| 43 | if line:
|
---|
| 44 | return line
|
---|
| 45 |
|
---|
| 46 | #---------------------------------------------------------------------------------------
|
---|
| 47 |
|
---|
| 48 | class BookedFlight(object):
|
---|
| 49 | """A flight that was booked."""
|
---|
[191] | 50 | TYPECODE2TYPE = { "736" : const.AIRCRAFT_B736,
|
---|
| 51 | "73G" : const.AIRCRAFT_B737,
|
---|
| 52 | "738" : const.AIRCRAFT_B738,
|
---|
| 53 | "73H" : const.AIRCRAFT_B738C,
|
---|
| 54 | "733" : const.AIRCRAFT_B733,
|
---|
| 55 | "734" : const.AIRCRAFT_B734,
|
---|
| 56 | "735" : const.AIRCRAFT_B735,
|
---|
| 57 | "DH4" : const.AIRCRAFT_DH8D,
|
---|
| 58 | "762" : const.AIRCRAFT_B762,
|
---|
| 59 | "763" : const.AIRCRAFT_B763,
|
---|
| 60 | "CR2" : const.AIRCRAFT_CRJ2,
|
---|
| 61 | "F70" : const.AIRCRAFT_F70,
|
---|
| 62 | "LI2" : const.AIRCRAFT_DC3,
|
---|
| 63 | "TU3" : const.AIRCRAFT_T134,
|
---|
| 64 | "TU5" : const.AIRCRAFT_T154,
|
---|
[443] | 65 | "YK4" : const.AIRCRAFT_YK40,
|
---|
| 66 | "146" : const.AIRCRAFT_B462 }
|
---|
[41] | 67 |
|
---|
[191] | 68 | TYPE2TYPECODE = { const.AIRCRAFT_B736 : "736",
|
---|
| 69 | const.AIRCRAFT_B737 : "73G",
|
---|
| 70 | const.AIRCRAFT_B738 : "738",
|
---|
| 71 | const.AIRCRAFT_B738C : "73H",
|
---|
| 72 | const.AIRCRAFT_B733 : "733",
|
---|
| 73 | const.AIRCRAFT_B734 : "734",
|
---|
| 74 | const.AIRCRAFT_B735 : "735",
|
---|
| 75 | const.AIRCRAFT_DH8D : "DH4",
|
---|
| 76 | const.AIRCRAFT_B762 : "762",
|
---|
| 77 | const.AIRCRAFT_B763 : "763",
|
---|
| 78 | const.AIRCRAFT_CRJ2 : "CR2",
|
---|
| 79 | const.AIRCRAFT_F70 : "F70",
|
---|
| 80 | const.AIRCRAFT_DC3 : "LI2",
|
---|
| 81 | const.AIRCRAFT_T134 : "TU3",
|
---|
| 82 | const.AIRCRAFT_T154 : "TU5",
|
---|
[443] | 83 | const.AIRCRAFT_YK40 : "YK4",
|
---|
| 84 | const.AIRCRAFT_B462 : "146" }
|
---|
[184] | 85 |
|
---|
| 86 | @staticmethod
|
---|
| 87 | def getDateTime(date, time):
|
---|
| 88 | """Get a datetime object from the given textual date and time."""
|
---|
| 89 | return datetime.datetime.strptime(date + " " + time,
|
---|
| 90 | "%Y-%m-%d %H:%M:%S")
|
---|
[41] | 91 |
|
---|
[184] | 92 | def __init__(self, id = None):
|
---|
| 93 | """Construct a booked flight with the given ID."""
|
---|
| 94 | self.id = id
|
---|
[41] | 95 |
|
---|
[184] | 96 | def readFromWeb(self, f):
|
---|
| 97 | """Read the data of the flight from the web via the given file
|
---|
| 98 | object."""
|
---|
[41] | 99 | self.callsign = readline(f)
|
---|
| 100 |
|
---|
| 101 | date = readline(f)
|
---|
[188] | 102 | print "web.BookedFlight.readFromWeb: date:", date
|
---|
| 103 | if date=="0000-00-00": date = "0001-01-01"
|
---|
[41] | 104 |
|
---|
| 105 | self.departureICAO = readline(f)
|
---|
| 106 | self.arrivalICAO = readline(f)
|
---|
| 107 |
|
---|
| 108 | self._readAircraftType(f)
|
---|
| 109 | self.tailNumber = readline(f)
|
---|
| 110 | self.numPassengers = int(readline(f))
|
---|
| 111 | self.numCrew = int(readline(f))
|
---|
| 112 | self.bagWeight = int(readline(f))
|
---|
| 113 | self.cargoWeight = int(readline(f))
|
---|
| 114 | self.mailWeight = int(readline(f))
|
---|
| 115 | self.route = readline(f)
|
---|
| 116 |
|
---|
| 117 | departureTime = readline(f)
|
---|
[184] | 118 | self.departureTime = BookedFlight.getDateTime(date, departureTime)
|
---|
[443] | 119 |
|
---|
[41] | 120 | arrivalTime = readline(f)
|
---|
[184] | 121 | self.arrivalTime = BookedFlight.getDateTime(date, arrivalTime)
|
---|
[205] | 122 | if self.arrivalTime<self.departureTime:
|
---|
| 123 | self.arrivalTime += datetime.timedelta(days = 1)
|
---|
[41] | 124 |
|
---|
| 125 | if not readline(f)==".NEXT.":
|
---|
| 126 | raise Exception("Invalid line in flight data")
|
---|
| 127 |
|
---|
[184] | 128 | def readFromFile(self, f):
|
---|
| 129 | """Read the data of the flight from a file via the given file
|
---|
| 130 | object."""
|
---|
| 131 | date = None
|
---|
| 132 | departureTime = None
|
---|
| 133 | arrivalTime = None
|
---|
[443] | 134 |
|
---|
[184] | 135 | line = f.readline()
|
---|
[443] | 136 | lineNumber = 0
|
---|
[184] | 137 | while line:
|
---|
| 138 | lineNumber += 1
|
---|
| 139 | line = line.strip()
|
---|
[443] | 140 |
|
---|
[184] | 141 | hashIndex = line.find("#")
|
---|
| 142 | if hashIndex>=0: line = line[:hashIndex]
|
---|
| 143 | if line:
|
---|
| 144 | equalIndex = line.find("=")
|
---|
| 145 | lineOK = equalIndex>0
|
---|
[443] | 146 |
|
---|
[184] | 147 | if lineOK:
|
---|
[443] | 148 | key = line[:equalIndex].strip()
|
---|
[184] | 149 | value = line[equalIndex+1:].strip().replace("\:", ":")
|
---|
[443] | 150 |
|
---|
[184] | 151 | lineOK = key and value
|
---|
| 152 |
|
---|
| 153 | if lineOK:
|
---|
| 154 | if key=="callsign": self.callsign = value
|
---|
| 155 | elif key=="date": date = value
|
---|
| 156 | elif key=="dep_airport": self.departureICAO = value
|
---|
| 157 | elif key=="dest_airport": self.arrivalICAO = value
|
---|
| 158 | elif key=="planecode": self.aircraftType = \
|
---|
| 159 | self._decodeAircraftType(value)
|
---|
[305] | 160 | elif key=="planetype": self.aircraftTypeName = value
|
---|
[184] | 161 | elif key=="tail_nr": self.tailNumber = value
|
---|
| 162 | elif key=="passenger": self.numPassengers = int(value)
|
---|
| 163 | elif key=="crew": self.numCrew = int(value)
|
---|
| 164 | elif key=="bag": self.bagWeight = int(value)
|
---|
| 165 | elif key=="cargo": self.cargoWeight = int(value)
|
---|
| 166 | elif key=="mail": self.mailWeight = int(value)
|
---|
| 167 | elif key=="flight_route": self.route = value
|
---|
| 168 | elif key=="departure_time": departureTime = value
|
---|
| 169 | elif key=="arrival_time": arrivalTime = value
|
---|
[214] | 170 | elif key=="foglalas_id":
|
---|
| 171 | self.id = None if value=="0" else value
|
---|
[184] | 172 | else: lineOK = False
|
---|
| 173 |
|
---|
| 174 | if not lineOK:
|
---|
| 175 | print "web.BookedFlight.readFromFile: line %d is invalid" % \
|
---|
| 176 | (lineNumber,)
|
---|
| 177 |
|
---|
| 178 | line = f.readline()
|
---|
| 179 |
|
---|
| 180 | if date is not None:
|
---|
| 181 | if departureTime is not None:
|
---|
| 182 | self.departureTime = BookedFlight.getDateTime(date,
|
---|
| 183 | departureTime)
|
---|
| 184 | if arrivalTime is not None:
|
---|
| 185 | self.arrivalTime = BookedFlight.getDateTime(date,
|
---|
| 186 | arrivalTime)
|
---|
| 187 |
|
---|
| 188 | d = dir(self)
|
---|
| 189 | for attribute in ["callsign", "departureICAO", "arrivalICAO",
|
---|
| 190 | "aircraftType", "tailNumber",
|
---|
| 191 | "numPassengers", "numCrew",
|
---|
| 192 | "bagWeight", "cargoWeight", "mailWeight",
|
---|
| 193 | "route", "departureTime", "arrivalTime"]:
|
---|
| 194 | if attribute not in d:
|
---|
| 195 | raise Exception("Attribute %s could not be read" % (attribute,))
|
---|
[305] | 196 |
|
---|
| 197 | if "aircraftTypeName" not in d:
|
---|
| 198 | self.aircraftTypeName = \
|
---|
| 199 | BookedFlight.TYPE2TYPECODE[self.aircraftType]
|
---|
[443] | 200 |
|
---|
[214] | 201 | def writeIntoFile(self, f):
|
---|
| 202 | """Write the flight into a file."""
|
---|
| 203 | print >> f, "callsign=%s" % (self.callsign,)
|
---|
| 204 | date = self.departureTime.date()
|
---|
| 205 | print >> f, "date=%04d-%02d-%0d" % (date.year, date.month, date.day)
|
---|
| 206 | print >> f, "dep_airport=%s" % (self.departureICAO,)
|
---|
| 207 | print >> f, "dest_airport=%s" % (self.arrivalICAO,)
|
---|
| 208 | print >> f, "planecode=%s" % \
|
---|
| 209 | (BookedFlight.TYPE2TYPECODE[self.aircraftType],)
|
---|
[305] | 210 | print >> f, "planetype=%s" % (self.aircraftTypeName,)
|
---|
[214] | 211 | print >> f, "tail_nr=%s" % (self.tailNumber,)
|
---|
| 212 | print >> f, "passenger=%d" % (self.numPassengers,)
|
---|
| 213 | print >> f, "crew=%d" % (self.numCrew,)
|
---|
| 214 | print >> f, "bag=%d" % (self.bagWeight,)
|
---|
| 215 | print >> f, "cargo=%d" % (self.cargoWeight,)
|
---|
| 216 | print >> f, "mail=%d" % (self.mailWeight,)
|
---|
| 217 | print >> f, "flight_route=%s" % (self.route,)
|
---|
| 218 | departureTime = self.departureTime
|
---|
| 219 | print >> f, "departure_time=%02d\\:%02d\\:%02d" % \
|
---|
| 220 | (departureTime.hour, departureTime.minute, departureTime.second)
|
---|
| 221 | arrivalTime = self.arrivalTime
|
---|
| 222 | print >> f, "arrival_time=%02d\\:%02d\\:%02d" % \
|
---|
| 223 | (arrivalTime.hour, arrivalTime.minute, arrivalTime.second)
|
---|
| 224 | print >> f, "foglalas_id=%s" % ("0" if self.id is None else self.id,)
|
---|
| 225 |
|
---|
[41] | 226 | def _readAircraftType(self, f):
|
---|
| 227 | """Read the aircraft type from the given file."""
|
---|
| 228 | line = readline(f)
|
---|
| 229 | typeCode = line[:3]
|
---|
[184] | 230 | self.aircraftType = self._decodeAircraftType(typeCode)
|
---|
[305] | 231 | self.aircraftTypeName = line[3:]
|
---|
[184] | 232 |
|
---|
| 233 | def _decodeAircraftType(self, typeCode):
|
---|
| 234 | """Decode the aircraft type from the given typeCode."""
|
---|
[41] | 235 | if typeCode in self.TYPECODE2TYPE:
|
---|
[184] | 236 | return self.TYPECODE2TYPE[typeCode]
|
---|
[41] | 237 | else:
|
---|
| 238 | raise Exception("Invalid aircraft type code: '" + typeCode + "'")
|
---|
[443] | 239 |
|
---|
[41] | 240 | def __repr__(self):
|
---|
| 241 | """Get a representation of the flight."""
|
---|
| 242 | s = "<Flight: %s-%s, %s, %s-%s," % (self.departureICAO,
|
---|
| 243 | self.arrivalICAO,
|
---|
| 244 | self.route,
|
---|
| 245 | self.departureTime, self.arrivalTime)
|
---|
| 246 | s += " %d %s," % (self.aircraftType, self.tailNumber)
|
---|
| 247 | s += " pax=%d, crew=%d, bag=%d, cargo=%d, mail=%d" % \
|
---|
| 248 | (self.numPassengers, self.numCrew,
|
---|
| 249 | self.bagWeight, self.cargoWeight, self.mailWeight)
|
---|
| 250 | s += ">"
|
---|
| 251 | return s
|
---|
[443] | 252 |
|
---|
[41] | 253 | #------------------------------------------------------------------------------
|
---|
| 254 |
|
---|
[51] | 255 | class Plane(object):
|
---|
| 256 | """Information about an airplane in the fleet."""
|
---|
| 257 | def __init__(self, s):
|
---|
| 258 | """Build a plane info based on the given string.
|
---|
| 259 |
|
---|
| 260 | The string consists of three, space-separated fields.
|
---|
| 261 | The first field is the tail number, the second field is the gate
|
---|
| 262 | number, the third field is the plane's status as a character."""
|
---|
| 263 | try:
|
---|
| 264 | words = s.split(" ")
|
---|
| 265 | tailNumber = words[0]
|
---|
| 266 | self.tailNumber = tailNumber
|
---|
| 267 |
|
---|
| 268 | status = words[2] if len(words)>2 else None
|
---|
| 269 | self.status = const.PLANE_HOME if status=="H" else \
|
---|
| 270 | const.PLANE_AWAY if status=="A" else \
|
---|
| 271 | const.PLANE_PARKING if status=="P" else \
|
---|
| 272 | const.PLANE_UNKNOWN
|
---|
| 273 |
|
---|
| 274 | gateNumber = words[1] if len(words)>1 else ""
|
---|
| 275 | self.gateNumber = gateNumber if gateNumber else None
|
---|
| 276 |
|
---|
| 277 | except:
|
---|
| 278 | print >> sys.stderr, "Plane string is invalid: '" + s + "'"
|
---|
| 279 | self.tailNumber = None
|
---|
| 280 |
|
---|
| 281 | def __repr__(self):
|
---|
| 282 | """Get the representation of the plane object."""
|
---|
[443] | 283 | s = "<Plane: %s %s" % (self.tailNumber,
|
---|
[51] | 284 | "home" if self.status==const.PLANE_HOME else \
|
---|
| 285 | "away" if self.status==const.PLANE_AWAY else \
|
---|
| 286 | "parking" if self.status==const.PLANE_PARKING \
|
---|
| 287 | else "unknown")
|
---|
| 288 | if self.gateNumber is not None:
|
---|
| 289 | s += " (gate " + self.gateNumber + ")"
|
---|
| 290 | s += ">"
|
---|
| 291 | return s
|
---|
[443] | 292 |
|
---|
[51] | 293 |
|
---|
| 294 | #------------------------------------------------------------------------------
|
---|
| 295 |
|
---|
| 296 | class Fleet(object):
|
---|
| 297 | """Information about the whole fleet."""
|
---|
| 298 | def __init__(self, f):
|
---|
| 299 | """Construct the fleet information by reading the given file object."""
|
---|
| 300 | self._planes = {}
|
---|
| 301 | while True:
|
---|
| 302 | line = readline(f)
|
---|
| 303 | if not line or line == "#END": break
|
---|
| 304 |
|
---|
| 305 | plane = Plane(line)
|
---|
| 306 | if plane.tailNumber is not None:
|
---|
[118] | 307 | self._planes[plane.tailNumber] = plane
|
---|
[51] | 308 |
|
---|
| 309 | def isGateConflicting(self, plane):
|
---|
| 310 | """Check if the gate of the given plane conflicts with another plane's
|
---|
| 311 | position."""
|
---|
| 312 | for p in self._planes.itervalues():
|
---|
| 313 | if p.tailNumber!=plane.tailNumber and \
|
---|
| 314 | p.status==const.PLANE_HOME and \
|
---|
| 315 | p.gateNumber==plane.gateNumber:
|
---|
| 316 | return True
|
---|
| 317 |
|
---|
| 318 | return False
|
---|
| 319 |
|
---|
| 320 | def getOccupiedGateNumbers(self):
|
---|
| 321 | """Get a set containing the numbers of the gates occupied by planes."""
|
---|
| 322 | gateNumbers = set()
|
---|
| 323 | for p in self._planes.itervalues():
|
---|
| 324 | if p.status==const.PLANE_HOME and p.gateNumber:
|
---|
| 325 | gateNumbers.add(p.gateNumber)
|
---|
| 326 | return gateNumbers
|
---|
[443] | 327 |
|
---|
[130] | 328 | def updatePlane(self, tailNumber, status, gateNumber = None):
|
---|
| 329 | """Update the status of the given plane."""
|
---|
| 330 | if tailNumber in self._planes:
|
---|
| 331 | plane = self._planes[tailNumber]
|
---|
| 332 | plane.status = status
|
---|
| 333 | plane.gateNumber = gateNumber
|
---|
[443] | 334 |
|
---|
[118] | 335 | def __iter__(self):
|
---|
| 336 | """Get an iterator over the planes."""
|
---|
| 337 | for plane in self._planes.itervalues():
|
---|
| 338 | yield plane
|
---|
[443] | 339 |
|
---|
[51] | 340 | def __getitem__(self, tailNumber):
|
---|
| 341 | """Get the plane with the given tail number.
|
---|
| 342 |
|
---|
| 343 | If the plane is not in the fleet, None is returned."""
|
---|
| 344 | return self._planes[tailNumber] if tailNumber in self._planes else None
|
---|
| 345 |
|
---|
| 346 | def __repr__(self):
|
---|
| 347 | """Get the representation of the fleet object."""
|
---|
| 348 | return self._planes.__repr__()
|
---|
[443] | 349 |
|
---|
[51] | 350 | #------------------------------------------------------------------------------
|
---|
| 351 |
|
---|
[63] | 352 | class NOTAM(object):
|
---|
| 353 | """A NOTAM for an airport."""
|
---|
| 354 | def __init__(self, begin, notice, end = None, permanent = False,
|
---|
| 355 | repeatCycle = None):
|
---|
| 356 | """Construct the NOTAM."""
|
---|
| 357 | self.begin = begin
|
---|
| 358 | self.notice = notice
|
---|
| 359 | self.end = end
|
---|
| 360 | self.permanent = permanent
|
---|
| 361 | self.repeatCycle = None
|
---|
| 362 |
|
---|
| 363 | def __repr__(self):
|
---|
| 364 | """Get the representation of the NOTAM."""
|
---|
| 365 | s = "<NOTAM " + str(self.begin)
|
---|
| 366 | if self.end:
|
---|
| 367 | s += " - " + str(self.end)
|
---|
| 368 | elif self.permanent:
|
---|
| 369 | s += " - PERMANENT"
|
---|
| 370 | if self.repeatCycle:
|
---|
| 371 | s += " (" + self.repeatCycle + ")"
|
---|
| 372 | s += ": " + self.notice
|
---|
| 373 | s += ">"
|
---|
| 374 | return s
|
---|
[443] | 375 |
|
---|
[63] | 376 | #------------------------------------------------------------------------------
|
---|
| 377 |
|
---|
| 378 | class NOTAMHandler(xml.sax.handler.ContentHandler):
|
---|
| 379 | """A handler for the NOTAM database."""
|
---|
| 380 | def __init__(self, airportICAOs):
|
---|
| 381 | """Construct the handler for the airports with the given ICAO code."""
|
---|
| 382 | self._notams = {}
|
---|
| 383 | for icao in airportICAOs:
|
---|
| 384 | self._notams[icao] = []
|
---|
| 385 |
|
---|
| 386 | def startElement(self, name, attrs):
|
---|
| 387 | """Start an element."""
|
---|
| 388 | if name!="notam" or \
|
---|
| 389 | "A" not in attrs or not attrs["A"] or \
|
---|
| 390 | "B" not in attrs or not attrs["B"] or \
|
---|
| 391 | "E" not in attrs or not attrs["E"]:
|
---|
| 392 | return
|
---|
[443] | 393 |
|
---|
[63] | 394 | icao = attrs["A"]
|
---|
| 395 | if icao not in self._notams:
|
---|
| 396 | return
|
---|
[443] | 397 |
|
---|
[63] | 398 | begin = datetime.datetime.strptime(attrs["B"], "%Y-%m-%d %H:%M:%S")
|
---|
| 399 |
|
---|
| 400 | c = attrs["C"] if "C" in attrs else None
|
---|
| 401 | end = datetime.datetime.strptime(c, "%Y-%m-%d %H:%M:%S") if c else None
|
---|
[443] | 402 |
|
---|
[63] | 403 | permanent = attrs["C_flag"]=="PERM" if "C_flag" in attrs else False
|
---|
[443] | 404 |
|
---|
[63] | 405 | repeatCycle = attrs["D"] if "D" in attrs else None
|
---|
| 406 |
|
---|
| 407 | self._notams[icao].append(NOTAM(begin, attrs["E"], end = end,
|
---|
| 408 | permanent = permanent,
|
---|
| 409 | repeatCycle = repeatCycle))
|
---|
| 410 |
|
---|
| 411 | def get(self, icao):
|
---|
| 412 | """Get the NOTAMs for the given ICAO code."""
|
---|
| 413 | return self._notams[icao] if icao in self._notams else []
|
---|
| 414 |
|
---|
| 415 | #------------------------------------------------------------------------------
|
---|
| 416 |
|
---|
[41] | 417 | class Result(object):
|
---|
| 418 | """A result object.
|
---|
| 419 |
|
---|
| 420 | An instance of this filled with the appropriate data is passed to the
|
---|
| 421 | callback function on each request."""
|
---|
| 422 |
|
---|
| 423 | def __repr__(self):
|
---|
| 424 | """Get a representation of the result."""
|
---|
| 425 | s = "<Result:"
|
---|
| 426 | for (key, value) in self.__dict__.iteritems():
|
---|
| 427 | s += " " + key + "=" + unicode(value)
|
---|
| 428 | s += ">"
|
---|
| 429 | return s
|
---|
| 430 |
|
---|
| 431 | #------------------------------------------------------------------------------
|
---|
| 432 |
|
---|
| 433 | class Request(object):
|
---|
| 434 | """Base class for requests.
|
---|
| 435 |
|
---|
| 436 | It handles any exceptions and the calling of the callback.
|
---|
| 437 |
|
---|
| 438 | If an exception occurs during processing, the callback is called with
|
---|
| 439 | the two parameters: a boolean value of False, and the exception object.
|
---|
| 440 |
|
---|
| 441 | If no exception occurs, the callback is called with True and the return
|
---|
| 442 | value of the run() function.
|
---|
| 443 |
|
---|
| 444 | If the callback function throws an exception, that is caught and logged
|
---|
| 445 | to the debug log."""
|
---|
| 446 | def __init__(self, callback):
|
---|
| 447 | """Construct the request."""
|
---|
| 448 | self._callback = callback
|
---|
| 449 |
|
---|
| 450 | def perform(self):
|
---|
| 451 | """Perform the request.
|
---|
| 452 |
|
---|
| 453 | The object's run() function is called. If it throws an exception,
|
---|
| 454 | the callback is called with False, and the exception. Otherwise the
|
---|
| 455 | callback is called with True and the return value of the run()
|
---|
| 456 | function. Any exceptions thrown by the callback are caught and
|
---|
| 457 | reported."""
|
---|
| 458 | try:
|
---|
| 459 | result = self.run()
|
---|
| 460 | returned = True
|
---|
| 461 | except Exception, e:
|
---|
[106] | 462 | traceback.print_exc()
|
---|
[41] | 463 | result = e
|
---|
| 464 | returned = False
|
---|
| 465 |
|
---|
| 466 | try:
|
---|
| 467 | self._callback(returned, result)
|
---|
| 468 | except Exception, e:
|
---|
[401] | 469 | print >> sys.stderr, "web.Handler.Request.perform: callback throwed an exception: " + util.utf2unicode(str(e))
|
---|
[106] | 470 | traceback.print_exc()
|
---|
[41] | 471 |
|
---|
| 472 | #------------------------------------------------------------------------------
|
---|
| 473 |
|
---|
| 474 | class Login(Request):
|
---|
| 475 | """A login request."""
|
---|
| 476 | iso88592decoder = codecs.getdecoder("iso-8859-2")
|
---|
[443] | 477 |
|
---|
[184] | 478 | def __init__(self, callback, pilotID, password, entranceExam):
|
---|
[41] | 479 | """Construct the login request with the given pilot ID and
|
---|
| 480 | password."""
|
---|
| 481 | super(Login, self).__init__(callback)
|
---|
| 482 |
|
---|
| 483 | self._pilotID = pilotID
|
---|
| 484 | self._password = password
|
---|
[184] | 485 | self._entranceExam = entranceExam
|
---|
[41] | 486 |
|
---|
| 487 | def run(self):
|
---|
| 488 | """Perform the login request."""
|
---|
| 489 | md5 = hashlib.md5()
|
---|
| 490 | md5.update(self._pilotID)
|
---|
| 491 | pilotID = md5.hexdigest()
|
---|
[443] | 492 |
|
---|
[41] | 493 | md5 = hashlib.md5()
|
---|
| 494 | md5.update(self._password)
|
---|
| 495 | password = md5.hexdigest()
|
---|
| 496 |
|
---|
[184] | 497 | if self._entranceExam:
|
---|
| 498 | url = "http://www.virtualairlines.hu/ellenorzo/getflightplan.php?pid=%s" % \
|
---|
| 499 | (pilotID,)
|
---|
| 500 | else:
|
---|
| 501 | url = "http://www.virtualairlines.hu/leker2.php?pid=%s&psw=%s" % \
|
---|
| 502 | (pilotID, password)
|
---|
[41] | 503 |
|
---|
| 504 | result = Result()
|
---|
[184] | 505 | result.entranceExam = self._entranceExam
|
---|
[41] | 506 |
|
---|
[88] | 507 | f = urllib2.urlopen(url, timeout = 10.0)
|
---|
[41] | 508 |
|
---|
| 509 | status = readline(f)
|
---|
[184] | 510 | if self._entranceExam:
|
---|
| 511 | result.loggedIn = status != "#NOEXAM"
|
---|
| 512 | else:
|
---|
| 513 | result.loggedIn = status == ".OK."
|
---|
[41] | 514 |
|
---|
| 515 | if result.loggedIn:
|
---|
[151] | 516 | result.pilotID = self._pilotID
|
---|
[208] | 517 | result.password = self._password
|
---|
[41] | 518 | result.flights = []
|
---|
[184] | 519 | # FIXME: this may not be the correct behaviour
|
---|
| 520 | # for an entrance exam, but the website returns
|
---|
| 521 | # an error
|
---|
| 522 | if self._entranceExam:
|
---|
| 523 | result.pilotName = result.pilotID
|
---|
| 524 | result.exams = ""
|
---|
| 525 | else:
|
---|
| 526 | result.pilotName = self.iso88592decoder(readline(f))[0]
|
---|
| 527 | result.exams = readline(f)
|
---|
[443] | 528 |
|
---|
[184] | 529 | while True:
|
---|
| 530 | line = readline(f)
|
---|
| 531 | if not line or line == "#ENDPIREP": break
|
---|
[41] | 532 |
|
---|
[184] | 533 | flight = BookedFlight(line)
|
---|
| 534 | flight.readFromWeb(f)
|
---|
| 535 | result.flights.append(flight)
|
---|
[41] | 536 |
|
---|
[48] | 537 | result.flights.sort(cmp = lambda flight1, flight2:
|
---|
| 538 | cmp(flight1.departureTime,
|
---|
| 539 | flight2.departureTime))
|
---|
| 540 |
|
---|
[51] | 541 | f.close()
|
---|
| 542 |
|
---|
[41] | 543 | return result
|
---|
[443] | 544 |
|
---|
[41] | 545 | #------------------------------------------------------------------------------
|
---|
| 546 |
|
---|
[51] | 547 | class GetFleet(Request):
|
---|
| 548 | """Request to get the fleet from the website."""
|
---|
[443] | 549 |
|
---|
[51] | 550 | def __init__(self, callback):
|
---|
| 551 | """Construct the fleet request."""
|
---|
| 552 | super(GetFleet, self).__init__(callback)
|
---|
| 553 |
|
---|
| 554 | def run(self):
|
---|
| 555 | """Perform the login request."""
|
---|
| 556 | url = "http://www.virtualairlines.hu/onlinegates_get.php"
|
---|
| 557 |
|
---|
[88] | 558 | f = urllib2.urlopen(url, timeout = 10.0)
|
---|
[51] | 559 | result = Result()
|
---|
| 560 | result.fleet = Fleet(f)
|
---|
| 561 | f.close()
|
---|
[443] | 562 |
|
---|
[51] | 563 | return result
|
---|
| 564 |
|
---|
| 565 | #------------------------------------------------------------------------------
|
---|
| 566 |
|
---|
| 567 | class UpdatePlane(Request):
|
---|
| 568 | """Update the status of one of the planes in the fleet."""
|
---|
| 569 | def __init__(self, callback, tailNumber, status, gateNumber = None):
|
---|
| 570 | """Construct the request."""
|
---|
| 571 | super(UpdatePlane, self).__init__(callback)
|
---|
| 572 | self._tailNumber = tailNumber
|
---|
| 573 | self._status = status
|
---|
| 574 | self._gateNumber = gateNumber
|
---|
| 575 |
|
---|
| 576 | def run(self):
|
---|
| 577 | """Perform the plane update."""
|
---|
| 578 | url = "http://www.virtualairlines.hu/onlinegates_set.php"
|
---|
| 579 |
|
---|
| 580 | status = "H" if self._status==const.PLANE_HOME else \
|
---|
| 581 | "A" if self._status==const.PLANE_AWAY else \
|
---|
| 582 | "P" if self._status==const.PLANE_PARKING else ""
|
---|
| 583 |
|
---|
| 584 | gateNumber = self._gateNumber if self._gateNumber else ""
|
---|
| 585 |
|
---|
| 586 | data = urllib.urlencode([("lajstrom", self._tailNumber),
|
---|
| 587 | ("status", status),
|
---|
| 588 | ("kapu", gateNumber)])
|
---|
[443] | 589 |
|
---|
[88] | 590 | f = urllib2.urlopen(url, data, timeout = 10.0)
|
---|
[51] | 591 | line = readline(f)
|
---|
[443] | 592 |
|
---|
[51] | 593 | result = Result()
|
---|
| 594 | result.success = line == "OK"
|
---|
| 595 |
|
---|
| 596 | return result
|
---|
[443] | 597 |
|
---|
[51] | 598 | #------------------------------------------------------------------------------
|
---|
| 599 |
|
---|
[63] | 600 | class GetNOTAMs(Request):
|
---|
| 601 | """Get the NOTAMs from EURoutePro and select the ones we are interested
|
---|
| 602 | in."""
|
---|
| 603 | def __init__(self, callback, departureICAO, arrivalICAO):
|
---|
| 604 | """Construct the request for the given airports."""
|
---|
| 605 | super(GetNOTAMs, self).__init__(callback)
|
---|
| 606 | self._departureICAO = departureICAO
|
---|
| 607 | self._arrivalICAO = arrivalICAO
|
---|
| 608 |
|
---|
| 609 | def run(self):
|
---|
[66] | 610 | """Perform the retrieval of the NOTAMs."""
|
---|
[63] | 611 | xmlParser = xml.sax.make_parser()
|
---|
| 612 | notamHandler = NOTAMHandler([self._departureICAO, self._arrivalICAO])
|
---|
| 613 | xmlParser.setContentHandler(notamHandler)
|
---|
| 614 |
|
---|
| 615 | url = "http://notams.euroutepro.com/notams.xml"
|
---|
| 616 |
|
---|
[88] | 617 | f = urllib2.urlopen(url, timeout = 10.0)
|
---|
[63] | 618 | try:
|
---|
| 619 | xmlParser.parse(f)
|
---|
| 620 | finally:
|
---|
| 621 | f.close()
|
---|
| 622 |
|
---|
| 623 | result = Result()
|
---|
| 624 | result.departureNOTAMs = notamHandler.get(self._departureICAO)
|
---|
| 625 | result.arrivalNOTAMs = notamHandler.get(self._arrivalICAO)
|
---|
| 626 |
|
---|
| 627 | return result
|
---|
| 628 |
|
---|
| 629 | #------------------------------------------------------------------------------
|
---|
| 630 |
|
---|
[66] | 631 | class GetMETARs(Request):
|
---|
[443] | 632 | """Get the METARs from the NOAA website for certain airport ICAOs."""
|
---|
[66] | 633 |
|
---|
| 634 | def __init__(self, callback, airports):
|
---|
| 635 | """Construct the request for the given airports."""
|
---|
| 636 | super(GetMETARs, self).__init__(callback)
|
---|
| 637 | self._airports = airports
|
---|
| 638 |
|
---|
| 639 | def run(self):
|
---|
| 640 | """Perform the retrieval opf the METARs."""
|
---|
[74] | 641 | url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?"
|
---|
| 642 | data = urllib.urlencode([ ("dataSource" , "metars"),
|
---|
[443] | 643 | ("requestType", "retrieve"),
|
---|
[74] | 644 | ("format", "csv"),
|
---|
| 645 | ("stationString", " ".join(self._airports)),
|
---|
| 646 | ("hoursBeforeNow", "24"),
|
---|
| 647 | ("mostRecentForEachStation", "constraint")])
|
---|
| 648 | url += data
|
---|
[88] | 649 | f = urllib2.urlopen(url, timeout = 10.0)
|
---|
[66] | 650 | try:
|
---|
| 651 | result = Result()
|
---|
| 652 | result.metars = {}
|
---|
| 653 | for line in iter(f.readline, ""):
|
---|
| 654 | if len(line)>5 and line[4]==' ':
|
---|
| 655 | icao = line[0:4]
|
---|
[443] | 656 | if icao in self._airports:
|
---|
[74] | 657 | result.metars[icao] = line.strip().split(",")[0]
|
---|
[66] | 658 | finally:
|
---|
| 659 | f.close()
|
---|
| 660 |
|
---|
| 661 | return result
|
---|
| 662 |
|
---|
| 663 | #------------------------------------------------------------------------------
|
---|
| 664 |
|
---|
[97] | 665 | class SendPIREP(Request):
|
---|
| 666 | """A request to send a PIREP to the MAVA website."""
|
---|
| 667 | _flightTypes = { const.FLIGHTTYPE_SCHEDULED : "SCHEDULED",
|
---|
| 668 | const.FLIGHTTYPE_OLDTIMER : "OT",
|
---|
| 669 | const.FLIGHTTYPE_VIP : "VIP",
|
---|
| 670 | const.FLIGHTTYPE_CHARTER : "CHARTER" }
|
---|
| 671 |
|
---|
| 672 | _latin2Encoder = codecs.getencoder("iso-8859-2")
|
---|
| 673 |
|
---|
| 674 | def __init__(self, callback, pirep):
|
---|
[312] | 675 | """Construct the sending of the PIREP."""
|
---|
[97] | 676 | super(SendPIREP, self).__init__(callback)
|
---|
| 677 | self._pirep = pirep
|
---|
| 678 |
|
---|
| 679 | def run(self):
|
---|
[326] | 680 | """Perform the sending of the PIREP."""
|
---|
[97] | 681 | url = "http://www.virtualairlines.hu/malevacars.php"
|
---|
[326] | 682 | #url = "http://localhost:15000"
|
---|
[97] | 683 |
|
---|
| 684 | pirep = self._pirep
|
---|
| 685 |
|
---|
| 686 | data = {}
|
---|
[326] | 687 | data["acarsdata"] = SendPIREP._latin2Encoder(pirep.getACARSText())[0]
|
---|
[97] | 688 |
|
---|
| 689 | bookedFlight = pirep.bookedFlight
|
---|
| 690 | data["foglalas_id"] = bookedFlight.id
|
---|
| 691 | data["repdate"] = bookedFlight.departureTime.date().strftime("%Y-%m-%d")
|
---|
| 692 | data["fltnum"] = bookedFlight.callsign
|
---|
| 693 | data["depap"] = bookedFlight.departureICAO
|
---|
| 694 | data["arrap"] = bookedFlight.arrivalICAO
|
---|
[303] | 695 | data["pass"] = str(pirep.numPassengers)
|
---|
| 696 | data["crew"] = str(pirep.numCrew)
|
---|
[97] | 697 | data["cargo"] = str(pirep.cargoWeight)
|
---|
[303] | 698 | data["bag"] = str(pirep.bagWeight)
|
---|
| 699 | data["mail"] = str(pirep.mailWeight)
|
---|
[443] | 700 |
|
---|
[97] | 701 | data["flttype"] = SendPIREP._flightTypes[pirep.flightType]
|
---|
| 702 | data["onoff"] = "1" if pirep.online else "0"
|
---|
| 703 | data["bt_dep"] = util.getTimestampString(pirep.blockTimeStart)
|
---|
| 704 | data["bt_arr"] = util.getTimestampString(pirep.blockTimeEnd)
|
---|
| 705 | data["bt_dur"] = util.getTimeIntervalString(pirep.blockTimeEnd -
|
---|
| 706 | pirep.blockTimeStart)
|
---|
| 707 | data["ft_dep"] = util.getTimestampString(pirep.flightTimeStart)
|
---|
| 708 | data["ft_arr"] = util.getTimestampString(pirep.flightTimeEnd)
|
---|
| 709 | data["ft_dur"] = util.getTimeIntervalString(pirep.flightTimeEnd -
|
---|
| 710 | pirep.flightTimeStart)
|
---|
| 711 | data["timecomm"] = pirep.getTimeComment()
|
---|
[313] | 712 | data["fuel"] = "%.2f" % (pirep.fuelUsed,)
|
---|
[97] | 713 | data["dep_rwy"] = pirep.departureRunway
|
---|
| 714 | data["arr_rwy"] = pirep.arrivalRunway
|
---|
| 715 | data["wea_dep"] = pirep.departureMETAR
|
---|
| 716 | data["wea_arr"] = pirep.arrivalMETAR
|
---|
| 717 | data["alt"] = "FL%.0f" % (pirep.filedCruiseAltitude/100.0,)
|
---|
| 718 | if pirep.filedCruiseAltitude!=pirep.cruiseAltitude:
|
---|
| 719 | data["mod_alt"] = "FL%.0f" % (pirep.cruiseAltitude/100.0,)
|
---|
| 720 | else:
|
---|
| 721 | data["mod_alt"] = ""
|
---|
| 722 | data["sid"] = pirep.sid
|
---|
| 723 | data["navroute"] = pirep.route
|
---|
| 724 | data["star"] = pirep.getSTAR()
|
---|
| 725 | data["aprtype"] = pirep.approachType
|
---|
| 726 | data["diff"] = "2"
|
---|
| 727 | data["comment"] = SendPIREP._latin2Encoder(pirep.comments)[0]
|
---|
| 728 | data["flightdefect"] = SendPIREP._latin2Encoder(pirep.flightDefects)[0]
|
---|
| 729 | data["kritika"] = pirep.getRatingText()
|
---|
[104] | 730 | data["flightrating"] = "%.1f" % (max(0.0, pirep.rating),)
|
---|
[97] | 731 | data["distance"] = "%.3f" % (pirep.flownDistance,)
|
---|
| 732 | data["insdate"] = datetime.date.today().strftime("%Y-%m-%d")
|
---|
| 733 |
|
---|
[326] | 734 | postData = urllib.urlencode(data)
|
---|
| 735 | f = urllib2.urlopen(url, postData, timeout = 10.0)
|
---|
[97] | 736 | try:
|
---|
| 737 | result = Result()
|
---|
| 738 | line = f.readline().strip()
|
---|
| 739 | print "PIREP result from website:", line
|
---|
| 740 | result.success = line=="OK"
|
---|
| 741 | result.alreadyFlown = line=="MARVOLT"
|
---|
| 742 | result.notAvailable = line=="NOMORE"
|
---|
| 743 | finally:
|
---|
| 744 | f.close()
|
---|
| 745 |
|
---|
[443] | 746 | return result
|
---|
[139] | 747 | #------------------------------------------------------------------------------
|
---|
| 748 |
|
---|
| 749 | class SendACARS(Request):
|
---|
| 750 | """A request to send an ACARS to the MAVA website."""
|
---|
| 751 | _latin2Encoder = codecs.getencoder("iso-8859-2")
|
---|
| 752 |
|
---|
| 753 | def __init__(self, callback, acars):
|
---|
| 754 | """Construct the request for the given PIREP."""
|
---|
| 755 | super(SendACARS, self).__init__(callback)
|
---|
| 756 | self._acars = acars
|
---|
| 757 |
|
---|
| 758 | def run(self):
|
---|
| 759 | """Perform the sending of the ACARS."""
|
---|
[203] | 760 | print "Sending the online ACARS"
|
---|
[443] | 761 |
|
---|
[139] | 762 | url = "http://www.virtualairlines.hu/acars2/acarsonline.php"
|
---|
| 763 |
|
---|
| 764 | acars = self._acars
|
---|
| 765 | bookedFlight = acars.bookedFlight
|
---|
| 766 |
|
---|
| 767 | data = {}
|
---|
| 768 | data["pid"] = acars.pid
|
---|
| 769 | data["pilot"] = SendACARS._latin2Encoder(acars.pilotName)[0]
|
---|
[443] | 770 |
|
---|
[139] | 771 | data["pass"] = str(bookedFlight.numPassengers)
|
---|
| 772 | data["callsign"] = bookedFlight.callsign
|
---|
[305] | 773 | data["airplane"] = bookedFlight.aircraftTypeName
|
---|
[139] | 774 | data["from"] = bookedFlight.departureICAO
|
---|
[443] | 775 | data["to"] = bookedFlight.arrivalICAO
|
---|
[139] | 776 | data["lajstrom"] = bookedFlight.tailNumber
|
---|
| 777 |
|
---|
| 778 | data["block_time"] = acars.getBlockTimeText()
|
---|
| 779 | data["longitude"] = str(acars.state.longitude)
|
---|
| 780 | data["latitude"] = str(acars.state.latitude)
|
---|
| 781 | data["altitude"] = str(acars.state.altitude)
|
---|
| 782 | data["speed"] = str(acars.state.groundSpeed)
|
---|
[443] | 783 |
|
---|
[139] | 784 | data["event"] = acars.getEventText()
|
---|
| 785 |
|
---|
| 786 | f = urllib2.urlopen(url, urllib.urlencode(data), timeout = 10.0)
|
---|
| 787 | try:
|
---|
| 788 | result = Result()
|
---|
| 789 | finally:
|
---|
| 790 | f.close()
|
---|
| 791 |
|
---|
[443] | 792 | return result
|
---|
[139] | 793 |
|
---|
| 794 | #------------------------------------------------------------------------------
|
---|
| 795 |
|
---|
[41] | 796 | class Handler(threading.Thread):
|
---|
| 797 | """The handler for the web services.
|
---|
| 798 |
|
---|
| 799 | It can process one request at a time. The results are passed to a callback
|
---|
| 800 | function."""
|
---|
| 801 | def __init__(self):
|
---|
| 802 | """Construct the handler."""
|
---|
| 803 | super(Handler, self).__init__()
|
---|
| 804 |
|
---|
| 805 | self._requests = []
|
---|
| 806 | self._requestCondition = threading.Condition()
|
---|
| 807 |
|
---|
| 808 | self.daemon = True
|
---|
| 809 |
|
---|
[184] | 810 | def login(self, callback, pilotID, password, entranceExam = False):
|
---|
[41] | 811 | """Enqueue a login request."""
|
---|
[184] | 812 | self._addRequest(Login(callback, pilotID, password, entranceExam))
|
---|
[41] | 813 |
|
---|
[51] | 814 | def getFleet(self, callback):
|
---|
| 815 | """Enqueue a fleet retrieval request."""
|
---|
| 816 | self._addRequest(GetFleet(callback))
|
---|
[443] | 817 |
|
---|
[51] | 818 | def updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
[443] | 819 | """Update the status of the given plane."""
|
---|
[51] | 820 | self._addRequest(UpdatePlane(callback, tailNumber, status, gateNumber))
|
---|
[63] | 821 |
|
---|
| 822 | def getNOTAMs(self, callback, departureICAO, arrivalICAO):
|
---|
| 823 | """Get the NOTAMs for the given two airports."""
|
---|
| 824 | self._addRequest(GetNOTAMs(callback, departureICAO, arrivalICAO))
|
---|
[443] | 825 |
|
---|
[66] | 826 | def getMETARs(self, callback, airports):
|
---|
| 827 | """Get the METARs for the given airports."""
|
---|
| 828 | self._addRequest(GetMETARs(callback, airports))
|
---|
[97] | 829 |
|
---|
| 830 | def sendPIREP(self, callback, pirep):
|
---|
| 831 | """Send the given PIREP."""
|
---|
| 832 | self._addRequest(SendPIREP(callback, pirep))
|
---|
[139] | 833 |
|
---|
| 834 | def sendACARS(self, callback, acars):
|
---|
| 835 | """Send the given ACARS"""
|
---|
| 836 | self._addRequest(SendACARS(callback, acars))
|
---|
[443] | 837 |
|
---|
[41] | 838 | def run(self):
|
---|
| 839 | """Process the requests."""
|
---|
| 840 | while True:
|
---|
| 841 | with self._requestCondition:
|
---|
| 842 | while not self._requests:
|
---|
| 843 | self._requestCondition.wait()
|
---|
| 844 | request = self._requests[0]
|
---|
| 845 | del self._requests[0]
|
---|
| 846 |
|
---|
| 847 | request.perform()
|
---|
[443] | 848 |
|
---|
[41] | 849 | def _addRequest(self, request):
|
---|
| 850 | """Add the given request to the queue."""
|
---|
| 851 | with self._requestCondition:
|
---|
| 852 | self._requests.append(request)
|
---|
| 853 | self._requestCondition.notify()
|
---|
| 854 |
|
---|
| 855 | #------------------------------------------------------------------------------
|
---|
| 856 |
|
---|
| 857 | if __name__ == "__main__":
|
---|
| 858 | import time
|
---|
[443] | 859 |
|
---|
[41] | 860 | def callback(returned, result):
|
---|
| 861 | print returned, unicode(result)
|
---|
[443] | 862 |
|
---|
[41] | 863 | handler = Handler()
|
---|
| 864 | handler.start()
|
---|
| 865 |
|
---|
[51] | 866 | #handler.login(callback, "P096", "V5fwj")
|
---|
| 867 | #handler.getFleet(callback)
|
---|
| 868 | # Plane: HA-LEG home (gate 67)
|
---|
[63] | 869 | #handler.updatePlane(callback, "HA-LQC", const.PLANE_AWAY, "72")
|
---|
[443] | 870 | #time.sleep(3)
|
---|
[63] | 871 | #handler.getFleet(callback)
|
---|
| 872 | #time.sleep(3)
|
---|
| 873 |
|
---|
[66] | 874 | #handler.getNOTAMs(callback, "LHBP", "EPWA")
|
---|
[204] | 875 | #handler.getMETARs(callback, ["LHBP", "EPWA"])
|
---|
| 876 | #time.sleep(5)
|
---|
[443] | 877 |
|
---|
[204] | 878 | handler.updatePlane(callback, "HA-LON", const.PLANE_AWAY, "")
|
---|
[443] | 879 | time.sleep(3)
|
---|
[41] | 880 |
|
---|
| 881 | #------------------------------------------------------------------------------
|
---|