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
# structure
......@@ -88,7 +88,7 @@ def indexSourceDependencies(package_name, target):
sh_vars = {}
for line in open(fetchsh, "r"):
items = sh_vars.items()
items.sort(reverse=True)
items = sorted(items, reverse=True)
# Substitute shell variables
for (key, value) in items:
line = line.replace("$"+key, value)
......@@ -98,8 +98,8 @@ def indexSourceDependencies(package_name, target):
sh_vars[parts[0].strip()] = removeQuotes_(parts[1].strip())
# Check svn exports
elif line.find("svn export") == 0:
urls = filter(
lambda x: x.find("https://") >= 0, line.split(" "))
urls = list(filter(
lambda x: x.find("https://") >= 0, line.split(" ")))
url = removeQuotes_(urls[0].strip())
# Find repo name and path
parts = (url[url.find("repos") + 6:]).split("/")
......@@ -111,8 +111,8 @@ def indexSourceDependencies(package_name, target):
dependencies.append(repository)
# Check git clones
elif line.find("git clone") == 0:
urls = filter(
lambda x: x.find("https://") >= 0, line.split(" "))
urls = list(filter(
lambda x: x.find("https://") >= 0, line.split(" ")))
url = removeQuotes_(urls[0].strip())
name = url[url.find("clean-and-itasks") + 17:]
repository = {"type": "git", "name": name, "url": url}
......@@ -131,7 +131,7 @@ def indexBinaryDependencies(package_name, target):
sh_vars = {}
for line in open(setupsh, "r"):
items = sh_vars.items()
items.sort(reverse=True)
items = sorted(items, reverse=True)
# Substitute shell variables
for (key, value) in items:
line = line.replace("$"+key, value)
......@@ -150,8 +150,8 @@ def indexBinaryDependencies(package_name, target):
package_dependencies.append(line[start:end])
# Include other downloads as a 'other' dependencies
elif line.find("http://") >= 0 or line.find("ftp://") >= 0:
urls = filter(lambda x: x.find("http://") >= 0
or x.find("ftp://") >= 0, line.split(" "))
urls = list(filter(lambda x: x.find("http://") >= 0
or x.find("ftp://") >= 0, line.split(" ")))
other_dependencies.append(urls[0])
return (package_dependencies, other_dependencies)
......
#!/usr/bin/env python
#!/usr/bin/env python3
# This script creates Jenkins build jobs for all packages and synchronizes
# them with a build server using the Jenkins CLI tool
......@@ -7,11 +7,11 @@ import os
import subprocess
import copy
import xml.etree.ElementTree as ET
import ConfigParser
import configparser
import cleanbuild
# Read the jenkins credentials from a local file with the
config = ConfigParser.ConfigParser()
config = configparser.ConfigParser()
config.read('jenkins.cfg')
JENKINS_URL = config.get("Jenkins", "url")
......@@ -33,13 +33,14 @@ def getJenkinsCLI():
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")
def getJenkinsJob(name):
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"):
return None
else:
......@@ -49,14 +50,14 @@ def getJenkinsJob(name):
def updateJenkinsJob(name, xml):
proc = subprocess.Popen(jenkinsCommand(
"update-job %s" % name), stdin=subprocess.PIPE, shell=True)
proc.stdin.write(xml)
proc.stdin.write(xml.encode())
proc.stdin.close()
def createJenkinsJob(name, xml):
proc = subprocess.Popen(jenkinsCommand(
"create-job %s" % name), stdin=subprocess.PIPE, shell=True)
proc.stdin.write(xml)
proc.stdin.write(xml.encode())
proc.stdin.close()
......@@ -168,7 +169,7 @@ def syncJenkinsServer(packages):
jobname = "%s-%s" % (package["name"], target["name"])
xml = "<?xml version='1.0' encoding='UTF-8'?>" + \
generateJenkinsJob(package, target)
generateJenkinsJob(package, target).decode()
if jobname in jobs:
print("Updating '%s'..." % jobname)
updateJenkinsJob(jobname, xml)
......
Markdown is supported
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