diff options
Diffstat (limited to 'bitbake/lib/toaster/orm')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 131 |
1 files changed, 64 insertions, 67 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index bb921fc98e..77afe35861 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -402,6 +402,18 @@ class Recipe(models.Model): | |||
402 | bugtracker = models.URLField(blank=True) | 402 | bugtracker = models.URLField(blank=True) |
403 | file_path = models.FilePathField(max_length=255) | 403 | file_path = models.FilePathField(max_length=255) |
404 | 404 | ||
405 | def get_vcs_link_url(self): | ||
406 | if self.layer_version.layer.vcs_web_file_base_url is None: | ||
407 | return "" | ||
408 | return self.layer_version.layer.vcs_web_file_base_url.replace('%path%', self.file_path).replace('%branch%', self.layer_version.up_branch.name) | ||
409 | |||
410 | def get_layersource_view_url(self): | ||
411 | if self.layer_source is None: | ||
412 | return "" | ||
413 | |||
414 | url = self.layer_source.get_object_view(self.layer_version.up_branch, "recipes", self.name) | ||
415 | return url | ||
416 | |||
405 | def __unicode__(self): | 417 | def __unicode__(self): |
406 | return "Recipe " + self.name + ":" + self.version | 418 | return "Recipe " + self.name + ":" + self.version |
407 | 419 | ||
@@ -508,6 +520,11 @@ class LayerIndexLayerSource(LayerSource): | |||
508 | super(LayerIndexLayerSource, self).__init__(args, kwargs) | 520 | super(LayerIndexLayerSource, self).__init__(args, kwargs) |
509 | self.sourcetype = LayerSource.TYPE_LAYERINDEX | 521 | self.sourcetype = LayerSource.TYPE_LAYERINDEX |
510 | 522 | ||
523 | def get_object_view(self, branch, objectype, upid): | ||
524 | if self != branch.layer_source: | ||
525 | raise Exception("Invalid branch specification") | ||
526 | return self.apiurl + "../branch/" + branch.name + "/" + objectype + "/?q=" + str(upid) | ||
527 | |||
511 | def update(self): | 528 | def update(self): |
512 | ''' | 529 | ''' |
513 | Fetches layer, recipe and machine information from remote repository | 530 | Fetches layer, recipe and machine information from remote repository |
@@ -538,99 +555,79 @@ class LayerIndexLayerSource(LayerSource): | |||
538 | return | 555 | return |
539 | 556 | ||
540 | # update branches; only those that we already have names listed in the database | 557 | # update branches; only those that we already have names listed in the database |
541 | whitelist_branch_names = self.branchnames.split(",") | 558 | whitelist_branch_names = map(lambda x: x.name, Branch.objects.all()) |
542 | 559 | ||
543 | branches_info = _get_json_response(apilinks['branches'] | 560 | branches_info = _get_json_response(apilinks['branches'] |
544 | + "?filter=name:%s" % "OR".join(whitelist_branch_names)) | 561 | + "?filter=name:%s" % "OR".join(whitelist_branch_names)) |
545 | for bi in branches_info: | 562 | for bi in branches_info: |
546 | try: | 563 | b, created = Branch.objects.get_or_create(layer_source = self, name = bi['name']) |
547 | b = Branch.objects.get(layer_source = self, name = bi['name']) | 564 | b.up_id = bi['id'] |
548 | b.up_id = bi['id'] | 565 | b.up_date = bi['updated'] |
549 | b.up_date = bi['updated'] | 566 | b.name = bi['name'] |
550 | b.name = bi['name'] | 567 | b.bitbake_branch = bi['bitbake_branch'] |
551 | b.bitbake_branch = bi['bitbake_branch'] | 568 | b.short_description = bi['short_description'] |
552 | b.short_description = bi['short_description'] | 569 | b.save() |
553 | b.save() | ||
554 | except Branch.DoesNotExist: | ||
555 | b = Branch.objects.create( | ||
556 | layer_source = self, | ||
557 | up_id = bi['id'], | ||
558 | up_date = bi['updated'], | ||
559 | name = bi['name'], | ||
560 | bitbake_branch = bi['bitbake_branch'], | ||
561 | short_description = bi['short_description'] | ||
562 | ) | ||
563 | 570 | ||
564 | # update layers | 571 | # update layers |
565 | layers_info = _get_json_response(apilinks['layerItems']) | 572 | layers_info = _get_json_response(apilinks['layerItems']) |
566 | for li in layers_info: | 573 | for li in layers_info: |
567 | try: | 574 | l, created = Layer.objects.get_or_create(layer_source = self, up_id = li['id']) |
568 | l = Layer.objects.get(layer_source = self, | 575 | l.up_date = li['updated'] |
569 | up_id = li['id']) | 576 | l.name = li['name'] |
570 | l.update( | 577 | l.vcs_url = li['vcs_url'] |
571 | up_date = li['updated'], | 578 | l.vcs_web_file_base_url = li['vcs_web_file_base_url'] |
572 | name = li['name'], | 579 | l.summary = li['summary'] |
573 | vcs_url = li['vcs_url'], | 580 | l.description = li['description'] |
574 | vcs_web_file_base_url = li['vcs_url'], | 581 | l.save() |
575 | summary = li['summary'], | ||
576 | description = li['description']) | ||
577 | except Layer.DoesNotExist: | ||
578 | Layer.objects.create(layer_source = self, | ||
579 | up_id = li['id'], | ||
580 | up_date = li['updated'], | ||
581 | name = li['name'], | ||
582 | vcs_url = li['vcs_url'], | ||
583 | vcs_web_file_base_url = li['vcs_url'], | ||
584 | summary = li['summary'], | ||
585 | description = li['description'] | ||
586 | ) | ||
587 | 582 | ||
588 | # update layerbranches/layer_versions | 583 | # update layerbranches/layer_versions |
589 | layerbranches_info = _get_json_response(apilinks['layerBranches'] | 584 | layerbranches_info = _get_json_response(apilinks['layerBranches'] |
590 | + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), Branch.objects.filter(layer_source = self))) | 585 | + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), Branch.objects.filter(layer_source = self))) |
591 | ) | 586 | ) |
592 | for lbi in layerbranches_info: | 587 | for lbi in layerbranches_info: |
593 | Layer_Version.objects.get_or_create(layer_source = self, | 588 | lv, created = Layer_Version.objects.get_or_create(layer_source = self, up_id = lbi['id']) |
594 | up_id = lbi['id'], | 589 | |
595 | up_date = lbi['updated'], | 590 | lv.up_date = lbi['updated'] |
596 | layer = Layer.objects.get(layer_source = self, up_id = lbi['layer']), | 591 | lv.layer = Layer.objects.get(layer_source = self, up_id = lbi['layer']) |
597 | up_branch = Branch.objects.get(layer_source = self, up_id = lbi['branch']), | 592 | lv.up_branch = Branch.objects.get(layer_source = self, up_id = lbi['branch']) |
598 | branch = lbi['actual_branch'], | 593 | lv.branch = lbi['actual_branch'] |
599 | commit = lbi['vcs_last_rev'], | 594 | lv.commit = lbi['vcs_last_rev'] |
600 | dirpath = lbi['vcs_subdir']) | 595 | lv.dirpath = lbi['vcs_subdir'] |
596 | lv.save() | ||
597 | |||
601 | 598 | ||
602 | # update machines | 599 | # update machines |
603 | machines_info = _get_json_response(apilinks['machines'] | 600 | machines_info = _get_json_response(apilinks['machines'] |
604 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) | 601 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) |
605 | ) | 602 | ) |
606 | for mi in machines_info: | 603 | for mi in machines_info: |
607 | Machine.objects.get_or_create(layer_source = self, | 604 | mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id']) |
608 | up_id = mi['id'], | 605 | mo.up_date = mi['updated'] |
609 | up_date = mi['updated'], | 606 | mo.layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']) |
610 | layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']), | 607 | mo.name = mi['name'] |
611 | name = mi['name'], | 608 | mo.description = mi['description'] |
612 | description = mi['description']) | 609 | mo.save() |
613 | 610 | ||
614 | # update recipes; paginate by layer version / layer branch | 611 | # update recipes; paginate by layer version / layer branch |
615 | recipes_info = _get_json_response(apilinks['recipes'] | 612 | recipes_info = _get_json_response(apilinks['recipes'] |
616 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) | 613 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) |
617 | ) | 614 | ) |
618 | for ri in recipes_info: | 615 | for ri in recipes_info: |
619 | Recipe.objects.get_or_create(layer_source = self, | 616 | ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id']) |
620 | up_id = ri['id'], | 617 | |
621 | up_date = ri['updated'], | 618 | ro.up_date = ri['updated'] |
622 | layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']), | 619 | ro.layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']) |
623 | 620 | ||
624 | name = ri['pn'], | 621 | ro.name = ri['pn'] |
625 | version = ri['pv'], | 622 | ro.version = ri['pv'] |
626 | summary = ri['summary'], | 623 | ro.summary = ri['summary'] |
627 | description = ri['description'], | 624 | ro.description = ri['description'] |
628 | section = ri['section'], | 625 | ro.section = ri['section'] |
629 | license = ri['license'], | 626 | ro.license = ri['license'] |
630 | homepage = ri['homepage'], | 627 | ro.homepage = ri['homepage'] |
631 | bugtracker = ri['bugtracker'], | 628 | ro.bugtracker = ri['bugtracker'] |
632 | file_path = ri['filepath'] + ri['filename'] | 629 | ro.file_path = ri['filepath'] + ri['filename'] |
633 | ) | 630 | ro.save() |
634 | 631 | ||
635 | pass | 632 | pass |
636 | 633 | ||