Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P11639
pcc-diff
Active
Public
Actions
Authored by
Kormat
on Jun 23 2020, 10:42 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F31876242: raw.txt
Jun 23 2020, 10:42 AM
2020-06-23 10:42:18 (UTC+0)
Subscribers
None
#!/usr/bin/python3
import
os
import
sys
import
re
from
urllib.request
import
urlopen
from
urllib.parse
import
urlparse
from
bs4
import
BeautifulSoup
jenkins_re
=
re
.
compile
(
r'/srv/jenkins-workspace/puppet-compiler/\d+/(production|change)'
)
def
main
():
url
=
sys
.
argv
[
1
]
if
not
url
.
endswith
(
"/"
):
url
+=
"/"
base_dir
=
os
.
path
.
join
(
os
.
curdir
,
urlparse
(
url
)
.
path
.
strip
(
"/"
))
prod_dir
=
os
.
path
.
join
(
base_dir
,
"prod"
)
change_dir
=
os
.
path
.
join
(
base_dir
,
"change"
)
os
.
makedirs
(
prod_dir
)
os
.
makedirs
(
change_dir
)
print
(
"Fetching
%s
"
%
url
)
with
urlopen
(
url
)
as
response
:
html
=
response
.
read
()
soup
=
BeautifulSoup
(
html
,
'html.parser'
)
h2
=
soup
.
find
(
'h2'
,
string
=
"Hosts that compile with differences"
)
assert
h2
is
not
None
ul
=
h2
.
next_sibling
.
next_sibling
assert
ul
.
name
==
'ul'
for
host
in
ul
.
find_all
(
'a'
):
hostname
=
host
.
text
prod
=
fetch_pson
(
"
%s
/
%s
/prod.
%s
.pson"
%
(
url
,
hostname
,
hostname
))
with
open
(
os
.
path
.
join
(
prod_dir
,
"
%s
.pson"
%
hostname
),
"w+"
)
as
f
:
f
.
write
(
prod
)
change
=
fetch_pson
(
"
%s
/
%s
/change.
%s
.pson"
%
(
url
,
hostname
,
hostname
))
with
open
(
os
.
path
.
join
(
change_dir
,
"
%s
.pson"
%
hostname
),
"w+"
)
as
f
:
f
.
write
(
change
)
os
.
system
(
"diff --color=auto -urN
%s
%s
"
%
(
prod_dir
,
change_dir
))
def
fetch_pson
(
url
):
pson
=
[]
with
urlopen
(
url
)
as
response
:
for
line
in
response
:
line_s
=
line
.
decode
(
"utf-8"
)
m
=
jenkins_re
.
search
(
line_s
)
if
m
:
line_s
=
line_s
[:
m
.
start
()]
+
line_s
[
m
.
end
():]
pson
.
append
(
line_s
)
return
""
.
join
(
pson
)
if
__name__
==
'__main__'
:
main
()
Event Timeline
Kormat
created this paste.
Jun 23 2020, 10:42 AM
2020-06-23 10:42:18 (UTC+0)
Kormat
mentioned this in
T256448: Add full pson diff to puppet-compiler output
.
Jun 26 2020, 7:39 AM
2020-06-26 07:39:02 (UTC+0)
Log In to Comment