Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-build
Commits
b4ff2b07
Commit
b4ff2b07
authored
Jan 27, 2021
by
Mart Lubbers
Browse files
update Tools/*.py scripts to python3
parent
e83db48d
Pipeline
#48764
passed with stage
in 15 minutes and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Tools/cleanbuild.py
View file @
b4ff2b07
#!/usr/bin/env python
2
#!/usr/bin/env python
3
# 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
=
sort
ed
(
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
=
sort
ed
(
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
)
...
...
Tools/sync-jenkins.py
View file @
b4ff2b07
#!/usr/bin/env python
#!/usr/bin/env python
3
# 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
C
onfig
P
arser
import
c
onfig
p
arser
import
cleanbuild
# Read the jenkins credentials from a local file with the
config
=
C
onfig
P
arser
.
ConfigParser
()
config
=
c
onfig
p
arser
.
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment