<commit_before>import json
import requests
# import logging
# import os
import re

from django.http import HttpResponse
from django.shortcuts import render
from django.conf import settings
import atlas.deftcore.api.client as deft

#from atlas.prodtask.task_actions import _do_deft_action

# _logger = logging.getLogger('prodtaskwebui')

_deft_client = deft.Client(settings.DEFT_AUTH_USER, settings.DEFT_AUTH_KEY)

_deft_job_actions = {

    'kill_jobs': 'kill_job',
    'set_debug_jobs': 'set_job_debug_mode',
    'reassign_jobs': 'reassign_jobs',

}

def request_jobs(request):
    params_for_bigpanda = ''
    request_path = request.META['QUERY_STRING']
    if request_path:
        params_for_bigpanda = "http://bigpanda.cern.ch/jobs/?" + request_path
    return render(request, 'prodjob/_job_table.html',{ 'params_for_bigpanda':  params_for_bigpanda  })


def jobs_action(request,action):
    """

    :type request: object
    """

    user = request.user.username

    is_superuser = request.user.is_superuser
    data = json.loads(request.body)
    jobs= data.get('jobs')
    args= data.get('parameters', [])

    fin_res=[]

    result = dict(owner=user, job=None, task=None, action=action, args=args,
                  status=None, accepted=False, registered=False,
                  exception=None, exception_source=None)


    #result = dict(status=None,exception=None)


    if not is_superuser:
        result['exception'] = "Permission denied"
        return HttpResponse(json.dumps(result))
        #return HttpResponse('Permission denied')


    #if action == 'decrease_priority':
    #    result.update(decrease_task_priority(owner, task_id, *args))
    #if action in _deft_actions:
    #    result.update(_do_deft_action(owner, task_id, action, *args))

    #do actions here


    for job in jobs:
        result.update(_do_deft_job_action(user, job['taskid'], job['pandaid'], action, *args))
        fin_res.append(result)

    return HttpResponse(json.dumps(fin_res))


def get_jobs(request):
    #    curl -H 'Accept: application/json' -H 'Content-Type: application/json' "http://bigpanda.cern.ch/jobs/?pandaid=2646731860,2646731861";
    #url = 'http://bigpanda.cern.ch/jobs/?pandaid=2646731860,2646731861';

    url = json.loads(request.body)[0];
    url=re.sub('&display_limit.*(\d+)','',url)



    headers = {'content-type': 'application/json', 'accept': 'application/json'};<commit_msg>Fix prodjob after bigpanda moved to https<commit_after>import json
import requests
# import logging
# import os
import re

from django.http import HttpResponse
from django.shortcuts import render
from django.conf import settings
import atlas.deftcore.api.client as deft

#from atlas.prodtask.task_actions import _do_deft_action

# _logger = logging.getLogger('prodtaskwebui')

_deft_client = deft.Client(settings.DEFT_AUTH_USER, settings.DEFT_AUTH_KEY)

_deft_job_actions = {

    'kill_jobs': 'kill_job',
    'set_debug_jobs': 'set_job_debug_mode',
    'reassign_jobs': 'reassign_jobs',

}

def request_jobs(request):
    params_for_bigpanda = ''
    request_path = request.META['QUERY_STRING']
    if request_path:
        params_for_bigpanda = "http://bigpanda.cern.ch/jobs/?" + request_path
    return render(request, 'prodjob/_job_table.html',{ 'params_for_bigpanda':  params_for_bigpanda  })


def jobs_action(request,action):
    """

    :type request: object
    """

    user = request.user.username

    is_superuser = request.user.is_superuser
    data = json.loads(request.body)
    jobs= data.get('jobs')
    args= data.get('parameters', [])

    fin_res=[]

    result = dict(owner=user, job=None, task=None, action=action, args=args,
                  status=None, accepted=False, registered=False,
                  exception=None, exception_source=None)


    #result = dict(status=None,exception=None)


    if not is_superuser:
        result['exception'] = "Permission denied"
        return HttpResponse(json.dumps(result))
        #return HttpResponse('Permission denied')


    #if action == 'decrease_priority':
    #    result.update(decrease_task_priority(owner, task_id, *args))
    #if action in _deft_actions:
    #    result.update(_do_deft_action(owner, task_id, action, *args))

    #do actions here


    for job in jobs:
        result.update(_do_deft_job_action(user, job['taskid'], job['pandaid'], action, *args))
        fin_res.append(result)

    return HttpResponse(json.dumps(fin_res))


def get_jobs(request):
    #    curl -H 'Accept: application/json' -H 'Content-Type: application/json' "http://bigpanda.cern.ch/jobs/?pandaid=2646731860,2646731861";
    #url = 'http://bigpanda.cern.ch/jobs/?pandaid=2646731860,2646731861';

    url = json.loads(request.body)[0];
    url=re.sub('&display_limit.*(\d+)','',url)
    url = url.replace('https','http')
    if 'json' not in url:
        if url[-1]=='&':
            url=url+'&'
        else:
            url=url+'&json'

    headers = {'content-type': 'application/json', 'accept': 'application/json'};
{'fraction_non_alphanumeric': 0.13261433992410626, 'fraction_numerical': 0.016576792490513283, 'mean_word_length': 3.8246628131021194, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4588120', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1652, 'n_words': 309}