diff options
| author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-02-16 17:47:07 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-20 12:58:19 +0000 |
| commit | c368d83bd6b34c2420c3d1d7269d8dc2edba1ce9 (patch) | |
| tree | d6a905444fe2ea0f0313bc4b848430108ac17388 /bitbake/lib/toaster/bldcontrol/management/commands | |
| parent | a574f293fe16612df446d3b7fef71adcab4773e9 (diff) | |
| download | poky-c368d83bd6b34c2420c3d1d7269d8dc2edba1ce9.tar.gz | |
bitbake: toaster: bitbake cooker log saving and downloading
This patch brings in cooker log saving and proper download links.
* toasterui will now write the cooker log file if running in managed
mode
* the BuildRequest has a new state, REQ_ARCHIVE, indicating that the
build is completed, and the artifacts are ready to be grabbed
* the runbuild test execution commands will gather needed artifacts,
and save them to a storage directory selected during Toaster setup.
* the build dashboard, project builds and all builds pages have
permanent links for the cooker log
[YOCTO #7220]
[YOCTO #7206]
(Bitbake rev: fad80e36c9da663b000cdf2cb3c75440c6431d84)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/management/commands')
| -rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | 17 | ||||
| -rw-r--r-- | bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py | 29 |
2 files changed, 45 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py index 5d80bc7155..1ff5c92833 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py | |||
| @@ -62,6 +62,23 @@ class Command(NoArgsCommand): | |||
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | def handle(self, **options): | 64 | def handle(self, **options): |
| 65 | # verify that we have a settings for downloading artifacts | ||
| 66 | while ToasterSetting.objects.filter(name="ARTIFACTS_STORAGE_DIR").count() == 0: | ||
| 67 | guessedpath = os.getcwd() + "/toaster_build_artifacts/" | ||
| 68 | print("Toaster needs to know in which directory it can download build log files and other artifacts.\n Toaster suggests \"%s\"." % guessedpath) | ||
| 69 | artifacts_storage_dir = raw_input(" Press Enter to select \"%s\" or type the full path to a different directory: " % guessedpath) | ||
| 70 | if len(artifacts_storage_dir) == 0: | ||
| 71 | artifacts_storage_dir = guessedpath | ||
| 72 | if len(artifacts_storage_dir) > 0 and artifacts_storage_dir.startswith("/"): | ||
| 73 | try: | ||
| 74 | os.makedirs(artifacts_storage_dir) | ||
| 75 | except OSError as ose: | ||
| 76 | if "File exists" in str(ose): | ||
| 77 | pass | ||
| 78 | else: | ||
| 79 | raise ose | ||
| 80 | ToasterSetting.objects.create(name="ARTIFACTS_STORAGE_DIR", value=artifacts_storage_dir) | ||
| 81 | |||
| 65 | self.guesspath = DN(DN(DN(DN(DN(DN(DN(__file__))))))) | 82 | self.guesspath = DN(DN(DN(DN(DN(DN(DN(__file__))))))) |
| 66 | # refuse to start if we have no build environments | 83 | # refuse to start if we have no build environments |
| 67 | while BuildEnvironment.objects.count() == 0: | 84 | while BuildEnvironment.objects.count() == 0: |
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py index 3de582cc86..808318f14f 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | from django.core.management.base import NoArgsCommand, CommandError | 1 | from django.core.management.base import NoArgsCommand, CommandError |
| 2 | from django.db import transaction | 2 | from django.db import transaction |
| 3 | from orm.models import Build | 3 | from orm.models import Build, ToasterSetting |
| 4 | from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException | 4 | from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException |
| 5 | from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable | 5 | from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable |
| 6 | import os | 6 | import os |
| @@ -93,7 +93,33 @@ class Command(NoArgsCommand): | |||
| 93 | bec.be.lock = BuildEnvironment.LOCK_FREE | 93 | bec.be.lock = BuildEnvironment.LOCK_FREE |
| 94 | bec.be.save() | 94 | bec.be.save() |
| 95 | 95 | ||
| 96 | def archive(self): | ||
| 97 | ''' archives data from the builds ''' | ||
| 98 | artifact_storage_dir = ToasterSetting.objects.get(name="ARTIFACTS_STORAGE_DIR").value | ||
| 99 | for br in BuildRequest.objects.filter(state = BuildRequest.REQ_ARCHIVE): | ||
| 100 | # save cooker log | ||
| 101 | if br.build == None: | ||
| 102 | br.state = BuildRequest.REQ_FAILED | ||
| 103 | br.save() | ||
| 104 | continue | ||
| 105 | build_artifact_storage_dir = os.path.join(artifact_storage_dir, "%d" % br.build.pk) | ||
| 106 | try: | ||
| 107 | os.makedirs(build_artifact_storage_dir) | ||
| 108 | except OSError as ose: | ||
| 109 | if "File exists" in str(ose): | ||
| 110 | pass | ||
| 111 | else: | ||
| 112 | raise ose | ||
| 113 | |||
| 114 | file_name = os.path.join(build_artifact_storage_dir, "cooker_log.txt") | ||
| 115 | try: | ||
| 116 | with open(file_name, "w") as f: | ||
| 117 | f.write(br.environment.get_artifact(br.build.cooker_log_path).read()) | ||
| 118 | except IOError: | ||
| 119 | os.unlink(file_name) | ||
| 96 | 120 | ||
| 121 | br.state = BuildRequest.REQ_COMPLETED | ||
| 122 | br.save() | ||
| 97 | 123 | ||
| 98 | def cleanup(self): | 124 | def cleanup(self): |
| 99 | from django.utils import timezone | 125 | from django.utils import timezone |
| @@ -104,4 +130,5 @@ class Command(NoArgsCommand): | |||
| 104 | 130 | ||
| 105 | def handle_noargs(self, **options): | 131 | def handle_noargs(self, **options): |
| 106 | self.cleanup() | 132 | self.cleanup() |
| 133 | self.archive() | ||
| 107 | self.schedule() | 134 | self.schedule() |
