aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2015-06-08 10:20:18 -0500
committerAndy Doan <andy.doan@linaro.org>2015-07-16 10:18:13 -0500
commit601bc17047b33a63c2b2875a3d3039038625ee41 (patch)
treed1864bbe09d6035d2d36e3fd99a83eaacf2db584
parent4f022a9309ebe7df573169681cd5b395ef379d97 (diff)
move render_descriptions to work with artifact object
needed for s3. With the patch, views.py no longer uses any local paths in its logic! Along with the added unit test case, this can also be tested in the local sampleroot at: ~linaro-android/staging-panda and in production at (looks like this feature hasn't been used in a build since 2014.10): http://releases.linaro.org/14.10/android/images/nexus10-linaro/ Change-Id: I7b8b8e7ebe216942c3239cd115f4340c63c70108
-rw-r--r--license_protected_downloads/common.py4
-rw-r--r--license_protected_downloads/tests/test_views.py6
-rw-r--r--license_protected_downloads/tests/testserver_root/~linaro-android/staging-panda/source-manifest-ann.xml14
-rw-r--r--license_protected_downloads/views.py18
4 files changed, 32 insertions, 10 deletions
diff --git a/license_protected_downloads/common.py b/license_protected_downloads/common.py
index f9b412d..bc90aa4 100644
--- a/license_protected_downloads/common.py
+++ b/license_protected_downloads/common.py
@@ -347,6 +347,10 @@ class Artifact(object):
content = '\n'.join(content.split('\n')[1:-1])
return content
+ def get_annotated_manifest(self):
+ assert self.isdir()
+ return self.get_file_contents(settings.ANNOTATED_XML)
+
class LocalArtifact(Artifact):
'''An artifact that lives on the local filesystem'''
diff --git a/license_protected_downloads/tests/test_views.py b/license_protected_downloads/tests/test_views.py
index e04e76f..5118fbb 100644
--- a/license_protected_downloads/tests/test_views.py
+++ b/license_protected_downloads/tests/test_views.py
@@ -397,6 +397,12 @@ class ViewTests(BaseServeViewTest):
self.assertContains(
response, r"Welcome to the Linaro releases server")
+ def test_render_descriptions(self):
+ url = 'http://testserver/~linaro-android/staging-panda/'
+ resp = self.client.get(url, follow=True)
+ self.assertEquals(200, resp.status_code)
+ self.assertIn('<a href="#tabs-2">Git Descriptions</a>', resp.content)
+
def test_exception_internal_host_for_lic(self):
internal_host = INTERNAL_HOSTS[0]
target_file = 'build-info/origen-blob.txt'
diff --git a/license_protected_downloads/tests/testserver_root/~linaro-android/staging-panda/source-manifest-ann.xml b/license_protected_downloads/tests/testserver_root/~linaro-android/staging-panda/source-manifest-ann.xml
new file mode 100644
index 0000000..c531f7a
--- /dev/null
+++ b/license_protected_downloads/tests/testserver_root/~linaro-android/staging-panda/source-manifest-ann.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest>
+
+<project groups="pdk" name="platform/external/libnfc-nxp" path="external/libnfc-nxp" revision="15d81f71a668b3092549c6b7f83694bf680d9c49"/>
+<!-- Project: Non AOSP project. Supporting obsolete AOSP libnl project -->
+<project name="platform/external/libnl" path="external/libnl" revision="99debfa4c01b49c9b470884cc56f81fcdee0fa1f"/>
+<project groups="pdk" name="platform/external/sonivox" path="external/sonivox" revision="c0723d864b10fbd6c5cbbfa65e886c5e9eb3aafd"/>
+<!-- Project: Non AOSP project. Open Source speech codec. Linaro monifications include making project build as a shared library, build resampler plugin and few additional NEON patches. -->
+<project groups="pdk" name="platform/external/speex" path="external/speex" revision="eaa4765b8cc6a6dd5ee0d26dc1b61a1044817f32"/>
+<project name="platform/external/strace" path="external/strace" revision="a2adbed6e2d3ce85ebb167e16ae370681a8b5188"/>
+<!-- Project: stressapptest tries to maximize randomized traffic to memory from processor and I/O, with the intent of creating a realistic high load situation in order to stress test the device. Also used in cache-coherency testing. -->
+<project name="platform/external/stressapptest" path="external/stressapptest" revision="0956427aa995561acb4471764158ae057a36dad5"/>
+
+</manifest>
diff --git a/license_protected_downloads/views.py b/license_protected_downloads/views.py
index 5d98288..9f7fd18 100644
--- a/license_protected_downloads/views.py
+++ b/license_protected_downloads/views.py
@@ -161,13 +161,13 @@ def _handle_dir_list(request, artifact):
else:
up_dir = None
- path = artifact.full_path
download = None
if 'dl' in request.GET:
download = request.GET['dl']
rendered_files = RenderTextFiles.find_and_render(artifact)
- if os.path.exists(os.path.join(path, settings.ANNOTATED_XML)):
- rendered_files["Git Descriptions"] = render_descriptions(path)
+ ann = artifact.get_annotated_manifest()
+ if ann:
+ rendered_files["Git Descriptions"] = render_descriptions(ann)
dirlist = dir_list(artifact)
lics = [x['license_digest_list'] for x in dirlist
@@ -239,15 +239,14 @@ def file_server_get(request, path):
def get_textile_files(request):
artifact = find_artifact(request, request.GET.get("path"))
rendered_files = RenderTextFiles.find_and_render(artifact)
- if os.path.exists(os.path.join(artifact.full_path, settings.ANNOTATED_XML)):
- if rendered_files is None:
- rendered_files = {}
- rendered_files["Git Descriptions"] = render_descriptions(artifact.full_path)
+ ann = artifact.get_annotated_manifest()
+ if ann:
+ rendered_files["Git Descriptions"] = render_descriptions(ann)
return HttpResponse(json.dumps(rendered_files))
-def render_descriptions(path):
+def render_descriptions(buf):
"""
Extracts project name and its description from annotated source manifest
and returns html string to include in tab.
@@ -255,8 +254,7 @@ def render_descriptions(path):
text = ''
line = '<p><strong>Project:</strong> "%s"<br>' \
'<strong>Description:</strong> "%s"</p>'
- filename = os.path.join(path, settings.ANNOTATED_XML)
- xmldoc = dom.parse(filename)
+ xmldoc = dom.parseString(buf)
nodes = xmldoc.documentElement.childNodes
for index, node in enumerate(nodes):