예제 #1
0
def update(url, filename):
	"""
	Updates a file by appending current information to already known information
	"""
	flights = scraper.load(filename)	# load currently known flights from file
	if flights is None:
		flights = []
	newflights = scraper.readFlights(url)	# scrape newly available flight data from site
	for flight in newflights:
		if flight not in flights:
			flights.append(flight)	# append each new flight to the list of known flights
	scraper.save(flights, filename)	# save the updated list of flights to file
예제 #2
0
def update(url, filename):
    """
	Updates a file by appending current information to already known information
	"""
    flights = scraper.load(filename)  # load currently known flights from file
    if flights is None:
        flights = []
    newflights = scraper.readFlights(
        url)  # scrape newly available flight data from site
    for flight in newflights:
        if flight not in flights:
            flights.append(
                flight)  # append each new flight to the list of known flights
    scraper.save(flights, filename)  # save the updated list of flights to file
예제 #3
0
	"""
	Updates a file by appending current information to already known information
	"""
	flights = scraper.load(filename)	# load currently known flights from file
	if flights is None:
		flights = []
	newflights = scraper.readFlights(url)	# scrape newly available flight data from site
	for flight in newflights:
		if flight not in flights:
			flights.append(flight)	# append each new flight to the list of known flights
	scraper.save(flights, filename)	# save the updated list of flights to file

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
예제 #4
0
def setter():
    final = load()
    if not final:
        abort(404)
    return final
예제 #5
0
    flights = scraper.load(filename)  # load currently known flights from file
    if flights is None:
        flights = []
    newflights = scraper.readFlights(
        url)  # scrape newly available flight data from site
    for flight in newflights:
        if flight not in flights:
            flights.append(
                flight)  # append each new flight to the list of known flights
    scraper.save(flights, filename)  # save the updated list of flights to file


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