def handle_describe_xml_file(): __has_expected_jar__ = False __found_jar__ = None __handled_expected_xml__ = False logger.info('Begin handling the describe.xml file.') for dirname,folders,files in _utils.walk(__source_build_deploy__): logger.info('Begin first pass through folders in "%s" while handling the describe.xml file.' % (dirname)) for f in folders: _f_ = dirname+os.sep+f if (_f_.find('%sbuild%sdeploy%s' % (os.sep,os.sep,os.sep)) > -1): if (__expected_jar__ in files): __has_expected_jar__ = True break else: found_jars = [n for n in files if (n.find('.jar') > -1)] __found_jar__ = found_jars[0] if (len(found_jars) > 0) else __found_jar__ logger.info('Done with first pass through folders in "%s" while handling the describe.xml file.' % (dirname)) for dirname,folders,files in _utils.walk(__source_conf__): if ((not __handled_expected_xml__) and __incrementbuildnumber__ and (dirname.find('%sbuild%sdeploy%s' % (os.sep,os.sep,os.sep)) == -1)): logger.info('Begin second pass through files in "%s" while handling the describe.xml file.' % (dirname)) for f in files: if (f == 'describe.xml'): _f_ = dirname+os.sep+f _b_ = _f_+'.new' logger.info('Opening "%s".' % (_f_)) fIn = open(_f_,'r') fOut = open(_b_,'w') logger.info('Opening "%s".' % (_b_)) for l in fIn: logger.info('Reading a line from "%s".' % (fIn.name)) if (l.find('<AdapterKind') > -1): so = SmartObject(dict([tuple(t.split('=')) for t in l.replace('<','').replace('>','').replace('AdapterKind ','').split(' ')])) if (so.version): so.version = '%d' % (int(so.version.replace('"','').strip())+1) if (not __override__) and (so.key.replace('"','') != __adaptername__): so.key = __adaptername__ logger.warning('Seems like your describe.xml file has a problem with the key field of the AdapterKind tag; the key should match the adaptername and this has been changed for you.') d = so.asPythonDict() v = ['%s="%s"' % (k,v) for k,v in d.iteritems()] l = '<AdapterKind %s>' % (' '.join(v)) l = l.replace('""','"') l = l.rstrip() if (len(l) > 0): print >>fOut, l logger.info('Writing a line into "%s".' % (fOut.name)) fOut.flush() fOut.close() logger.info('Closing "%s".' % (fOut.name)) fIn.close() logger.info('Closing "%s".' % (fIn.name)) os.remove(_f_) logger.info('Removed "%s".' % (_f_)) os.rename(_b_, _f_) logger.info('Renamed "%s" --> "%s".' % (_b_, _f_)) __handled_expected_xml__ = True break logger.info('Done with second pass through files in "%s" while handling the describe.xml file.' % (dirname)) logger.info('Done handling the describe.xml file.') return __has_expected_jar__, __found_jar__, __handled_expected_xml__