<commit_before>#!/usr/bin/python
import os
import subprocess
import sys
import traceback

class Builder(object):
    """Class that represents the actions for a builder"""
    def __init__(self, name, preAction, postAction):
        self.name = name
        self.preAction = preAction
        self.postAction = postAction

# the version of MSBuild.exe to use, depends on which version of VisualStudio was used to build the solution and projects
# by default, VS2008 is assumed
msBuildVersion = {\
  None:"v3.5",
  "9.0":"v3.5",
  "10.0":"v4.0.30319",
  "11.0":"v4.0.30319",
}

def VSSolutionPost(package, options, outputMessages, errorMessages):
    """Post action for testing the VSSolution builder"""
    exitCode = 0
    buildRoot = os.path.join(package.GetPath(), options.buildRoot)
    slnPath = os.path.join(buildRoot, package.GetId(), package.GetId() + ".sln")
    if not os.path.exists(slnPath):
        # TODO: really need something different here - an invalid test result, rather than a failure
        outputMessages.write("ViisualStudio solution expected at %s did not exist" % slnPath)
        return 0
    try:
        vcVersion = options.visualc_version
        if vcVersion:
          vcVersion = vcVersion[0]
        msBuildPath = r"C:\Windows\Microsoft.NET\Framework\%s\MSBuild.exe"%msBuildVersion[vcVersion]
        for config in options.configurations:
            argList = []
            argList.append(msBuildPath)
            argList.append("/verbosity:normal");
            argList.append(slnPath)
            # capitalize the first letter of the configuration
            config = config[0].upper() + config[1:]
            argList.append("/p:Configuration=%s" % config)
            print "Running '%s'\n" % ' '.join(argList)
            p = subprocess.Popen(argList, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (outputStream, errorStream) = p.communicate() # this should WAIT
            exitCode |= p.returncode
            if outputStream:
                outputMessages.write(outputStream)
            if errorStream:
                errorMessages.write(errorStream)
    except Exception, e:
        errorMessages.write(str(e))
        return -1
    return exitCode

def MakeFilePost(package, options, outputMessages, errorMessages):
    """Post action for testing the MakeFile builder"""
    if sys.platform.startswith("win"):
        # TODO: allow configuring where make is
        return 0<commit_msg>[trunk] Microsoft moved MSBuild with VS2013, out of c:\Windows into c:\Program Files<commit_after>#!/usr/bin/python
import os
import subprocess
import sys
import traceback

class Builder(object):
    """Class that represents the actions for a builder"""
    def __init__(self, name, preAction, postAction):
        self.name = name
        self.preAction = preAction
        self.postAction = postAction

# the version of MSBuild.exe to use, depends on which version of VisualStudio was used to build the solution and projects
# by default, VS2008 is assumed
msBuildVersionToNetMapping = {\
  None:"v3.5",
  "9.0":"v3.5",
  "10.0":"v4.0.30319",
  "11.0":"v4.0.30319"
}

def VSSolutionPost(package, options, outputMessages, errorMessages):
    """Post action for testing the VSSolution builder"""
    exitCode = 0
    buildRoot = os.path.join(package.GetPath(), options.buildRoot)
    slnPath = os.path.join(buildRoot, package.GetId(), package.GetId() + ".sln")
    if not os.path.exists(slnPath):
        # TODO: really need something different here - an invalid test result, rather than a failure
        outputMessages.write("ViisualStudio solution expected at %s did not exist" % slnPath)
        return 0
    try:
        vcVersion = options.visualc_version
        if vcVersion:
          vcVersion = vcVersion[0]
        vcVersionSplit = vcVersion.split('.')
        vcMajorVersion = int(vcVersionSplit[0])
        if vcMajorVersion < 12:
          msBuildPath = r"C:\Windows\Microsoft.NET\Framework\%s\MSBuild.exe"%msBuildVersionToNetMapping[vcVersion]
        else:
          msBuildPath = r"C:\Program Files (x86)\MSBuild\%s\bin\MSBuild.exe"%vcVersion
        for config in options.configurations:
            argList = []
            argList.append(msBuildPath)
            argList.append("/verbosity:normal");
            argList.append(slnPath)
            # capitalize the first letter of the configuration
            config = config[0].upper() + config[1:]
            argList.append("/p:Configuration=%s" % config)
            print "Running '%s'\n" % ' '.join(argList)
            p = subprocess.Popen(argList, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            (outputStream, errorStream) = p.communicate() # this should WAIT
            exitCode |= p.returncode
            if outputStream:
                outputMessages.write(outputStream)
            if errorStream:
                errorMessages.write(errorStream)
    except Exception, e:
        errorMessages.write(str(e))
        return -1
    return exitCode

def MakeFilePost(package, options, outputMessages, errorMessages):
    """Post action for testing the MakeFile builder"""
    if sys.platform.startswith("win"):
        # TODO: allow configuring where make is
        return 0
{'fraction_non_alphanumeric': 0.10515226968013791, 'fraction_numerical': 0.01589733767477495, 'mean_word_length': 2.7785817655571634, 'pattern_counts': {'":': 6, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '220878', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1479, 'n_words': 404}