def view_generic(_, view_name): """ First parameter request is not used. Replaced by _ for sonar """ requested_view = 'view_{}()'.format(view_name) action_url = 'Requested view: {}'.format(requested_view) try: logger.info(action_url) eval(requested_view) logger.info('Successful') except Exception as e: exception_text = traceback.format_exc() logger.error(exception_text) notify('FM: Exception', 'Exception:\n{}'.format(exception_text)) raise e finally: save_session_to_db() return HttpResponse('started')
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