mirror of
git://git.yoctoproject.org/yocto-autobuilder2.git
synced 2025-07-19 20:59:02 +02:00
wikilog: Allow footer of archived logs
Preseve a footer 'Archived Logs' section at the end of the BuildLog wiki page. This will be later used for archiving purposes. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
31f297e026
commit
6a4cebdfee
11
lib/wiki.py
11
lib/wiki.py
|
@ -136,15 +136,20 @@ class YPWiki(object):
|
||||||
|
|
||||||
parsed = self.parse_json(req)
|
parsed = self.parse_json(req)
|
||||||
pageid = sorted(parsed['query']['pages'].keys())[-1]
|
pageid = sorted(parsed['query']['pages'].keys())[-1]
|
||||||
blurb, entries = "\n", ""
|
blurb, entries, footer = "\n", "", "\n==Archived Logs=="
|
||||||
if 'revisions' in parsed['query']['pages'][pageid]:
|
if 'revisions' in parsed['query']['pages'][pageid]:
|
||||||
content = parsed['query']['pages'][pageid]['revisions'][0]['*']
|
content = parsed['query']['pages'][pageid]['revisions'][0]['*']
|
||||||
blurb, entries = content.split('==', 1)
|
blurb, entries = content.split('==', 1)
|
||||||
# ensure we keep only a single newline after the blurb
|
# ensure we keep only a single newline after the blurb
|
||||||
blurb = blurb.strip() + "\n"
|
blurb = blurb.strip() + "\n"
|
||||||
entries = '=='+entries
|
entries = '==' + entries
|
||||||
|
try:
|
||||||
|
entries, footer = entries.rsplit('\n==Archived Logs==', 1)
|
||||||
|
footer = '\n==Archived Logs==' + footer
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
return blurb, entries
|
return blurb, entries, footer
|
||||||
|
|
||||||
def post_entry(self, wiki_page, content, summary, cookies):
|
def post_entry(self, wiki_page, content, summary, cookies):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -159,19 +159,19 @@ class WikiLog(service.BuildbotService):
|
||||||
content = content + '* ' + forcedby + '\n* ' + reason + '\n'
|
content = content + '* ' + forcedby + '\n* ' + reason + '\n'
|
||||||
new_entry = '{}\n{}\n'.format(section_title, content)
|
new_entry = '{}\n{}\n'.format(section_title, content)
|
||||||
|
|
||||||
blurb, entries = self.wiki.get_content(self.wiki_page)
|
blurb, entries, footer = self.wiki.get_content(self.wiki_page)
|
||||||
if not blurb:
|
if not blurb:
|
||||||
log.err("wkl: Unexpected content retrieved from wiki!")
|
log.err("wkl: Unexpected content retrieved from wiki!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
entries = new_entry + entries
|
content = blurb + new_entry + entries + footer
|
||||||
cookies = self.wiki.login()
|
cookies = self.wiki.login()
|
||||||
|
|
||||||
if not cookies:
|
if not cookies:
|
||||||
log.err("wkl: Failed to login to wiki")
|
log.err("wkl: Failed to login to wiki")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
post = self.wiki.post_entry(self.wiki_page, blurb+entries, summary, cookies)
|
post = self.wiki.post_entry(self.wiki_page, content, summary, cookies)
|
||||||
if not post:
|
if not post:
|
||||||
log.err("wkl: Failed to post entry for %s" % buildid)
|
log.err("wkl: Failed to post entry for %s" % buildid)
|
||||||
return False
|
return False
|
||||||
|
@ -248,7 +248,7 @@ class WikiLog(service.BuildbotService):
|
||||||
|
|
||||||
log.err("wkl: Starting to update entry for %s(%s)" % (buildid, parent['buildid']))
|
log.err("wkl: Starting to update entry for %s(%s)" % (buildid, parent['buildid']))
|
||||||
|
|
||||||
blurb, entries = self.wiki.get_content(self.wiki_page)
|
blurb, entries, footer = self.wiki.get_content(self.wiki_page)
|
||||||
if not blurb:
|
if not blurb:
|
||||||
log.err("wkl: Unexpected content retrieved from wiki!")
|
log.err("wkl: Unexpected content retrieved from wiki!")
|
||||||
return False
|
return False
|
||||||
|
@ -310,14 +310,14 @@ class WikiLog(service.BuildbotService):
|
||||||
# There was no following entry
|
# There was no following entry
|
||||||
tail = ""
|
tail = ""
|
||||||
|
|
||||||
update = head + "==[" + new_title + "]==\n" + new_entry + tail
|
update = blurb + head + "==[" + new_title + "]==\n" + new_entry + tail + footer
|
||||||
|
|
||||||
cookies = self.wiki.login()
|
cookies = self.wiki.login()
|
||||||
if not cookies:
|
if not cookies:
|
||||||
log.err("wkl: Failed to login to wiki")
|
log.err("wkl: Failed to login to wiki")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
post = self.wiki.post_entry(self.wiki_page, blurb+update, summary, cookies)
|
post = self.wiki.post_entry(self.wiki_page, update, summary, cookies)
|
||||||
if not post:
|
if not post:
|
||||||
log.err("wkl: Failed to update entry for %s(%s)" % (buildid, parent['buildid']))
|
log.err("wkl: Failed to update entry for %s(%s)" % (buildid, parent['buildid']))
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user