示例#1
0
def main(threadcount, mountloc, cr_map, projectmap, successmaploc = None):
  shelvelist = []
  namelist = [id for id in projectmap if projectmap[id]["success"]]
  sourcepaths = {}
  for id in namelist:
    sourcepaths[id] = str(cr_map[id]["path"])
  threadlist = []
  for i in range(threadcount):
    tempdir = "src" + str(i)
    cc.cleanup(tempdir)
    shelvelist.append(shelve.open(PARTMAP.format(i)))
    if len(shelvelist[i]) > 0:
      keys = shelvelist[i]["Keys"]
    else :
      keys = namelist[i::threadcount]
      shelvelist[i]["Keys"] = keys
      shelvelist[i].sync()

    threadlist.append(
        Thread(
            target=createProjectAndCompile,
            args=(mountloc,
                  tempdir,
                  keys,
                  projectmap,
                  sourcepaths,
                  shelvelist[i])))
    threadlist[i].isDaemon = True
    threadlist[i].start()

  for i in range(threadcount):
    threadlist[i].join()

  final_success = {}
  for i in range(len(shelvelist)):
    final_success.update(shelvelist[i])
    del final_success["Keys"]
    call(["rm", PARTMAP.format(i)])

  if successmaploc:
    json.dump(
        final_success,
        open(successmaploc, "w"),
        sort_keys=True,
        indent=4,
        separators=(',', ': '))

  return final_success
示例#2
0
def main(threadcount, mountloc, cr_map, projectmap, successmaploc=None):
    shelvelist = []
    namelist = [id for id in projectmap if projectmap[id]["success"]]
    sourcepaths = {}
    for id in namelist:
        sourcepaths[id] = str(cr_map[id]["path"])
    threadlist = []
    for i in range(threadcount):
        tempdir = "src" + str(i)
        cc.cleanup(tempdir)
        shelvelist.append(shelve.open(PARTMAP.format(i)))
        if len(shelvelist[i]) > 0:
            keys = shelvelist[i]["Keys"]
        else:
            keys = namelist[i::threadcount]
            shelvelist[i]["Keys"] = keys
            shelvelist[i].sync()

        threadlist.append(
            Thread(target=createProjectAndCompile,
                   args=(mountloc, tempdir, keys, projectmap, sourcepaths,
                         shelvelist[i])))
        threadlist[i].isDaemon = True
        threadlist[i].start()

    for i in range(threadcount):
        threadlist[i].join()

    final_success = {}
    for i in range(len(shelvelist)):
        final_success.update(shelvelist[i])
        del final_success["Keys"]
        call(["rm", PARTMAP.format(i)])

    if successmaploc:
        json.dump(final_success,
                  open(successmaploc, "w"),
                  sort_keys=True,
                  indent=4,
                  separators=(',', ': '))

    return final_success
示例#3
0
def createProjectAndCompile(path, srcdir, namelist, projectmap, sourcepaths, shelveobj):
  i = 0
  for id in namelist:
    id = str(id)
    if id in shelveobj:
      continue
    #print id
    succ = False
    output = ""
    try:
      makeproject(os.path.join(MOUNTLOCATION, sourcepaths[id]), projectmap[id], srcdir)
      succ, output = cc.compile(srcdir)
    except Exception, e:
      succ, output = False, str(e.message)
      print output
    if succ:
      savebuildfiles(srcdir, sourcepaths[id])
    shelveobj[id] = {"success": succ}
    cc.cleanup(srcdir)
    i += 1
    if i%10 == 0:
      print srcdir, i, "/", len(namelist)
示例#4
0
def createProjectAndCompile(path, srcdir, namelist, projectmap, sourcepaths,
                            shelveobj):
    i = 0
    for id in namelist:
        id = str(id)
        if id in shelveobj:
            continue
        #print id
        succ = False
        output = ""
        try:
            makeproject(os.path.join(MOUNTLOCATION, sourcepaths[id]),
                        projectmap[id], srcdir)
            succ, output = cc.compile(srcdir)
        except Exception, e:
            succ, output = False, str(e.message)
            print output
        if succ:
            savebuildfiles(srcdir, sourcepaths[id])
        shelveobj[id] = {"success": succ}
        cc.cleanup(srcdir)
        i += 1
        if i % 10 == 0:
            print srcdir, i, "/", len(namelist)