def stopOrDeleteJob(request, jobType):
    manage = Manager()
    jobs = sepByComma(request.POST['subName'])
    changedJobs = []
    for job in jobs:
        job = job.strip()
        if job == "": continue
        if jobType == "stop" : 
            manage.stopJob(job)
            changedJobs.append(CondorJobPopulate.updateStopJob(job))
        elif jobType == "delete" :
            CondorJobPopulate.deleteJob(job)
    return changedJobs
def initTable(request):
    #Populate the database with current jobs
    manage = Manager()
    retVal = manage.getStatus()
    CondorJobPopulate.populateJobs(retVal)
    
    #Get current running experiment & jobs
    retDict = {'jobs' : CondorJob.objects.all()}
    
    #Return
    c = Context(retDict)  
    t = loader.get_template("condorManager/condorjobs.html")
    return HttpResponse(t.render(c))
def updateTable(request):
    #Use CondorJobPopulat to get updates
    manage = Manager()
    retVal = manage.getStatus()
    changedJobs = CondorJobPopulate.checkUpdate(retVal)
    data = serializers.serialize('json', changedJobs)
    print sys.stderr, data
    return HttpResponse(data, "application/json")