def test_read_agency(self):
     agency = Agency('FDHUKSDI', None)
     db.session.add(agency)
     db.session.commit()
     agency_name = read_agency(agency.id)['name']
     db.session.delete(agency)
     db.session.commit()
     self.assertEqual(agency_name, 'FDHUKSDI')
Beispiel #2
0
 def buy(self, ag: Agency):
     try:
         seatSearch = ag.getList()
         choice = seatSearch[seatSearch.index(
             min(seatSearch, key=lambda t: t[2]))]
         #print(choice, '  ', choice[0], '  ', choice[1], ' ', choice[2])
         if (ag.sellToCLient(choice[0], choice[1])):
             # Travel
             sleep(10)
             return choice
         else:
             sleep(0.01)
             self.buy(ag)
     except:
         sleep(0.1)
         print('\n\nThe Client ' + str(currentThread) +
               ' Could not Find any flights'
               )  # in case there are more clients than seats
Beispiel #3
0
 def __init__(self):
     self.database = None
     self.source_folder = None
     self.agency = Agency()
     self.trips = None
     self.num_routes = None
     self.routes = {}
     self.stops = {}
     self.calendar_dates = {}
     self.available_files = {}
     self.shapes = {}
     self.schedule_exceptions = None
Beispiel #4
0
def create_agency(name, parent_id):
    '''
	This function creates a new tupple in Agency table.
	return 0 means everything accomplished successfully.
	return 1 means the operation was unsuccessfull.
	'''
    try:
        agency = Agency(name, parent_id)
        db.session.add(agency)
        db.session.commit()
        return 0
    except Exception as e:
        print('error while creating the agency: ' + str(e))
        return 1
Beispiel #5
0
from porc import Client
import utils, time
from agency import Agency

client = Client("your api key")
agency = Agency("rutgers")

relevantTags = ['a', 'b', 'f', 'lx']

relevantRoutes = []
for relevantTag in relevantTags:
    route = agency.getRoute(relevantTag)
    if route != None:
        relevantRoutes.append(route)

while True:
    print("start")
    predictions = []
    for route in relevantRoutes:
        predictions = predictions + route.getPredictions()

    # asynchronously post items
    with client. async () as c:
        futures = [
            c.post('predictions', prediction) for prediction in predictions
        ]
        responses = [future.result() for future in futures]
        [response.raise_for_status() for response in responses]
    print("end")
    time.sleep(10)
Beispiel #6
0
from watchers import Writer, Caller
from agency import Agency


agency = Agency("OpeN AgencY")

Writer({
    'booked_phone': agency.booked_phone,
    'booked_cash': agency.booked_cash,
    'tickets': agency.tickets,
    'sold': agency.sold
}).watch(10)

Caller({
    'booked_phone': agency.booked_phone,
    'tickets': agency.tickets
}).watch(6 * 60 * 60)

agency.open()
Beispiel #7
0
	def agency(self):
		from agency import Agency
		return Agency.get(self['agencyId'])
Beispiel #8
0
    def agency(self):
        from agency import Agency

        return Agency.get(self["agencyId"])
    threadList = []

    clientList = []
    companyList = []
    agencyList = []

    #Flight Companies

    latam = Company('LATAM')
    ryanair = Company('Ryanair')
    airFrance = Company('AirFrance')
    panAm = Company('PanAm')

    companyList = [latam, ryanair, airFrance, panAm]

    #Travel Agencies
    decolar = Agency(companyList, 'Decolar.Com')
    skyScanner = Agency(companyList, 'Sky Scanner')

    agencyList = [decolar, skyScanner]

    for agency in agencyList:
        agency.run()

    sleep(2)

    # Creating Clients
    for i in range(10):
        clientList.append(Client(agencyList))
        threadList.append(Thread(target=clientList[i].run).start())