diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-10-14 13:57:33 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-10-30 13:39:51 +0000 |
commit | 298c3d52bab5cf38c37438c54853d6803ca194bd (patch) | |
tree | 2113944f04d337bc6a2ddfd2484f95ab7ea2d775 /bitbake/lib/toaster/toastergui/views.py | |
parent | 2837b110ae8fd5ff0ca3ac5959cadb7d4a5ce6cc (diff) | |
download | poky-298c3d52bab5cf38c37438c54853d6803ca194bd.tar.gz |
bitbake: toastergui: provide download file capability
We add, for the localhost environments, the capability to
download build artifacts. This is a pontentially dangerous API,
because it gives unrestricted read access to the build environment
file system - do not expose the functionality directly to the
web layer, but use filtering/translation code, such as
exemplified in the build_artifact view.
The capability for remote build environments is dependent
on bug 6835, as to use the collect storage as intermediary
storage for serving files.
[YOCTO #6834]
(Bitbake rev: 5fce7f6e83c6143244faa9618b7ed20c1106e08f)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 38d67e378f..e568ee70ed 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2603,6 +2603,43 @@ if toastermain.settings.MANAGED: | |||
2603 | 2603 | ||
2604 | 2604 | ||
2605 | 2605 | ||
2606 | def build_artifact(request, build_id, artifact_type, artifact_id): | ||
2607 | try: | ||
2608 | b = Build.objects.get(pk=build_id) | ||
2609 | if b.buildrequest is None or b.buildrequest.environment is None: | ||
2610 | raise Exception("Cannot download file") | ||
2611 | |||
2612 | file_name = None | ||
2613 | fsock = None | ||
2614 | content_type='application/force-download' | ||
2615 | # Target_Image_File file_name | ||
2616 | # Task logfile | ||
2617 | if artifact_type == "tasklogfile": | ||
2618 | file_name = Task.objects.get(build = b, pk = artifact_id).logfile | ||
2619 | |||
2620 | # Task path_to_sstate_obj | ||
2621 | # Package_File path | ||
2622 | # Recipe file_path | ||
2623 | # VariableHistory file_name | ||
2624 | # LogMessage pathname | ||
2625 | if artifact_type == "logmessagefile": | ||
2626 | file_name = LogMessage.objects.get(build = b, pk = artifact_id).pathname | ||
2627 | |||
2628 | if file_name is not None: | ||
2629 | content_type = b.buildrequest.environment.get_artifact_type(file_name) | ||
2630 | fsock = b.buildrequest.environment.get_artifact(file_name) | ||
2631 | file_name = os.path.basename(file_name) | ||
2632 | |||
2633 | response = HttpResponse(fsock, content_type = content_type) | ||
2634 | |||
2635 | # returns a file from the environment | ||
2636 | response['Content-Disposition'] = 'attachment; filename=' + file_name | ||
2637 | return response | ||
2638 | except: | ||
2639 | raise | ||
2640 | |||
2641 | |||
2642 | |||
2606 | def projects(request): | 2643 | def projects(request): |
2607 | template="projects.html" | 2644 | template="projects.html" |
2608 | 2645 | ||
@@ -2725,5 +2762,8 @@ else: | |||
2725 | def projectbuilds(request): | 2762 | def projectbuilds(request): |
2726 | raise Exception("page not available in interactive mode") | 2763 | raise Exception("page not available in interactive mode") |
2727 | 2764 | ||
2765 | def build_artifact(request, build_id, artifact_type, artifact_id): | ||
2766 | raise Exception("page not available in interactive mode") | ||
2767 | |||
2728 | def projects(request): | 2768 | def projects(request): |
2729 | raise Exception("page not available in interactive mode") | 2769 | raise Exception("page not available in interactive mode") |