From c1bd68e32f52f6b79aad05c76de979bb7ef8d615 Mon Sep 17 00:00:00 2001 From: "huang.xiangdong" Date: Fri, 10 May 2019 09:37:04 +0800 Subject: [PATCH] fix YAMLLoadWarning when running 'atomic install/run' --- Atomic/util.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Atomic/util.py b/Atomic/util.py index 6be5f098..d3eff2eb 100644 --- a/Atomic/util.py +++ b/Atomic/util.py @@ -11,7 +11,7 @@ import os import selinux from .client import AtomicDocker -from yaml import load as yaml_load +import yaml from yaml import safe_load from yaml import YAMLError from yaml.scanner import ScannerError @@ -41,11 +41,19 @@ KPOD_PATH = os.environ.get("KPOD_PATH", "/usr/bin/kpod") CAPSH_PATH = os.environ.get("CAPSH_PATH", "/usr/sbin/capsh") +try: + from yaml import CLoader as Loader +except ImportError: + from yaml import Loader + try: from subprocess import DEVNULL # pylint: disable=no-name-in-module except ImportError: DEVNULL = open(os.devnull, 'wb') +def yaml_load(stream): + return yaml.load(stream, Loader=Loader) + def gomtree_available(): return os.path.exists(GOMTREE_PATH)