summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py49
1 files changed, 29 insertions, 20 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 1b3bb22e79..1521717482 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -76,21 +76,25 @@ class Project(models.Model):
76 def schedule_build(self): 76 def schedule_build(self):
77 from bldcontrol.models import BuildRequest, BRTarget, BRLayer, BRVariable, BRBitbake 77 from bldcontrol.models import BuildRequest, BRTarget, BRLayer, BRVariable, BRBitbake
78 br = BuildRequest.objects.create(project = self) 78 br = BuildRequest.objects.create(project = self)
79 try:
79 80
80 BRBitbake.objects.create(req = br, 81 BRBitbake.objects.create(req = br,
81 giturl = self.bitbake_version.giturl, 82 giturl = self.bitbake_version.giturl,
82 commit = self.bitbake_version.branch, 83 commit = self.bitbake_version.branch,
83 dirpath = self.bitbake_version.dirpath) 84 dirpath = self.bitbake_version.dirpath)
84 85
85 for l in self.projectlayer_set.all(): 86 for l in self.projectlayer_set.all():
86 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = l.layercommit.commit, dirpath = l.layercommit.dirpath) 87 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = l.layercommit.commit, dirpath = l.layercommit.dirpath)
87 for t in self.projecttarget_set.all(): 88 for t in self.projecttarget_set.all():
88 BRTarget.objects.create(req = br, target = t.target, task = t.task) 89 BRTarget.objects.create(req = br, target = t.target, task = t.task)
89 for v in self.projectvariable_set.all(): 90 for v in self.projectvariable_set.all():
90 BRVariable.objects.create(req = br, name = v.name, value = v.value) 91 BRVariable.objects.create(req = br, name = v.name, value = v.value)
91 92
92 br.state = BuildRequest.REQ_QUEUED 93 br.state = BuildRequest.REQ_QUEUED
93 br.save() 94 br.save()
95 except Exception as e:
96 br.delete()
97 raise e
94 return br 98 return br
95 99
96class Build(models.Model): 100class Build(models.Model):
@@ -131,7 +135,7 @@ class Build(models.Model):
131 135
132 def eta(self): 136 def eta(self):
133 from django.utils import timezone 137 from django.utils import timezone
134 eta = 0 138 eta = timezone.now()
135 completeper = self.completeper() 139 completeper = self.completeper()
136 if self.completeper() > 0: 140 if self.completeper() > 0:
137 eta = timezone.now() + ((timezone.now() - self.started_on)*(100-completeper)/completeper) 141 eta = timezone.now() + ((timezone.now() - self.started_on)*(100-completeper)/completeper)
@@ -534,12 +538,16 @@ class LayerIndexLayerSource(LayerSource):
534 def _get_json_response(apiurl = self.apiurl): 538 def _get_json_response(apiurl = self.apiurl):
535 import httplib, urlparse, json 539 import httplib, urlparse, json
536 parsedurl = urlparse.urlparse(apiurl) 540 parsedurl = urlparse.urlparse(apiurl)
537 (host, port) = parsedurl.netloc.split(":") 541 try:
542 (host, port) = parsedurl.netloc.split(":")
543 except ValueError:
544 host = parsedurl.netloc
545 port = None
546
538 if port is None: 547 if port is None:
539 port = 80 548 port = 80
540 else: 549 else:
541 port = int(port) 550 port = int(port)
542 #print "-- connect to: http://%s:%s%s?%s" % (host, port, parsedurl.path, parsedurl.query)
543 conn = httplib.HTTPConnection(host, port) 551 conn = httplib.HTTPConnection(host, port)
544 conn.request("GET", parsedurl.path + "?" + parsedurl.query) 552 conn.request("GET", parsedurl.path + "?" + parsedurl.query)
545 r = conn.getresponse() 553 r = conn.getresponse()
@@ -550,8 +558,9 @@ class LayerIndexLayerSource(LayerSource):
550 # verify we can get the basic api 558 # verify we can get the basic api
551 try: 559 try:
552 apilinks = _get_json_response() 560 apilinks = _get_json_response()
553 except: 561 except Exception as e:
554 print "EE: could not connect to %s, skipping update" % self.apiurl 562 import traceback
563 print "EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e))
555 return 564 return
556 565
557 # update branches; only those that we already have names listed in the database 566 # update branches; only those that we already have names listed in the database
@@ -582,7 +591,7 @@ class LayerIndexLayerSource(LayerSource):
582 591
583 # update layerbranches/layer_versions 592 # update layerbranches/layer_versions
584 layerbranches_info = _get_json_response(apilinks['layerBranches'] 593 layerbranches_info = _get_json_response(apilinks['layerBranches']
585 + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), Branch.objects.filter(layer_source = self))) 594 + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] ))
586 ) 595 )
587 for lbi in layerbranches_info: 596 for lbi in layerbranches_info:
588 lv, created = Layer_Version.objects.get_or_create(layer_source = self, 597 lv, created = Layer_Version.objects.get_or_create(layer_source = self,