buildframework/helium/sf/python/pythoncore/lib/atsant.py
branchhelium-9.0
changeset 618 df88fead2976
parent 587 85df38eb4012
equal deleted inserted replaced
587:85df38eb4012 618:df88fead2976
    29 
    29 
    30 _logger = logging.getLogger('atsant')
    30 _logger = logging.getLogger('atsant')
    31 
    31 
    32 class IConfigATS(object):
    32 class IConfigATS(object):
    33     """ Class used to read configuration file iconfig.xml """
    33     """ Class used to read configuration file iconfig.xml """
    34     def __init__(self, imagesdir):
    34     def __init__(self, imagesdir, productname):
    35         self.imagesdir = imagesdir
    35         self.imagesdir = imagesdir
       
    36         self.productname = productname
    36         self.config = self.getconfig()
    37         self.config = self.getconfig()
    37         
    38         
    38     def getconfig(self, type=None):
    39     def getconfig(self, type=None, productname=None):
    39         """get configuration"""
    40         """get configuration"""
    40         noncust = None
    41         noncust = None
    41         for root, _, files in os.walk(self.imagesdir, topdown=False):
    42         for root, _, files in os.walk(self.imagesdir, topdown=False):
    42             for fname in files:
    43             for fname in files:
    43                 if 'iconfig.xml' in fname:
    44                 if 'iconfig.xml' in fname:
    44                     filePath = os.path.join(root, fname)
    45                     filePath = os.path.join(root, fname)
    45                     configBuilder = configuration.NestedConfigurationBuilder(open(filePath, 'r'))
    46                     configBuilder = configuration.NestedConfigurationBuilder(open(filePath, 'r'))
    46                     configSet = configBuilder.getConfiguration()
    47                     configSet = configBuilder.getConfiguration()
    47                     for config in configSet.getConfigurations():
    48                     for config in configSet.getConfigurations():
    48                         if type:
    49                         if type and productname:
    49                             if type in config.type:
    50                             if type in config.type and config['PRODUCT_NAME'] in productname:
    50                                 return config
    51                                 return config
    51                         else:
    52                         else:
    52                             noncust = config
    53                             noncust = config
    53         if type:
    54         if type:
    54             return None
    55             return None
    66     
    67     
    67     def findimages(self): 
    68     def findimages(self): 
    68         """find images"""
    69         """find images"""
    69         output = ''
    70         output = ''
    70         for imagetype, imagetypename in [('core', 'CORE'), ('langpack', 'ROFS2'), ('cust', 'ROFS3'), ('udaerase', 'UDAERASE')]:
    71         for imagetype, imagetypename in [('core', 'CORE'), ('langpack', 'ROFS2'), ('cust', 'ROFS3'), ('udaerase', 'UDAERASE')]:
    71             iconfigxml = self.getconfig(imagetype)
    72             iconfigxml = self.getconfig(imagetype, self.productname)
    72             if iconfigxml == None:
    73             if iconfigxml == None:
    73                 iconfigxml = self.config
    74                 iconfigxml = self.config
    74 
    75 
    75             if iconfigxml.has_key(imagetypename + '_FLASH'):
    76             if iconfigxml.has_key(imagetypename + '_FLASH'):
    76                 (drive, _) = os.path.splitdrive(self.imagesdir)
    77                 (drive, _) = os.path.splitdrive(self.imagesdir)
    81                     output = output + image + ','
    82                     output = output + image + ','
    82                 else:
    83                 else:
    83                     raise Exception(image + ' not found')
    84                     raise Exception(image + ' not found')
    84             else:
    85             else:
    85                 if imagetype == 'core':
    86                 if imagetype == 'core':
    86                     raise Exception(imagetypename + '_FLASH not found in iconfig.xml')
    87                     raise Exception(imagetypename + '_FLASH not found in iconfig.xml in ' + self.imagesdir)
    87                 print imagetypename + '_FLASH not found in iconfig.xml'
    88                 print imagetypename + '_FLASH not found in iconfig.xml'
    88         return output
    89         return output
    89 
    90 
    90 def files_to_test(canonicalsysdeffile, excludetestlayers, idobuildfilter, builddrive):
    91 def files_to_test(canonicalsysdeffile, excludetestlayers, idobuildfilter, builddrive):
    91     """list the files to test"""
    92     """list the files to test"""