parameters: (self)
docstring: Loads all scenarios from the db
          for each scenario call the create_scenario method
docstring_summary: Loads all scenarios from the db
          for each scenario call the create_scenario method
docstring_tokens: Loads all scenarios from the db for each scenario call the create_scenario method
function: def load_scenarios(self):
          """ Loads all scenarios from the db
          for each scenario call the create_scenario method
          """
          try:
              with self._db.session_scope():
                  ### TEST if database is up
                  nb_test = 0
                  db_ok = False
                  while not db_ok and nb_test < DATABASE_CONNECTION_NUM_TRY:
                      nb_test += 1
                      try:
                          self._db.list_user_accounts()
                          db_ok = True
                      except:
                          msg = "The database is not responding. Check your configuration of if the database is up. Test {0}/{1}. The error while trying to connect to the database is : {2}".format(nb_test, DATABASE_CONNECTION_NUM_TRY, traceback.format_exc())
                          self.log.error(msg)
                          msg = "Waiting for {0} seconds".format(DATABASE_CONNECTION_WAIT)
                          self.log.info(msg)
                          time.sleep(DATABASE_CONNECTION_WAIT)
  
                  if nb_test >= DATABASE_CONNECTION_NUM_TRY:
                      msg = "Exiting scenario!"
                      self.log.error(msg)
                      self.force_leave()
                      return
  
                  ### Do the stuff
                  msg = "Connected to the database"
                  self.log.info(msg)
                  for scenario in self._db.list_scenario():
                      self.create_scenario(scenario.name, scenario.json, int(scenario.id), scenario.disabled, scenario.description, scenario.behavior, scenario.state)
          except:
              self.log.error(u"Error while loading the scenarios! The error is : {0}".format(traceback.format_exc()))
function_tokens: def load_scenarios ( self ) : try : with self . _db . session_scope ( ) : ### TEST if database is up nb_test = 0 db_ok = False while not db_ok and nb_test < DATABASE_CONNECTION_NUM_TRY : nb_test += 1 try : self . _db . list_user_accounts ( ) db_ok = True except : msg = "The database is not responding. Check your configuration of if the database is up. Test {0}/{1}. The error while trying to connect to the database is : {2}" . format ( nb_test , DATABASE_CONNECTION_NUM_TRY , traceback . format_exc ( ) ) self . log . error ( msg ) msg = "Waiting for {0} seconds" . format ( DATABASE_CONNECTION_WAIT ) self . log . info ( msg ) time . sleep ( DATABASE_CONNECTION_WAIT ) if nb_test >= DATABASE_CONNECTION_NUM_TRY : msg = "Exiting scenario!" self . log . error ( msg ) self . force_leave ( ) return ### Do the stuff msg = "Connected to the database" self . log . info ( msg ) for scenario in self . _db . list_scenario ( ) : self . create_scenario ( scenario . name , scenario . json , int ( scenario . id ) , scenario . disabled , scenario . description , scenario . behavior , scenario . state ) except : self . log . error ( u"Error while loading the scenarios! The error is : {0}" . format ( traceback . format_exc ( ) ) )