<commit_before>import os
import requests
import paramiko

from celery.task import Task
from django.conf import settings
from sftpclone import sftpclone

from .models import BinaryContent
from subscriptions.tasks import make_absolute_url


class SyncAudioMessages(Task):

    def _get_existing_files(self, root, host, username, password, port):
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(host, username=username, password=password, port=port)
        ftp = ssh.open_sftp()
        existing_files = ftp.listdir(root)
        return existing_files

    def run(self, **kwargs):
        if settings.AUDIO_FTP_HOST:

            src = '{}/{}/'.format(settings.BASE_DIR, settings.MEDIA_ROOT)

            root = settings.AUDIO_FTP_ROOT
            host = settings.AUDIO_FTP_HOST
            username = settings.AUDIO_FTP_USER
            password = <PASSWORD>.AUDIO_FTP_PASS
            port = int(settings.AUDIO_FTP_PORT)

            existing_files = self._get_existing_files(
                root, host, username, password, port)

            delete_files = []

            files = BinaryContent.objects.all()<commit_msg>don't use BASE_DIR<commit_after>import os
import requests
import paramiko

from celery.task import Task
from django.conf import settings
from django.utils._os import abspathu
from sftpclone import sftpclone

from .models import BinaryContent
from subscriptions.tasks import make_absolute_url


class SyncAudioMessages(Task):

    def _get_existing_files(self, root, host, username, password, port):
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(host, username=username, password=password, port=port)
        ftp = ssh.open_sftp()
        existing_files = ftp.listdir(root)
        return existing_files

    def run(self, **kwargs):
        if settings.AUDIO_FTP_HOST:
            src = abspathu(settings.MEDIA_ROOT)
            if not src.endswith('/'):
                src += '/'

            root = settings.AUDIO_FTP_ROOT
            host = settings.AUDIO_FTP_HOST
            username = settings.AUDIO_FTP_USER
            password = <PASSWORD>
            port = int(settings.AUDIO_FTP_PORT)

            existing_files = self._get_existing_files(
                root, host, username, password, port)

            delete_files = []

            files = BinaryContent.objects.all()
{'fraction_non_alphanumeric': 0.08096013018714401, 'fraction_numerical': 0.0, 'mean_word_length': 2.7201210287443267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1031967', 'n_tokens_mistral': 736, 'n_tokens_neox': 693, 'n_words': 160}