Commit b4ff2b07 authored by Mart Lubbers's avatar Mart Lubbers
Browse files

update Tools/*.py scripts to python3

parent e83db48d
Pipeline #48764 passed with stage
in 15 minutes and 55 seconds
#!/usr/bin/env python2 #!/usr/bin/env python3
# This library indexes the packages in this repository in a convenient data # This library indexes the packages in this repository in a convenient data
# structure # structure
...@@ -88,7 +88,7 @@ def indexSourceDependencies(package_name, target): ...@@ -88,7 +88,7 @@ def indexSourceDependencies(package_name, target):
sh_vars = {} sh_vars = {}
for line in open(fetchsh, "r"): for line in open(fetchsh, "r"):
items = sh_vars.items() items = sh_vars.items()
items.sort(reverse=True) items = sorted(items, reverse=True)
# Substitute shell variables # Substitute shell variables
for (key, value) in items: for (key, value) in items:
line = line.replace("$"+key, value) line = line.replace("$"+key, value)
...@@ -98,8 +98,8 @@ def indexSourceDependencies(package_name, target): ...@@ -98,8 +98,8 @@ def indexSourceDependencies(package_name, target):
sh_vars[parts[0].strip()] = removeQuotes_(parts[1].strip()) sh_vars[parts[0].strip()] = removeQuotes_(parts[1].strip())
# Check svn exports # Check svn exports
elif line.find("svn export") == 0: elif line.find("svn export") == 0:
urls = filter( urls = list(filter(
lambda x: x.find("https://") >= 0, line.split(" ")) lambda x: x.find("https://") >= 0, line.split(" ")))
url = removeQuotes_(urls[0].strip()) url = removeQuotes_(urls[0].strip())
# Find repo name and path # Find repo name and path
parts = (url[url.find("repos") + 6:]).split("/") parts = (url[url.find("repos") + 6:]).split("/")
...@@ -111,8 +111,8 @@ def indexSourceDependencies(package_name, target): ...@@ -111,8 +111,8 @@ def indexSourceDependencies(package_name, target):
dependencies.append(repository) dependencies.append(repository)
# Check git clones # Check git clones
elif line.find("git clone") == 0: elif line.find("git clone") == 0:
urls = filter( urls = list(filter(
lambda x: x.find("https://") >= 0, line.split(" ")) lambda x: x.find("https://") >= 0, line.split(" ")))
url = removeQuotes_(urls[0].strip()) url = removeQuotes_(urls[0].strip())
name = url[url.find("clean-and-itasks") + 17:] name = url[url.find("clean-and-itasks") + 17:]
repository = {"type": "git", "name": name, "url": url} repository = {"type": "git", "name": name, "url": url}
...@@ -131,7 +131,7 @@ def indexBinaryDependencies(package_name, target): ...@@ -131,7 +131,7 @@ def indexBinaryDependencies(package_name, target):
sh_vars = {} sh_vars = {}
for line in open(setupsh, "r"): for line in open(setupsh, "r"):
items = sh_vars.items() items = sh_vars.items()
items.sort(reverse=True) items = sorted(items, reverse=True)
# Substitute shell variables # Substitute shell variables
for (key, value) in items: for (key, value) in items:
line = line.replace("$"+key, value) line = line.replace("$"+key, value)
...@@ -150,8 +150,8 @@ def indexBinaryDependencies(package_name, target): ...@@ -150,8 +150,8 @@ def indexBinaryDependencies(package_name, target):
package_dependencies.append(line[start:end]) package_dependencies.append(line[start:end])
# Include other downloads as a 'other' dependencies # Include other downloads as a 'other' dependencies
elif line.find("http://") >= 0 or line.find("ftp://") >= 0: elif line.find("http://") >= 0 or line.find("ftp://") >= 0:
urls = filter(lambda x: x.find("http://") >= 0 urls = list(filter(lambda x: x.find("http://") >= 0
or x.find("ftp://") >= 0, line.split(" ")) or x.find("ftp://") >= 0, line.split(" ")))
other_dependencies.append(urls[0]) other_dependencies.append(urls[0])
return (package_dependencies, other_dependencies) return (package_dependencies, other_dependencies)
......
#!/usr/bin/env python #!/usr/bin/env python3
# This script creates Jenkins build jobs for all packages and synchronizes # This script creates Jenkins build jobs for all packages and synchronizes
# them with a build server using the Jenkins CLI tool # them with a build server using the Jenkins CLI tool
...@@ -7,11 +7,11 @@ import os ...@@ -7,11 +7,11 @@ import os
import subprocess import subprocess
import copy import copy
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import ConfigParser import configparser
import cleanbuild import cleanbuild
# Read the jenkins credentials from a local file with the # Read the jenkins credentials from a local file with the
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read('jenkins.cfg') config.read('jenkins.cfg')
JENKINS_URL = config.get("Jenkins", "url") JENKINS_URL = config.get("Jenkins", "url")
...@@ -33,13 +33,14 @@ def getJenkinsCLI(): ...@@ -33,13 +33,14 @@ def getJenkinsCLI():
def listJenkinsJobs(): def listJenkinsJobs():
output = subprocess.check_output(jenkinsCommand("list-jobs"), shell=True) output = subprocess.check_output(
jenkinsCommand("list-jobs"), shell=True).decode()
return output.strip().split("\n") return output.strip().split("\n")
def getJenkinsJob(name): def getJenkinsJob(name):
output = subprocess.check_output( output = subprocess.check_output(
jenkinsCommand("get-job %s" % name), shell=True) jenkinsCommand("get-job %s" % name), shell=True).decode()
if output.startswith("ERROR: No such job"): if output.startswith("ERROR: No such job"):
return None return None
else: else:
...@@ -49,14 +50,14 @@ def getJenkinsJob(name): ...@@ -49,14 +50,14 @@ def getJenkinsJob(name):
def updateJenkinsJob(name, xml): def updateJenkinsJob(name, xml):
proc = subprocess.Popen(jenkinsCommand( proc = subprocess.Popen(jenkinsCommand(
"update-job %s" % name), stdin=subprocess.PIPE, shell=True) "update-job %s" % name), stdin=subprocess.PIPE, shell=True)
proc.stdin.write(xml) proc.stdin.write(xml.encode())
proc.stdin.close() proc.stdin.close()
def createJenkinsJob(name, xml): def createJenkinsJob(name, xml):
proc = subprocess.Popen(jenkinsCommand( proc = subprocess.Popen(jenkinsCommand(
"create-job %s" % name), stdin=subprocess.PIPE, shell=True) "create-job %s" % name), stdin=subprocess.PIPE, shell=True)
proc.stdin.write(xml) proc.stdin.write(xml.encode())
proc.stdin.close() proc.stdin.close()
...@@ -168,7 +169,7 @@ def syncJenkinsServer(packages): ...@@ -168,7 +169,7 @@ def syncJenkinsServer(packages):
jobname = "%s-%s" % (package["name"], target["name"]) jobname = "%s-%s" % (package["name"], target["name"])
xml = "<?xml version='1.0' encoding='UTF-8'?>" + \ xml = "<?xml version='1.0' encoding='UTF-8'?>" + \
generateJenkinsJob(package, target) generateJenkinsJob(package, target).decode()
if jobname in jobs: if jobname in jobs:
print("Updating '%s'..." % jobname) print("Updating '%s'..." % jobname)
updateJenkinsJob(jobname, xml) updateJenkinsJob(jobname, xml)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment