Пример #1
0
 def __change_engines(self):
     result = post_request(CHANGE_ENGINES_URL.format(plane_id=self.plane.plane_id),
                           {'id_moteur': self.plane.replacement_engines_type})
     if not string_contains("L'avion va bien recevoir ses nouveaux moteurs, durée : 2 heures.", result):
         # TODO parse the answer
         logger.warning('Error while changing engines')
     self.__ready = False
Пример #2
0
 def __fill_fuel(self):
     fuel_qty = self.plane.fuel_capacity - self.plane.kerosene
     confirm_page = post_request(FILL_FUEL_URL.format(plane_id=self.plane.plane_id),
                                 {'cq': fuel_qty})
     if not string_contains('Vous avez ajouté .+ litres? de kérosène dans votre avion !',
                            confirm_page):
         logger.warning('Error when filling fuel')
         self.__ready = False
Пример #3
0
def take_concorde_from_alliance():
    page = get_request(ALLIANCE_PAGE)
    if string_contains(CONCORDE_PANEL_AVAILABLE_HTML, page):
        page = get_request(ALLIANCE_CONCORDE_PANEL_URL)
        concorde_id = get_values_from_regex(ALLIANCE_CONCORDE_PATTERN_HTML, page)[0]
        page = get_request(ALLIANCE_TAKE_CONCORDE_URL.format(concorde_id=concorde_id))
        # Todo check if successful
        return True
    else:
        return False
Пример #4
0
def parse_one_mission(mission_html, country_nb):
    if not string_contains(MISSION_TOO_SHORT_HTML,
                           mission_html):  # and not string_contains(u"vous n'avez pas d'avion correspondant à cette mission", mission_html):
        contract_amount = int(''.join(get_value_from_regex(MISSION_AMOUNT_REGEX, mission_html).split(',')))
        time_before_departure = parse_duration_before_departure(mission_html)
        a_mission = {
            'country_nb': int(country_nb),
            'mission_nb': get_int_from_regex(MISSION_ID_REGEX, mission_html),
            'travellers_nb': get_int_from_regex(MISSION_PASSENGERS_CARGO_NB_REGEX, mission_html),
            'contract_amount': contract_amount,
            'reputation': get_int_from_regex(MISSION_REPUTATION_REGEX, mission_html),
            'pilots_nb': get_int_from_regex(MISSIONS_PILOTS_NB_REGEX, mission_html),
            'flight_attendants_nb': get_int_from_regex(MISSIONS_FLIGHT_ATTENDANTS_NB_REGEX, mission_html),
            'time_before_departure': time_before_departure,
            'km_nb': get_int_from_regex(MISSION_DISTANCE_REGEX, mission_html)
        }
        return a_mission
Пример #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