Exemplo n.º 1
0
import requests
from time import sleep
from random import randint
from datetime import datetime
from db_commands import FlightTrackerCluster
from env_variables import QPX_API_KEY, ORIGIN_ONE, DESTINATION_ONE, ORIGIN_TWO, DESTINATION_TWO, DEPARTURE_DATE
from env_variables import QPX_API_KEY_TWO, ORIGIN_THREE, DESTINATION_THREE, ORIGIN_FOUR, DESTINATION_FOUR
# from env_variables import RETURN_DATE

############################################## Set-Up ################################################
days = [
    'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
    'Sunday'
]

myCluster = FlightTrackerCluster()
myCluster.createKeySpace('plane')
myCluster.changeKeySpace('plane')

#Uncomment the first time to create the table
#myCluster.createTable('tickets', ['hour', 'date', 'day', 'carrier', 'origin', 'destination', 'departure_date', 'price'], ['day', 'date', 'origin', 'destination', 'price', 'hour'])

params_one = myCluster.getParams(ORIGIN_ONE, DESTINATION_ONE, DEPARTURE_DATE,
                                 100)
params_two = myCluster.getParams(ORIGIN_TWO, DESTINATION_TWO, DEPARTURE_DATE,
                                 100)
params_three = myCluster.getParams(ORIGIN_THREE, DESTINATION_THREE,
                                   DEPARTURE_DATE, 100)
params_four = myCluster.getParams(ORIGIN_FOUR, DESTINATION_FOUR,
                                  DEPARTURE_DATE, 100)
# params = myCluster.getParams(ORIGIN_ONE, DESTINATION_ONE, DEPARTURE_DATE, RETURN_DATE, 100)
from db_commands import FlightTrackerCluster

myCluster = FlightTrackerCluster()
myCluster.changeKeySpace('plane')
first = raw_input('Are you sure you want to delete the table "tickets"? Type "Y" to confirm: ')
if first == 'Y':
    myCluster.deleteTable('tickets')
    print "Table has been deleted."
Exemplo n.º 3
0
import json
import requests
from time import sleep
from random import randint
from datetime import datetime
from db_commands import FlightTrackerCluster
from env_variables import QPX_API_KEY, ORIGIN_ONE, DESTINATION_ONE, ORIGIN_TWO, DESTINATION_TWO, DEPARTURE_DATE
from env_variables import QPX_API_KEY_TWO, ORIGIN_THREE, DESTINATION_THREE, ORIGIN_FOUR, DESTINATION_FOUR
# from env_variables import RETURN_DATE

############################################## Set-Up ################################################
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

myCluster = FlightTrackerCluster()
myCluster.createKeySpace('plane')
myCluster.changeKeySpace('plane')

#Uncomment the first time to create the table
#myCluster.createTable('tickets', ['hour', 'date', 'day', 'carrier', 'origin', 'destination', 'departure_date', 'price'], ['day', 'date', 'origin', 'destination', 'price', 'hour'])


params_one = myCluster.getParams(ORIGIN_ONE, DESTINATION_ONE, DEPARTURE_DATE, 100)
params_two = myCluster.getParams(ORIGIN_TWO, DESTINATION_TWO, DEPARTURE_DATE, 100)
params_three = myCluster.getParams(ORIGIN_THREE, DESTINATION_THREE, DEPARTURE_DATE, 100)
params_four = myCluster.getParams(ORIGIN_FOUR, DESTINATION_FOUR, DEPARTURE_DATE, 100)
# params = myCluster.getParams(ORIGIN_ONE, DESTINATION_ONE, DEPARTURE_DATE, RETURN_DATE, 100)

last = None

def writeToCassandra(params, hour, date, day_of_week, origin, destination, departure_date, api_key):
    url = 'https://www.googleapis.com/qpxExpress/v1/trips/search?key=' + QPX_API_KEY
Exemplo n.º 4
0
from db_commands import FlightTrackerCluster

myCluster = FlightTrackerCluster()
myCluster.changeKeySpace('plane')
first = raw_input(
    'Are you sure you want to delete the table "tickets"? Type "Y" to confirm: '
)
if first == 'Y':
    myCluster.deleteTable('tickets')
    print "Table has been deleted."