Exemple #1
0
 def handle_load_config(self, wsmsg):
     global SRVR_CFG
     result = None
     success = False
     try:
         filepath = wsmsg.data('filename')
         logger.debug("%s handle_load_config filepath: %s", self.log_str(), filepath)
         if SRVR_CFG.multiuser:
             logger.debug("%s translating filepath to local in multiuser mode", self.log_str())
             filepath = self.store.copy_to_local(filepath, self.work_dir)
         logger.debug("%s handle_load_config filepath: %s", self.log_str(), filepath)
         
         cfg = CSConfig(filepath)
         
         if SRVR_CFG.multiuser:
             result = cfg.as_dict()
         else:
             filedir, _filename = os.path.split(filepath)
             result = cfg.as_dict(rel_to_abs=filedir)
         success = True
     except Exception as e:
         logger.exception("%s Error reading configuration from %s", self.log_str(), wsmsg.data('filename'))
         result = 'HttpError' if isinstance(e, HttpError) else 'UnknownError'
     logger.debug("%s returning config [%s]", self.log_str(), str(result))
     return ({'cfg': result, 'success': success}, False)