summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py29
1 files changed, 28 insertions, 1 deletions
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 @@
1from django.core.management.base import NoArgsCommand, CommandError 1from django.core.management.base import NoArgsCommand, CommandError
2from django.db import transaction 2from django.db import transaction
3from orm.models import Build 3from orm.models import Build, ToasterSetting
4from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException 4from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException, BuildSetupException
5from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable 5from bldcontrol.models import BuildRequest, BuildEnvironment, BRError, BRVariable
6import os 6import 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()