示例#1
0
def buildspec_complete(currentLogFile, env, sagenconfigTool):
   buildspec = str(env.GetOption('buildspec'))
   root = os.path.normpath(str(env['TARGET_ROOT']))

#   print "USING Klocwork tool %s" % sagenconfigTool

   if os.path.exists(currentLogFile):
      if os.path.exists(currentLogFile) and os.path.getsize(currentLogFile)  > 0 and env.has_key('USES_NO_STRIP_NO_ODM'):
         if os.environ.get('BUILDSPEC') == 'CACHE':
            for a in listOfTags:
               buildspec_writeline(currentLogFile, a,env)  
         buildspec_writeline(currentLogFile,"</buildspec>\n",env)
         buildspec_convert_to_kw(currentLogFile, env)
         file_path = currentLogFile +".trace"
         tracefile = file_path[file_path.find('static_analysis'):]
      
         if os.name is 'nt':
            sagenconfigCmd = sagenconfigTool + ' -r ' + root + " -t trace -f " + tracefile
            try:
              utils.exec_cmds(env, sagenconfigCmd)
            except NameError:
              print "call to sagenconfig failed"
         elif os.name is 'posix':
            sagenconfigCmd = "perl " + sagenconfigTool + ' -r ' + root + " -t trace -f " + tracefile
            try:
              utils.exec_cmds(env, sagenconfigCmd)
            except NameError:
              print "call to sagenconfig failed"
   else:
      print "buildspec_complete - file not found %s" % currentLogFile
示例#2
0
    def _exec(self, cmds):
        _cmds = []
        if isinstance(cmds, dict):
            _cmds.append(cmds)
        elif isinstance(cmds, list):
            _cmds = cmds
        else:
            raise utils.CmdException({'cmd': str(cmds)})

        results = []
        cmdfailure = False
        try:
            results = utils.exec_cmds(_cmds, self._repodir)
        except utils.CmdException as ce:
            cmdfailure = True
            raise ce
        finally:
            if cmdfailure:
                for cmd in _cmds:
                    logger.debug("CMD: %s" % ' '.join(cmd['cmd']))
            else:
                for result in results:
                    cmd, rc, stdout, stderr = ' '.join(
                        result['cmd']
                    ), result['returncode'], result['stdout'], result['stderr']
                    logger.debug("CMD: %s RCODE: %s STDOUT: %s STDERR: %s" %
                                 (cmd, rc, stdout, stderr))

        return results
示例#3
0
def buildspec_complete(env, sadir, sacmd):
    '''
       buildspec_complete

       - exit function handler to finish buildspec log, and create kw log
    '''
    # Complicated mess to determine the path in which to create the trace files
    if env.has_key('IMAGE_NAME'):
        imagename = str(env['IMAGE_NAME'])
    else:
        imagename = 'none'

    # Create SA dir
    buildpath = str(env['BUILDPATH'])
    sa_buildpath_dir = sadir + "/" + buildpath
    if not os.path.exists(sa_buildpath_dir):
        os.makedirs(sa_buildpath_dir)

    # Filenames and paths
    tracefilename = str(imagename + ".bspec.trace")
    tracepath = sa_buildpath_dir + "/" + tracefilename

    # Write the tracefile
    counter = 0
    file_item = open(os.path.normpath(tracepath), "w")
    # Iterate through the list of commands
    if CMDDICT.has_key(imagename):
        for cmd in CMDDICT[imagename]:
            pieces = cmd.strip(' ').split()
            cmdname = os.path.normpath(pieces[0])
            line_to_write = ";".join(["exec", str(counter), os.getcwd(), \
                                     cmdname, cmdname] + pieces[1:])
            file_item.write(line_to_write + "\n")
            counter += 1
        file_item.close()

    # Setup the SA command to run
    root = os.path.normpath(str(env['TARGET_ROOT']))
    reltracepath = tracepath[tracepath.find('static_analysis'):]
    sacmd += ' -r ' + root + " -t trace -f " + reltracepath
    # Run the SA command
    try:
        utils.exec_cmds(env, sacmd)
    except NameError:
        print "call to sagenconfig failed"