<commit_before>from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect, Http404
from JobEntry import JobEntry, SubJobEntry
import pickle
from models import JobRecord
import socket
import json
from dwolla import DwollaUser

def job_submit(request):

    #save file into object file
    number_of_records = JobRecord.objects.filter().count()
    file_name = 'job' + str(number_of_records)
    print file_name
    print request.GET['function']
    print request.GET['data']
    print number_of_records
    job = JobEntry(request.GET['function'], request.GET['data'], number_of_records + 1)
    with open(file_name, 'w') as fout:
        pickle.dump(job, fout)
    record = JobRecord(obj_name=file_name, status=False)
    record.save()

    # inform master about new job
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect( ('localhost', 5000))
    s.send('S' + file_name)

    s.close()

    json_data = json.dumps({'job_id' : record.pk})
    return HttpResponse(json_data, mimetype="application/json")

def home(request) :
    return render(request, 'morpheus/index.html')

def check_status(request):
    print request.GET['job_id']
    job = JobRecord.objects.filter(pk=int(request.GET['job_id']))
    print str( )
    res = {'status' : 'no_job'}
    if len(job) == 1:
        # print job[0].status
        res['status'] = job[0].status
        print "computation value " + str( job[0].result )
        if res['status']:
            print 'puting result'
            res['result'] = job[0].result

    return HttpResponse(json.dumps(res), mimetype="application/json")

start_string ="""<html>
    <head>
    </head>
    <body>
        <script type="text/javascript">"""


end_string = """

        var returnAsyncResult = function(result) {
            window.location = 'result://localhost/' + result;
        }

        </script>
    </body>
</html> """

def available(request):
    #inform master about new slave
    try:<commit_msg>html5 & async js<commit_after>from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect, Http404
from JobEntry import JobEntry, SubJobEntry
import pickle
from models import JobRecord
import socket
import json
from dwolla import DwollaUser

def job_submit(request):

    #save file into object file
    number_of_records = JobRecord.objects.filter().count()
    file_name = 'job' + str(number_of_records)
    print file_name
    print request.GET['function']
    print request.GET['data']
    print number_of_records
    job = JobEntry(request.GET['function'], request.GET['data'], number_of_records + 1)
    with open(file_name, 'w') as fout:
        pickle.dump(job, fout)
    record = JobRecord(obj_name=file_name, status=False)
    record.save()

    # inform master about new job
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect( ('localhost', 5000))
    s.send('S' + file_name)

    s.close()

    json_data = json.dumps({'job_id' : record.pk})
    return HttpResponse(json_data, mimetype="application/json")

def home(request) :
    return render(request, 'morpheus/index.html')

def check_status(request):
    print request.GET['job_id']
    job = JobRecord.objects.filter(pk=int(request.GET['job_id']))
    print str( )
    res = {'status' : 'no_job'}
    if len(job) == 1:
        # print job[0].status
        res['status'] = job[0].status
        print "computation value " + str( job[0].result )
        if res['status']:
            print 'puting result'
            res['result'] = job[0].result

    return HttpResponse(json.dumps(res), mimetype="application/json")

start_string ="""<!DOCTYPE HTML><html>
    <head>
    </head>
    <body>
        <script async type="text/javascript">"""


end_string = """

        var returnAsyncResult = function(result) {
            window.location = 'result://localhost/' + result;
        }

        </script>
    </body>
</html> """

def available(request):
    #inform master about new slave
    try:
{'fraction_non_alphanumeric': 0.13160518444666003, 'fraction_numerical': 0.006729810568295114, 'mean_word_length': 3.2873931623931623, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '3346377', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1236, 'n_words': 299}