Add pdf file link in build result page

Now, openstack manual builds supports build a pdf file.
But, The build result page of zenkins does not show pdf files.

This patch adds a pdf file link for manual in build result page.

Change-Id: I5043c582c5a09cf8a8976a05a0ba65a007fcf20f
Depends-On: I66242f44bb13f1a09be0904a491c84f42f25c3a2
Implements: blueprint build-pdf-from-rst-guides
This commit is contained in:
SeongSoo Cho 2016-12-14 02:22:12 +09:00
parent 7cb8a0f545
commit 28bedc4c87
1 changed files with 19 additions and 6 deletions

View File

@ -13,10 +13,21 @@
# under the License.
import argparse
import glob
import os
import sys
def get_pdf_link(root, publish_path):
p = '%s/*.pdf' % root
re = glob.glob(p)
if len(re) == 0:
return ''
filename = os.path.basename(re[0])
path = os.path.relpath(root, publish_path)
return ' <a href="%s/%s">(pdf)</a>' % (path, filename)
def generate_index_file(publish_path):
"""Generate index.html file in publish_path."""
@ -42,19 +53,21 @@ def generate_index_file(publish_path):
if root == publish_path:
continue
pdf_link = get_pdf_link(root, publish_path)
if os.path.isfile(os.path.join(root, 'content/index.html')):
path = os.path.relpath(root, publish_path)
links[path] = ('<a href="%s/content/index.html">%s</a>\n' %
(path, path))
links[path] = ('<a href="%s/content/index.html">%s</a>%s\n' %
(path, path, pdf_link))
elif os.path.isfile(os.path.join(root, 'index.html')):
path = os.path.relpath(root, publish_path)
links[path] = ('<a href="%s/index.html">%s</a>\n' %
(path, path.replace('draft/', '')))
links[path] = ('<a href="%s/index.html">%s</a>%s\n' %
(path, path.replace('draft/', ''), pdf_link))
if os.path.isfile(os.path.join(root, 'api-ref.html')):
path = os.path.relpath(root, publish_path)
links[path] = ('<a href="%s/api-ref.html">%s</a>\n' %
(path, path))
links[path] = ('<a href="%s/api-ref.html">%s</a>%s\n' %
(path, path, pdf_link))
# List PDF files for api-site that have from "bk-api-ref*.pdf"
# as well since they have no corresponding html file.