os.chdir(config.directory) update(config.url, config.flightdata) flights = scraper.load(config.flightdata) archives = scraper.load(config.archivedata) numflights = 0 unknown = 0 capacity = 0 passengers = 0 for flight in flights[:]: # if the flight's arrival time is at most config.interval seconds ago and less than now if int(time.time()) - config.interval < flight.arrival and flight.arrival < int(time.time()): numflights += 1 flightcap = flightmod.findSeats(flight) if flightcap != None: capacity += flightcap passengers += config.ratio(flight) * flightcap else: unknown += 1 # if the flight is old enough to be archived elif flight.arrival < int(time.time()) - config.archiveage: archives.append(flight) flights.remove(flight) scraper.save(flights, config.flightdata) scraper.save(archives, config.archivedata) if numflights != 0 and numflights != unknown: capacity = int(capacity * numflights / (numflights - unknown))
update(config.url, config.flightdata) flights = scraper.load(config.flightdata) archives = scraper.load(config.archivedata) numflights = 0 unknown = 0 passengers = 0 for flight in flights[:]: # if the flight's arrival time is at most config.interval seconds ago and less than now if int(time.time() ) - config.interval < flight.arrival and flight.arrival < int( time.time()): numflights += 1 flightpass = flightmod.findSeats(flight) if flightpass != None: passengers += flightpass else: unknown += 1 # if the flight is old enough to be archived elif flight.arrival < int(time.time()) - config.archiveage: archives.append(flight) flights.remove(flight) scraper.save(flights, config.flightdata) scraper.save(archives, config.archivedata) print "\nSince " + time.ctime(time.time() - config.interval) + ", "\ + str(numflights) + " airplanes have entered Marco Polo Airport. Of those flights, "\ + str(numflights - unknown) + " carried a total of " + str(passengers)\
os.chdir(config.directory) update(config.url, config.flightdata) flights = scraper.load(config.flightdata) archives = scraper.load(config.archivedata) numflights = 0 unknown = 0 passengers = 0 for flight in flights[:]: # if the flight's arrival time is at most config.interval seconds ago and less than now if int(time.time()) - config.interval < flight.arrival and flight.arrival < int(time.time()): numflights += 1 flightpass = flightmod.findSeats(flight) if flightpass != None: passengers += flightpass else: unknown += 1 # if the flight is old enough to be archived elif flight.arrival < int(time.time()) - config.archiveage: archives.append(flight) flights.remove(flight) scraper.save(flights, config.flightdata) scraper.save(archives, config.archivedata) print "\nSince " + time.ctime(time.time() - config.interval) + ", "\ + str(numflights) + " airplanes have entered Marco Polo Airport. Of those flights, "\ + str(numflights - unknown) + " carried a total of " + str(passengers)\
update(config.url, config.flightdata) flights = scraper.load(config.flightdata) archives = scraper.load(config.archivedata) numflights = 0 unknown = 0 capacity = 0 passengers = 0 for flight in flights[:]: # if the flight's arrival time is at most config.interval seconds ago and less than now if int(time.time() ) - config.interval < flight.arrival and flight.arrival < int( time.time()): numflights += 1 flightcap = flightmod.findSeats(flight) if flightcap != None: capacity += flightcap passengers += config.ratio(flight) * flightcap else: unknown += 1 # if the flight is old enough to be archived elif flight.arrival < int(time.time()) - config.archiveage: archives.append(flight) flights.remove(flight) scraper.save(flights, config.flightdata) scraper.save(archives, config.archivedata) if numflights != 0 and numflights != unknown: capacity = int(capacity * numflights / (numflights - unknown))