Ejemplo n.º 1
0
def move_money_to_alliance(amount=None):
    if not amount:
        page = get_request(ALLIANCE_PAGE)
        amount = get_amount_from_regex(AIRPORT_CASH_REGEX, page)
    if amount > 0:
        result = post_request(ALLIANCE_DEPOSIT_CASH_URL, {'cq': amount})
        exception_if_not_contains(ALLIANCE_DEPOSIT_SUCCESSFUL, result)
Ejemplo n.º 2
0
def buy_market_kero(quantity, sale_id):
    body = {
        'cq': quantity,
        'mon_champ': sale_id
     }
    response = post_request(SHOP_BUY_USED_KEROSENE_URL, body)
    exception_if_not_contains(SHOP_SUCCESSFUL_KEROSENE, response)
Ejemplo n.º 3
0
def move_money_to_bank(amount=None):
    if not amount:
        page = get_request(BANK_PAGE)
        amount = get_amount_from_regex(AIRPORT_CASH_REGEX, page)
    else:
        get_request(BANK_PAGE)
    result = post_request(BANK_DEPOSIT_URL, {'cq': amount})
    exception_if_not_contains(BANK_DEPOSIT_SUCCESSFUL, result)
Ejemplo n.º 4
0
def buy_missing_planes(plane_class, missing_units):
    # if amount_needed(missing_planes) < self.airport.money:
    #     for aircraft_type, missing_units in missing_planes.iteritems():
    for _ in range(missing_units):
        if plane_class == SupersonicPlane:
            if take_concorde_from_alliance():
                return
        page = get_request(plane_class.buy_url)
        try:
            exception_if_not_contains(SHOP_SUCCESSFUL_PLANES, page, 'Could not buy a plane')
        except:
            withdraw_from_alliance(plane_class.price)
Ejemplo n.º 5
0
 def __do_maintenance(self):
     page = None
     try:
         page = get_request(MAINTENANCE_URL.format(plane_id=self.plane.plane_id))
         exception_if_not_contains('Votre avion est maintenant en maintenance', page)
     except:
         logger.error('Problem sending to maintenance')
         if not string_contains("en mission, en maintenance ou n'a pas plus de 100,000 km sans maintenance",
                                page):
             # case when the current airport has changed
             # case not enough mecanicians
             notify('FM : could not send to maintenance', page)
         else:
             # TODO case plane maintenance was over, should continue iteration over planes, refresh and run again
             logger.warning("Outdated plane list (not an exception anymore)")
             # raise OutdatedPlanesListException()
     self.__ready = False