buildframework/helium/tools/common/common.antlib.xml
changeset 645 b8d81fa19e7d
parent 628 7c4a911dc066
equal deleted inserted replaced
643:27cf35f95864 645:b8d81fa19e7d
   323 target = str(attributes.get('target'))
   323 target = str(attributes.get('target'))
   324 
   324 
   325 collectTargetDependencies(target, 1)
   325 collectTargetDependencies(target, 1)
   326 targetList.append((target, 0))
   326 targetList.append((target, 0))
   327     
   327     
   328 format = str(attributes.get('format'))
   328 formatstr = str(attributes.get('format'))
   329 
   329 
   330 if format == 'nested':    
   330 if formatstr == 'nested':    
   331     for target, indent in targetList:        
   331     for target, indent in targetList:        
   332         indentString = ''.join(['   ' for x in range(indent)])
   332         indentString = ''.join(['   ' for x in range(indent)])
   333         print indentString + str(target)
   333         print indentString + str(target)
   334 elif format == 'executable':
   334 elif formatstr == 'executable':
   335     print "Top level targets:\n"
   335     print "Top level targets:\n"
   336     print ''.join([str(target) + ' ' for target, indent in targetList[:-1] if indent == 1])
   336     print ''.join([str(target) + ' ' for target, indent in targetList[:-1] if indent == 1])
   337     print "\n\nAll targets in sequence:\n"
   337     print "\n\nAll targets in sequence:\n"
   338     print ''.join([str(target) + ' ' for target, indent in targetList[:-1]])
   338     print ''.join([str(target) + ' ' for target, indent in targetList[:-1]])
   339     </scriptdef>
   339     </scriptdef>
   376         <attribute name="type"/>
   376         <attribute name="type"/>
   377         <![CDATA[
   377         <![CDATA[
   378 import netrc
   378 import netrc
   379 import os
   379 import os
   380 result = "0"
   380 result = "0"
   381 try:
   381 
   382     netrc_file = netrc.netrc()
   382 netrc_file = netrc.netrc()
   383     self.log("Type: %s" % str(attributes.get("type")))
   383 self.log("Type: %s" % str(attributes.get("type")))
   384     netrc_info = netrc_file.authenticators(str(attributes.get("type")))
   384 netrc_info = netrc_file.authenticators(str(attributes.get("type")))
   385     if netrc_info == None:
   385 if netrc_info == None:
   386         raise Exception("No entry found for Type: %s" % str(attributes.get("type")))
   386     print "No entry found for Type: %s" % str(attributes.get("type"))
       
   387     result = '-1'
       
   388 else:
   387     (n_username, n_account, n_password) = netrc_info
   389     (n_username, n_account, n_password) = netrc_info
   388     if attributes.get('output-prop') != None:
   390     if attributes.get('output-prop') != None:
   389         project.setProperty(str(attributes.get('output-prop')), str(n_password))
   391         project.setProperty(str(attributes.get('output-prop')), str(n_password))
   390 except Exception, e:
       
   391     result = "-1"
       
   392     print "Warning: %s" % e
       
   393 if attributes.get('result-prop') != None:
   392 if attributes.get('result-prop') != None:
   394     project.setProperty(str(attributes.get('result-prop')), str(result))
   393     project.setProperty(str(attributes.get('result-prop')), str(result))
   395         ]]>
   394         ]]>
   396     </scriptdef>
   395     </scriptdef>
   397 
   396 
   403         <attribute name="type"/>
   402         <attribute name="type"/>
   404         <![CDATA[
   403         <![CDATA[
   405 import netrc
   404 import netrc
   406 import os
   405 import os
   407 result = "0"
   406 result = "0"
   408 try:
   407 
   409     netrc_file = netrc.netrc()
   408 netrc_file = netrc.netrc()
   410     self.log("Type: %s" % str(attributes.get("type")))
   409 self.log("Type: %s" % str(attributes.get("type")))
   411     netrc_info = netrc_file.authenticators(str(attributes.get("type")))
   410 netrc_info = netrc_file.authenticators(str(attributes.get("type")))
   412     if netrc_info == None:
   411 if netrc_info == None:
   413         raise Exception("No entry found for Type: %s" % str(attributes.get("type")))
   412     print "No entry found for Type: %s" % str(attributes.get("type"))
       
   413     result = '-1'
       
   414 else:
   414     (n_username, n_account, n_password) = netrc_info
   415     (n_username, n_account, n_password) = netrc_info
   415     if attributes.get('output-prop') != None:
   416     if attributes.get('output-prop') != None:
   416         project.setProperty(str(attributes.get('output-prop')), str(n_username))
   417         project.setProperty(str(attributes.get('output-prop')), str(n_username))
   417 except Exception, e:
       
   418     result = "-1"
       
   419     print "Warning: %s" % e
       
   420 if attributes.get('result-prop') != None:
   418 if attributes.get('result-prop') != None:
   421     project.setProperty(str(attributes.get('result-prop')), str(result))
   419     project.setProperty(str(attributes.get('result-prop')), str(result))
   422         ]]>
   420         ]]>
   423     </scriptdef>
   421     </scriptdef>
   424      
   422      
   436 session = None
   434 session = None
   437 result = "0"
   435 result = "0"
   438 cache = None
   436 cache = None
   439 if project.getProperty("ccm.cache.xml")is not None:
   437 if project.getProperty("ccm.cache.xml")is not None:
   440     cache = str(project.getProperty("ccm.cache.xml"))
   438     cache = str(project.getProperty("ccm.cache.xml"))
   441 try:
   439 database = project.getProperty('ccm.database')
   442     database = project.getProperty('ccm.database')
   440 if project.getProperty('ccm.user.login') == None :
   443     
   441     raise Exception("'ccm.user.login' property is not defined")
   444     if project.getProperty('ccm.user.login') == None :
   442 username = project.getProperty('ccm.user.login')
   445         raise Exception("'ccm.user.login' property is not defined")
   443 if project.getProperty('ccm.user.password') == None :
   446         
   444     raise Exception("'ccm.user.password' property is not defined")
   447     username = project.getProperty('ccm.user.login')
   445 password = project.getProperty('ccm.user.password')
   448     
   446 engine = project.getProperty('ccm.engine.host')
   449     if project.getProperty('ccm.user.password') == None :
   447 dbpath = project.getProperty('ccm.database.path')
   450         raise Exception("'ccm.user.password' property is not defined")
   448 provider = ccm.extra.CachedSessionProvider(opener=nokia.nokiaccm.open_session, cache=cache)
   451         
   449 if database != None:
   452     password = project.getProperty('ccm.user.password')
   450     session = provider.get(username, password, database=database, reuse=False)
   453     
   451 else:
   454     
   452     session = provider.get(username, password, engine, dbpath, reuse=False)
   455     engine = project.getProperty('ccm.engine.host')
   453 session.close()
   456     dbpath = project.getProperty('ccm.database.path')
   454 provider.close()
   457     provider = ccm.extra.CachedSessionProvider(opener=nokia.nokiaccm.open_session, cache=cache)
       
   458     if database != None:
       
   459         session = provider.get(username, password, database=database, reuse=False)
       
   460     else:
       
   461         session = provider.get(username, password, engine, dbpath, reuse=False)
       
   462     session.close()
       
   463     provider.close()
       
   464 except Exception, e:
       
   465     print "ERROR: %s" % e
       
   466     if str(e).find("access denied") != -1:
       
   467         result = "-2"
       
   468     else:
       
   469         result = "-1"
       
   470 self.log("Result: %s" % attributes.get('resultproperty'))
       
   471 project.setProperty(str(attributes.get('resultproperty')), str(result))
       
   472         ]]>
   455         ]]>
   473     </scriptdef>
   456     </scriptdef>
   474 
   457 
   475     
   458     
   476     <macrodef name="signalMacro" uri="http://www.nokia.com/helium">
   459     <macrodef name="signalMacro" uri="http://www.nokia.com/helium">
   502                 file="@{logfile}" />
   485                 file="@{logfile}" />
   503 
   486 
   504             <!-- signal for errors -->
   487             <!-- signal for errors -->
   505             <var name="internal.signal.macro.log.basename" value="" unset="true"/> 
   488             <var name="internal.signal.macro.log.basename" value="" unset="true"/> 
   506             <basename property="internal.signal.macro.log.basename" file="@{logfile}" />
   489             <basename property="internal.signal.macro.log.basename" file="@{logfile}" />
   507             <hlm:signal name="@{signal.input}" result="${signal.errors.total}"
   490             <hlm:signal result="${signal.errors.total}" message="Found ${signal.errors.total} errors under @{logfile}."> 
   508                 message="Found ${signal.errors.total} errors under @{logfile}.">
       
   509                 <signalNotifierInput>
   491                 <signalNotifierInput>
   510                     <signalInput refid="@{signal.input}" />
   492                     <signalInput refid="@{signal.input}" />
   511                     <notifierInput>
   493                     <notifierInput>
   512                         <fileset casesensitive="false" dir="${build.signal.status.dir}"
   494                         <fileset casesensitive="false" dir="${build.log.dir}">
   513                             includes="${internal.signal.macro.log.basename}.status.html" />
   495                             <include name="**/${internal.signal.macro.log.basename}*" />
       
   496                         </fileset>
   514                     </notifierInput>
   497                     </notifierInput>
   515                 </signalNotifierInput>
   498                 </signalNotifierInput>
   516             </hlm:signal>
   499             </hlm:signal>
   517         </sequential>
   500         </sequential>
   518     </macrodef>
   501     </macrodef>
   534         <attribute name="control"/>
   517         <attribute name="control"/>
   535         <attribute name="test"/>
   518         <attribute name="test"/>
   536         <attribute name="failonerror"/>
   519         <attribute name="failonerror"/>
   537         <![CDATA[
   520         <![CDATA[
   538 import logging
   521 import logging
   539 
   522 import junit.framework
   540 import java.io
   523 import java.io
   541 import org.custommonkey.xmlunit
   524 import org.custommonkey.xmlunit
   542 
   525 
   543 control_id = str(attributes.get('control'))
   526 control_id = str(attributes.get('control'))
   544 test_id = str(attributes.get('test'))
   527 test_id = str(attributes.get('test'))
   560 try:
   543 try:
   561     control_reader = java.io.InputStreamReader(control_resource.getInputStream())
   544     control_reader = java.io.InputStreamReader(control_resource.getInputStream())
   562     test_reader = java.io.InputStreamReader(test_resource.getInputStream())
   545     test_reader = java.io.InputStreamReader(test_resource.getInputStream())
   563     org.custommonkey.xmlunit.XMLAssert.assertXMLEqual(control_reader, test_reader)
   546     org.custommonkey.xmlunit.XMLAssert.assertXMLEqual(control_reader, test_reader)
   564     print 'XML is similar'
   547     print 'XML is similar'
   565 except Exception, e:
   548 except junit.framework.AssertionFailedError, e:
   566     print 'XML is NOT similar!'
   549     print 'XML is NOT similar!'
   567     failonerror = str(attributes.get('failonerror'))
   550     failonerror = str(attributes.get('failonerror'))
   568     if failonerror == 'true' or failonerror == 'None':
   551     if failonerror == 'true' or failonerror == 'None':
   569         raise e
   552         raise e
   570         ]]>
   553         ]]>
   573     
   556     
   574     <!-- unsubst task, will unsubst a given drive. -->
   557     <!-- unsubst task, will unsubst a given drive. -->
   575     <scriptdef name="unsubst" language="jython" uri="http://www.nokia.com/helium">
   558     <scriptdef name="unsubst" language="jython" uri="http://www.nokia.com/helium">
   576         <attribute name="drive"/>
   559         <attribute name="drive"/>
   577         <attribute name="failonerror"/>
   560         <attribute name="failonerror"/>
   578 """ internal.codescanner.drive """
   561 #internal.codescanner.drive
   579 import os
   562 import os
   580 if os.sep == '\\':
   563 if os.sep == '\\':
   581     import fileutils
   564     import fileutils
   582     self.setTaskName('unsubst')
   565     self.setTaskName('unsubst')
   583     drive = attributes.get('drive')
   566     drive = attributes.get('drive')
   594     else:
   577     else:
   595         drive = str(drive)
   578         drive = str(drive)
   596         try:
   579         try:
   597             self.log(str("Unsubsting %s..." % drive))
   580             self.log(str("Unsubsting %s..." % drive))
   598             fileutils.unsubst(drive)
   581             fileutils.unsubst(drive)
   599         except Exception, e:
   582         except OSError, e:
   600             if failonerror:
   583             if failonerror:
   601                 raise e
   584                 raise e
   602             else:
   585             else:
   603                 self.log(str("Error: %s" % e))
   586                 self.log(str("Error: %s" % e))
   604     </scriptdef>
   587     </scriptdef>
   607     <!-- Touches the files in the paths given. -->
   590     <!-- Touches the files in the paths given. -->
   608     <scriptdef name="touch" language="jython" uri="http://www.nokia.com/helium">
   591     <scriptdef name="touch" language="jython" uri="http://www.nokia.com/helium">
   609         <element name="path" type="path"/>
   592         <element name="path" type="path"/>
   610         <![CDATA[
   593         <![CDATA[
   611 import fileutils
   594 import fileutils
   612 for id in range(elements.get("path").size()):
   595 for aid in range(elements.get("path").size()):
   613     iterator = elements.get("path").get(int(id)).iterator()
   596     iterator = elements.get("path").get(int(aid)).iterator()
   614     while iterator.hasNext():
   597     while iterator.hasNext():
   615         path = str(iterator.next())
   598         path = str(iterator.next())
   616         fileutils.touch(path)
   599         fileutils.touch(path)
   617         ]]>
   600         ]]>
   618     </scriptdef>
   601     </scriptdef>
   727             <hlm:database output="@{file}" scope="@{scope}">
   710             <hlm:database output="@{file}" scope="@{scope}">
   728                 <fileset dir="${helium.dir}">
   711                 <fileset dir="${helium.dir}">
   729                     <include name="config/signaling_config_default.ant.xml"/>
   712                     <include name="config/signaling_config_default.ant.xml"/>
   730                     <include name="config/stages_config_default.ant.xml"/>
   713                     <include name="config/stages_config_default.ant.xml"/>
   731                     <include name="config/metadata_filter_config_default.ant.xml"/>
   714                     <include name="config/metadata_filter_config_default.ant.xml"/>
       
   715                     <include name="tools/common/default_config.ant.xml"/>
   732                     <include name="tools/**/*.antlib.xml"/>
   716                     <include name="tools/**/*.antlib.xml"/>
   733                 </fileset>
   717                 </fileset>
   734             </hlm:database>
   718             </hlm:database>
   735         </sequential>
   719         </sequential>
   736     </macrodef>
   720     </macrodef>