<commit_before>import os
import http
import json
import asyncio

from tornado import web

import waterbutler.core
from waterbutler import tasks
from waterbutler.core.streams import RequestStreamReader

from waterbutler.server import utils
from waterbutler.server import settings
from waterbutler.server.handlers import core
from waterbutler.server.identity import get_identity


class MoveHandler(core.BaseCrossProviderHandler):
    JSON_REQUIRED = True
    ACTION_MAP = {
        'POST': 'move'
    }

    @utils.coroutine
    def prepare(self):
        yield from super().prepare()

    @utils.coroutine
    def post(self):
        if not self.source_provider.can_intra_move(self.destination_provider):
            resp = yield from tasks.move({
                'args': self.json['source'],
                'provider': self.source_provider.serialized()
            }, {
                'args': self.json['destination'],
                'provider': self.destination_provider.serialized()
            })
            self.set_status(202)
            return

        metadata, created = (
            yield from tasks.backgrounded(
                self.source_provider.move,
                self.destination_provider,
                self.json['source'],
                self.json['destination']
            )
        )

        if created:
            self.set_status(201)
        else:
            self.set_status(200)

        self.write(metadata)

        # TODO copy/created?
        self._send_hook(
            'create' if created else 'update',
            metadata,
        )<commit_msg>Actually send the call back<commit_after>import os
import http
import json
import asyncio

from tornado import web

import waterbutler.core
from waterbutler import tasks
from waterbutler.core.streams import RequestStreamReader

from waterbutler.server import utils
from waterbutler.server import settings
from waterbutler.server.handlers import core
from waterbutler.server.identity import get_identity


class MoveHandler(core.BaseCrossProviderHandler):
    JSON_REQUIRED = True
    ACTION_MAP = {
        'POST': 'move'
    }

    @utils.coroutine
    def prepare(self):
        yield from super().prepare()

    @utils.coroutine
    def post(self):
        if not self.source_provider.can_intra_move(self.destination_provider):
            resp = yield from tasks.move({
                'args': self.json['source'],
                'provider': self.source_provider.serialized()
            }, {
                'args': self.json['destination'],
                'provider': self.destination_provider.serialized()
            })
            self.set_status(202)
            return

        metadata, created = (
            yield from tasks.backgrounded(
                self.source_provider.move,
                self.destination_provider,
                self.json['source'],
                self.json['destination']
            )
        )

        if created:
            self.set_status(201)
        else:
            self.set_status(200)

        self.write(metadata)

        self._send_hook('move', metadata['path'])
{'fraction_non_alphanumeric': 0.08656620711766592, 'fraction_numerical': 0.005771080474511061, 'mean_word_length': 2.0738916256157633, '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': '6628580', 'n_tokens_mistral': 838, 'n_tokens_neox': 799, 'n_words': 187}