def __getModulesFromConfig(self, modules, config_array_name):
        try:
            modules_from_config = self.__config['MODULES'][config_array_name]
        except:
            logger.Warning('config.json : modules bad format')
            modules_from_config = []

        if len(modules_from_config) == 0 and modules is None:
            return None

        if len(modules_from_config) == 0 and modules is not None:
            return modules

        if modules is None:
            modules = []

        for module in modules_from_config:
            if module in modules:
                logger.Warning('warning : ' + module + ' already referenced.')

            modules.append(module)

        return modules
Ejemplo n.º 2
0
    def download(self):
        demoddata = self.observation[self.__json_id]
        if not any(demoddata):
            logger.Info('no demoddata found for the observation ' + str(self.observation['id']) + ' of ' + self.observation['start'])
            return

        fileHelper.create_dir_if_not_exist(self.full_path)
        for demod in demoddata:
            file_name = ntpath.basename(demod['payload_demod'])
            full_path_file = self.full_path + os.path.sep + file_name
            if os.path.exists(full_path_file):
                logger.Warning('pass ' + file_name + '... file already exist')
                return

            r = self.client.get(demod['payload_demod'])
            if r.status_code == 200:
                logger.Info('downloading...' + file_name)
                with open(full_path_file, "wb") as file:
                    file.write(r.content)
                self.runModulesAfterDownload(file_name)