651 doc.bom.content.input.xml_append(doc.xml_create_element(u'week', content=(unicode(empty_bom_tm)))) |
641 doc.bom.content.input.xml_append(doc.xml_create_element(u'week', content=(unicode(empty_bom_tm)))) |
652 doc.bom.content.input.xml_append(doc.xml_create_element(u'version', content=(unicode(empty_bom_str)))) |
642 doc.bom.content.input.xml_append(doc.xml_create_element(u'version', content=(unicode(empty_bom_str)))) |
653 |
643 |
654 doc.bom.content.input.xml_append(doc.xml_create_element(u'icds')) |
644 doc.bom.content.input.xml_append(doc.xml_create_element(u'icds')) |
655 |
645 |
656 # pylint: disable-msg=R0914 |
646 # pylint: disable=R0914 |
657 for i, icd in enumerate(self._bom._icd_icfs): |
647 for i, icd in enumerate(self._bom.icd_icfs): |
658 doc.bom.content.input.icds.xml_append(doc.xml_create_element(u'icd')) |
648 doc.bom.content.input.icds.xml_append(doc.xml_create_element(u'icd')) |
659 doc.bom.content.input.icds.icd[i].xml_append(doc.xml_create_element(u'name', content=(unicode(icd)))) |
649 doc.bom.content.input.icds.icd[i].xml_append(doc.xml_create_element(u'name', content=(unicode(icd)))) |
660 #If currentRelease.xml exists then send s60 <input> tag to diamonds |
650 #If currentRelease.xml exists then send s60 <input> tag to diamonds |
661 current_release_xml_path = self._bom.config['currentRelease.xml'] |
651 current_release_xml_path = self._bom.config['currentRelease.xml'] |
|
652 # data from the metadata will go first as they must be safer than the one |
|
653 # given by the user |
662 if current_release_xml_path is not None and os.path.exists(current_release_xml_path): |
654 if current_release_xml_path is not None and os.path.exists(current_release_xml_path): |
663 metadata = symrec.ReleaseMetadata(current_release_xml_path) |
655 metadata = symrec.ReleaseMetadata(current_release_xml_path) |
664 service = metadata.service |
656 service = metadata.service |
665 product = metadata.product |
657 product = metadata.product |
666 release = metadata.release |
658 release = metadata.release |
667 # Get name, year, week and version from baseline configuration |
659 # Get name, year, week and version from baseline configuration |
668 s60_input_node = doc.xml_create_element(u'input') |
660 s60_input_node = doc.xml_create_element(u'input') |
669 s60_version = self._bom.config['s60_version'] |
661 s60_type = u's60' |
670 s60_release = self._bom.config['s60_release'] |
662 s60_year = u'0' |
671 if s60_version != None: |
663 s60_week = u'0' |
672 s60_year = s60_version[0:4] |
664 s60_release = u'' |
673 s60_week = s60_version[4:] |
665 # Using regular expression in first place |
|
666 regexp = r'(?P<TYPE>.*)_(?P<YEAR>\d{4})(?P<WEEK>\d{2})_(?P<REVISION>.*)' |
|
667 if self._bom.config['release_regexp']: |
|
668 if '?P<TYPE>' not in self._bom.config['release_regexp']: |
|
669 _logger.error('Missing TYPE in: %s' % str(self._bom.config['release_regexp'])) |
|
670 _logger.info('Using default regular expression: %s' % regexp) |
|
671 elif '?P<YEAR>' not in self._bom.config['release_regexp']: |
|
672 _logger.error('Missing YEAR in: %s' % str(self._bom.config['release_regexp'])) |
|
673 _logger.info('Using default regular expression: %s' % regexp) |
|
674 elif '?P<WEEK>' not in self._bom.config['release_regexp']: |
|
675 _logger.error('Missing WEEK in: %s' % str(self._bom.config['release_regexp'])) |
|
676 _logger.info('Using default regular expression: %s' % regexp) |
|
677 elif '?P<REVISION>' not in self._bom.config['release_regexp']: |
|
678 _logger.error('Missing REVISION in: %s' % str(self._bom.config['release_regexp'])) |
|
679 _logger.info('Using default regular expression: %s' % regexp) |
|
680 else: |
|
681 _logger.info('Using custom regular expression to capture the baseline release information: %s' |
|
682 % str(self._bom.config['release_regexp'])) |
|
683 regexp = self._bom.config['release_regexp'] |
|
684 res = re.match(regexp, release) |
|
685 if res != None: |
|
686 s60_type = res.group('TYPE') |
|
687 s60_release = res.group('TYPE') + '_' + res.group('REVISION') |
|
688 s60_year = res.group('YEAR') |
|
689 s60_week = res.group('WEEK') |
674 else: |
690 else: |
675 s60_year = u'0' |
691 _logger.warning("Regular expression '%s' is not matching '%s'." % (regexp, release)) |
676 s60_week = u'0' |
692 if self._bom.config['s60_version'] != None: |
677 if s60_version == None: |
693 # last resorts if it doesn't matches |
678 res = re.match(r'(.*)_(\d{4})(\d{2})_(.*)', release) |
694 _logger.warning("Falling back on s60.version and s60.release to determine input.") |
679 if res != None: |
695 s60_version = self._bom.config['s60_version'] |
680 s60_release = res.group(1) + '_' + res.group(4) |
696 s60_year = s60_version[0:4] |
681 s60_year = res.group(2) |
697 s60_week = s60_version[4:] |
682 s60_week = res.group(3) |
698 if self._bom.config['s60_release']: |
683 s60_input_node.xml_append(doc.xml_create_element(u'name', content=(unicode("s60")))) |
699 s60_release = self._bom.config['s60_release'] |
|
700 |
|
701 s60_input_node.xml_append(doc.xml_create_element(u'name', content=(unicode(s60_type)))) |
684 s60_input_node.xml_append(doc.xml_create_element(u'year', content=(unicode(s60_year)))) |
702 s60_input_node.xml_append(doc.xml_create_element(u'year', content=(unicode(s60_year)))) |
685 s60_input_node.xml_append(doc.xml_create_element(u'week', content=(unicode(s60_week)))) |
703 s60_input_node.xml_append(doc.xml_create_element(u'week', content=(unicode(s60_week)))) |
686 s60_input_node.xml_append(doc.xml_create_element(u'version', content=(unicode(s60_release)))) |
704 s60_input_node.xml_append(doc.xml_create_element(u'version', content=(unicode(s60_release)))) |
687 |
705 |
688 s60_input_source = s60_input_node.xml_create_element(u'source') |
706 s60_input_source = s60_input_node.xml_create_element(u'source') |
689 s60_input_source.xml_append(doc.xml_create_element(u'type', content=(unicode("grace")))) |
707 s60_input_source.xml_append(doc.xml_create_element(u'type', content=(unicode("hydra")))) |
690 s60_input_source.xml_append(doc.xml_create_element(u'service', content=(unicode(service)))) |
708 s60_input_source.xml_append(doc.xml_create_element(u'service', content=(unicode(service)))) |
691 s60_input_source.xml_append(doc.xml_create_element(u'product', content=(unicode(product)))) |
709 s60_input_source.xml_append(doc.xml_create_element(u'product', content=(unicode(product)))) |
692 s60_input_source.xml_append(doc.xml_create_element(u'release', content=(unicode(release)))) |
710 s60_input_source.xml_append(doc.xml_create_element(u'release', content=(unicode(release)))) |
693 s60_input_node.xml_append(s60_input_source) |
711 s60_input_node.xml_append(s60_input_source) |
694 doc.bom.content.xml_append(s60_input_node) |
712 doc.bom.content.xml_append(s60_input_node) |
|
713 elif self._bom.config['s60_version'] and self._bom.config['s60_release']: |
|
714 _logger.info("currentRelease.xml not defined, falling back on s60.version and s60.release to determine input.") |
|
715 s60_type = u's60' |
|
716 s60_version = self._bom.config['s60_version'] |
|
717 s60_year = u'0' |
|
718 s60_week = u'0' |
|
719 if len(s60_version) > 6: |
|
720 s60_year = s60_version[0:4] |
|
721 s60_week = s60_version[4:] |
|
722 s60_release = self._bom.config['s60_release'] |
|
723 s60_input_node = doc.xml_create_element(u'input') |
|
724 s60_input_node.xml_append(doc.xml_create_element(u'name', content=(unicode(s60_type)))) |
|
725 s60_input_node.xml_append(doc.xml_create_element(u'year', content=(unicode(s60_year)))) |
|
726 s60_input_node.xml_append(doc.xml_create_element(u'week', content=(unicode(s60_week)))) |
|
727 s60_input_node.xml_append(doc.xml_create_element(u'version', content=(unicode(s60_release)))) |
|
728 |
|
729 s60_input_source = s60_input_node.xml_create_element(u'source') |
|
730 s60_input_source.xml_append(doc.xml_create_element(u'type', content=(unicode("unknown")))) |
|
731 s60_input_node.xml_append(s60_input_source) |
|
732 doc.bom.content.xml_append(s60_input_node) |
|
733 |
|
734 |
695 out = open(path, 'w') |
735 out = open(path, 'w') |
696 doc.xml(out, indent='yes') |
736 doc.xml(out, indent='yes') |
697 out.close() |
737 out.close() |
698 |
738 |
699 def parse_status_log(self, log): |
739 def parse_status_log(self, log): |