<commit_before>from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from zephyr.models import UserProfile, UserActivity, get_client
from zephyr.lib.response import json_success, json_error
from django.utils.timezone import now
from django.db import transaction, IntegrityError
from django.conf import settings

from functools import wraps

import types

class TornadoAsyncException(Exception): pass

class _DefGen_Return(BaseException):
    def __init__(self, value):
        self.value = value

def returnResponse(value):
    raise _DefGen_Return(value)

def asynchronous(method):
    @wraps(method)
    def wrapper(request, *args, **kwargs):
        try:
            v = method(request, handler=request._tornado_handler, *args, **kwargs)
            if v == None or type(v) == types.GeneratorType:
                raise TornadoAsyncException
        except _DefGen_Return, e:
            request._tornado_handler.finish(e.value.content)
        return v
    if getattr(method, 'csrf_exempt', False):
        wrapper.csrf_exempt = True
    return wrapper

# I like the all-lowercase name better
require_post = require_POST

def parse_client(request, default):
    client_name = default
    if 'client' in request.POST:
        client_name = request.POST['client']
    return get_client(client_name)

def update_user_activity(request, user_profile, client):
    current_time = now()
    try:
        (activity, created) = UserActivity.objects.get_or_create(
            user_profile = user_profile,
            client = client,
            query = request.META["PATH_INFO"],
            defaults={'last_visit': current_time, 'count': 0})
    except IntegrityError:
        transaction.commit()
        activity = UserActivity.objects.get(user_profile = user_profile,<commit_msg>Remove some unused @asynchronous-related code<commit_after>from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from zephyr.models import UserProfile, UserActivity, get_client
from zephyr.lib.response import json_success, json_error
from django.utils.timezone import now
from django.db import transaction, IntegrityError
from django.conf import settings

from functools import wraps

import types

class TornadoAsyncException(Exception): pass

def asynchronous(method):
    @wraps(method)
    def wrapper(request, *args, **kwargs):
        v = method(request, handler=request._tornado_handler, *args, **kwargs)
        if v == None or type(v) == types.GeneratorType:
            raise TornadoAsyncException
        return v
    if getattr(method, 'csrf_exempt', False):
        wrapper.csrf_exempt = True
    return wrapper

# I like the all-lowercase name better
require_post = require_POST

def parse_client(request, default):
    client_name = default
    if 'client' in request.POST:
        client_name = request.POST['client']
    return get_client(client_name)

def update_user_activity(request, user_profile, client):
    current_time = now()
    try:
        (activity, created) = UserActivity.objects.get_or_create(
            user_profile = user_profile,
            client = client,
            query = request.META["PATH_INFO"],
            defaults={'last_visit': current_time, 'count': 0})
    except IntegrityError:
        transaction.commit()
        activity = UserActivity.objects.get(user_profile = user_profile,
{'fraction_non_alphanumeric': 0.08508771929824561, 'fraction_numerical': 0.0005847953216374269, 'mean_word_length': 3.6105121293800537, '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': '4782039', 'n_tokens_mistral': 970, 'n_tokens_neox': 966, 'n_words': 255}