Loading src/ztp_server/service/rest_server/ztpServer_plugins/ztp_provisioning_api/Tools.py +11 −10 Original line number Diff line number Diff line Loading @@ -12,20 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # ztp_server/service/rest_server/ztpServer_plugins/ztp_provisioning_api/Tools.py import os, logging log = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) def returnConfigFile(config_db: str): base = os.path.normpath( os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","data") ) cfg = os.path.join(base, config_db) log.info("ZTP REST: trying config file: %s", cfg) file_path = os.path.normpath(os.path.join( os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..', 'data', config_db )) MSG = 'ZTP REST: trying config file: {:s}' LOGGER.info(MSG.format(str(file_path))) try: with open(cfg, "r", encoding="utf-8") as f: with open(file_path, 'r', encoding='utf-8') as f: return f.read() except FileNotFoundError: log.warning("ZTP REST: config file not found: %s", cfg) MSG = 'ZTP REST: config file not found: {:s}' LOGGER.warning(MSG.format(str(file_path))) return None Loading
src/ztp_server/service/rest_server/ztpServer_plugins/ztp_provisioning_api/Tools.py +11 −10 Original line number Diff line number Diff line Loading @@ -12,20 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # ztp_server/service/rest_server/ztpServer_plugins/ztp_provisioning_api/Tools.py import os, logging log = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__) def returnConfigFile(config_db: str): base = os.path.normpath( os.path.join(os.path.dirname(os.path.abspath(__file__)), "..","..","..","..","data") ) cfg = os.path.join(base, config_db) log.info("ZTP REST: trying config file: %s", cfg) file_path = os.path.normpath(os.path.join( os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..', 'data', config_db )) MSG = 'ZTP REST: trying config file: {:s}' LOGGER.info(MSG.format(str(file_path))) try: with open(cfg, "r", encoding="utf-8") as f: with open(file_path, 'r', encoding='utf-8') as f: return f.read() except FileNotFoundError: log.warning("ZTP REST: config file not found: %s", cfg) MSG = 'ZTP REST: config file not found: {:s}' LOGGER.warning(MSG.format(str(file_path))) return None