def __init__( self, kw=None, start=None, end=None, events=None, group=[], f=[], missingaircraft=False ): """Search for flights on the server. Only flights matching ALL of the specified criteria are returned. :param kw: search keywords. Can be (portions of) aircraft identifier, names of events found by analysis, part of the headline, airport identifiers, etc... :param start: start boundary of the search, in UTC :param end: end boundary of the search, in UTC :param f: sequence of integer flight IDs. If given, the search will be restricted to flights with those IDs :param missingaircraft: if True, only flights which are not registered to any aircraft will be returned :param group: sequence of group names (strings) which the flights must be members of :param events: if False, None, or not specified, abbreviated flight information without events is returned. If True, flights are returned including events. Otherwise, a string which is a comma-separated list of ranges of event severities to count. The events in each range of severities are counted separately and returned in a special <event_counts> tag. For example, "30..39,.." (used at the time of writing by the Wi-Flight flight browser at https://www.wi-flight.net/flight/ ) produces two event counts: one count of events with severities between 30 and 39, and the other counts all events (unbounded range). """ p = [] if kw: p.append(('kw', kw)) if start: p.append(('start', _encode_iso8601(start))) if end: p.append(('end', _encode_iso8601(end))) if missingaircraft: p.append(('missingaircraft', '1')) for g in group: p.append(('group', g)) for f1 in f: p.append(('f', int(f1))) if events is True: p.append(('events', 'true')) elif events is not False and events is not None: p.append(('events', events)) if p: APIObject.__init__(self, 'a', 'flight', '', query_string=urllib.urlencode(p)) else: APIObject.__init__(self, 'a', 'flight', '')
def __init__(self, query): """Search for CrewDb entries by keyword on the server. :param query: should be a keyword search string. It is directly interpreted by the server. It is required. """ APIObject.__init__(self, 'a', 'crewdb', query_string=urllib.urlencode({ 'q': query }))
def __init__(self, fleetname, username): # Note that even though users are contained inside fleets, # not the other way around, and URL components are usually # expected to be more or less big endian, in this case the # username comes first. This is done to make it consistent # with the URL a/crewdb/username (no fleet) that searches # for a given username in any fleet APIObject.__init__(self, 'a', 'crewdb', username, fleetname) self.username = username self.fleet = fleetname
def __init__(self, query): """Search for aircraft by keyword on the server. :param query: should be a keyword search string. It is direcrlt interpreted by the server. If None, all aircraft for which the client has permission will be returned. """ if query is None: APIObject.__init__(self, 'a', 'aircraft', '') else: APIObject.__init__(self, 'a', 'aircraft', '', query_string=urllib.urlencode({ 'search': query }))
def __init__(self, aircraft_id): """Aircraft may be referenced either by numeric ID or by tail number. The numeric ID should be used if available since it is the primary key and cannot be changed. However, new aircraft can only be referenced by tail number (as an ID does not yet exist for them). If :param aircraft_id: is a string, the aircraft will be referenced by tail number. Otherwise it will be referenced by numeric ID. """ if isinstance(aircraft_id, basestring): APIObject.__init__(self, 'a', 'aircraft', 'tail', aircraft_id) self.body.set('tail', aircraft_id) else: APIObject.__init__(self, 'a', 'aircraft', str(aircraft_id)) self.body.set('id', str(aircraft_id))
def __init__(self, api_flight, offset=0, length=None): """Initialize query for flight track data. :param offset: Offset in seconds from start of flight :param length: Length in seconds of list to download The server limits the length to 10 minutes, so multiple queries are almost always necessary to download a whole flight. """ if not isinstance(api_flight, APIFlight): raise TypeError("APIFlightTrack only works on APIFlight") p = [] if offset is not None and offset != 0: p.append(('offset', str(offset))) if length is not None: p.append(('length', str(length))) urlparts = list(api_flight.urlparts) # Replace the last component which should be the empty string urlparts[-1] = 'track' if p: APIObject.__init__(self, *urlparts, query_string=urllib.urlencode(p)) else: APIObject.__init__(self, *urlparts)
def __init__(self, reservation_name): APIObject.__init__(self, 'a', 'reservation', reservation_name) self.body.set('name', reservation_name) self.body.append(lxml.etree.Element('crew'))
def __init__(self, fleetname): APIObject.__init__(self, 'a', 'fleet', fleetname) self.body.set('name', fleetname)
def __init__(self, username): """Search for CrewDb entries by username on the server. """ APIObject.__init__(self, 'a', 'crewdb', username)
def __init__(self, flight_id): APIObject.__init__(self, 'a', 'flight', str(flight_id), '') self.body.set('id', str(flight_id))
def __init__(self, api_aircraft): """Produce aircraft image given aircraft instance""" if not isinstance(api_aircraft, APIAircraft): raise TypeError("APIAircraftImage only works on APIAircraft") urlparts = list(api_aircraft.urlparts) + ['image'] APIObject.__init__(self, *urlparts)