[sysadmin/ci-tooling] helpers: Port to non-deprecated PyYAML functions.

Ben Cooksley null at kde.org
Sun Apr 7 10:41:17 BST 2019


Git commit 1f1b5806aca0bec73b33820fac0044bd7914fe18 by Ben Cooksley.
Committed on 07/04/2019 at 09:40.
Pushed by bcooksley into branch 'master'.

Port to non-deprecated PyYAML functions.
This should also correct the breakage which is currently causing all Frameworks Linux builds to have an UNSTABLE (failing tests) status as the YAML depreciation warnings were causing the check-platforms logic to trip.

CCMAIL: kde-frameworks-devel at kde.org

M  +1    -1    helpers/check-platform.py
M  +1    -1    helpers/helperslib/BuildSpecs.py
M  +3    -3    helpers/helperslib/Buildable.py
M  +6    -6    helpers/helperslib/Packages.py
M  +1    -1    helpers/helperslib/ToolingSettings.py

https://invent.kde.org/sysadmin/ci-tooling/commit/1f1b5806aca0bec73b33820fac0044bd7914fe18

diff --git a/helpers/check-platform.py b/helpers/check-platform.py
index a24bf9e..e045e22 100644
--- a/helpers/check-platform.py
+++ b/helpers/check-platform.py
@@ -26,7 +26,7 @@ resolver.loadProjectsIgnoreRules(os.path.join( CommonUtils.scriptsBaseDirectory(
 
 for metainfo in arguments.metainfo:
     metainfoFile = open(metainfo, 'r', encoding='utf-8')
-    read = yaml.load(metainfoFile)
+    read = yaml.safe_load(metainfoFile)
     platforms = [p['name'] for p in read['platforms']]
     if 'All' in platforms:
         platforms = allPlatforms.values()
diff --git a/helpers/helperslib/BuildSpecs.py b/helpers/helperslib/BuildSpecs.py
index f44aa89..9e70a3b 100644
--- a/helpers/helperslib/BuildSpecs.py
+++ b/helpers/helperslib/BuildSpecs.py
@@ -52,7 +52,7 @@ class Loader(object):
 		# Load the file now
 		with open(configFileLocation, 'r') as configFile:
 			# Parse the YAML file
-			projectConfig = yaml.load(configFile)
+			projectConfig = yaml.safe_load(configFile)
 
 			# Does it specify something for this branch group?
 			if branchGroup in projectConfig:
diff --git a/helpers/helperslib/Buildable.py b/helpers/helperslib/Buildable.py
index 1fa0793..faed3bd 100644
--- a/helpers/helperslib/Buildable.py
+++ b/helpers/helperslib/Buildable.py
@@ -107,7 +107,7 @@ class DependencyResolver(object):
 			# Load the metadata.yaml file and create a project from it
 			projectMetadataFile = open(entry.path, 'r', encoding='utf-8')
 			# Parse the YAML file
-			projectMetadata = yaml.load(projectMetadataFile)
+			projectMetadata = yaml.safe_load(projectMetadataFile)
 			# Is it a repository - ie. something we need to know about?
 			if not projectMetadata['hasrepo'] or not projectMetadata['repoactive']:
 				continue
@@ -135,7 +135,7 @@ class DependencyResolver(object):
 		# Open the file
 		ignoreRulesFile = open(ignoreRulesPath, 'r', encoding='utf-8')
 		# Parse the YAML file
-		ignoreRules = yaml.load(ignoreRulesFile)
+		ignoreRules = yaml.safe_load(ignoreRulesFile)
 		# We'll go through each platform's section in turn
 		for platform in ignoreRules.keys():
 			# Now go over each rule in turn (which is just the name of the project...
@@ -295,7 +295,7 @@ class ProductHandler(object):
 		# We expect a YAML format file
 		with open(filePath, 'r') as dataFile:
 			# Parse the YAML file
-			self.productsData = yaml.load( dataFile )
+			self.productsData = yaml.safe_load( dataFile )
 
 	# Let the user know what Products we know about
 	def knownProducts(self):
diff --git a/helpers/helperslib/Packages.py b/helpers/helperslib/Packages.py
index c263cb8..42dd62b 100644
--- a/helpers/helperslib/Packages.py
+++ b/helpers/helperslib/Packages.py
@@ -28,7 +28,7 @@ class Archive(object):
 		configFileLocation = os.path.join( CommonUtils.scriptsBaseDirectory(), 'archive-configs', name + '.yaml' )
 		with open(configFileLocation, 'r') as configFile:
 			# Parse the YAML file
-			self.config = yaml.load( configFile )
+			self.config = yaml.safe_load( configFile )
 
 		# Are we using a local cache?
 		# If not, then retrieval of packages won't be possible so nothing further needs to be done
@@ -43,7 +43,7 @@ class Archive(object):
 		# Retrieve the archive manifest from the remote server
 		# We'll use this to determine if we need to update a file from the remote server
 		response = urllib.request.urlopen( self.downloadBaseUrl() + '/manifest.yaml' )
-		self.serverManifest = yaml.load( response.read() )
+		self.serverManifest = yaml.safe_load( response.read() )
 
 		# Make sure the Manifest is valid...
 		if self.serverManifest is None:
@@ -103,7 +103,7 @@ class Archive(object):
 		if os.path.exists( localMetadataPath ):
 			# Load the local metadata
 			with open(localMetadataPath, 'r', encoding='utf-8') as localMetadataFile:
-				localMetadata = yaml.load( localMetadataFile )
+				localMetadata = yaml.safe_load( localMetadataFile )
 			# Look it up in the server manifest...
 			serverMetadata = self.serverManifest[ package ]
 			# If the server timestamp is lower or the same, no need to fetch
@@ -216,7 +216,7 @@ class Archive(object):
 
 		# And update our internal copy of the server side metadata
 		with open(localMetadataPath, 'r', encoding='utf-8') as localMetadataFile:
-			self.serverManifest[ package ] = yaml.load( localMetadataFile )
+			self.serverManifest[ package ] = yaml.safe_load( localMetadataFile )
 
 	# Performs the package publishing process
 	# This function should only be called on the archive server and will not function correctly on clients.
@@ -228,7 +228,7 @@ class Archive(object):
 
 		# Because we need to know the contentsSuffix of the file we're publishing, load the metadata for the file...
 		with open(stagedMetadataPath, 'r', encoding='utf-8') as metadataFile:
-			metadata = yaml.load( metadataFile )
+			metadata = yaml.safe_load( metadataFile )
 			contentsSuffix = metadata.get('contentsSuffix', self.contentsSuffix)
 
 		# Now that we know the contentsSuffix, we can go ahead and determine where our package's content can be found and where it needs to be moved to
@@ -277,7 +277,7 @@ class Archive(object):
 			metadataPath = os.path.join(archiveFolder, fileToCheck)
 			# Load the YAML file
 			with open(metadataPath, 'r', encoding='utf-8') as metadataFile:
-				metadata = yaml.load( metadataFile )
+				metadata = yaml.safe_load( metadataFile )
 
 			# Add it to our Manifest
 			manifestContents[ packageName ] = metadata
diff --git a/helpers/helperslib/ToolingSettings.py b/helpers/helperslib/ToolingSettings.py
index 70f0b7d..f9b74de 100644
--- a/helpers/helperslib/ToolingSettings.py
+++ b/helpers/helperslib/ToolingSettings.py
@@ -45,7 +45,7 @@ class Loader(object):
 		# Load the file now
 		with open( configFileLocation, 'r' ) as configFile:
 			# Parse the YAML file
-			projectConfig = yaml.load( configFile )
+			projectConfig = yaml.safe_load( configFile )
 
 		entries = []
 		for key in projectConfig:


More information about the Kde-frameworks-devel mailing list