<commit_before># coding=utf-8
import os
import subprocess

from app_file import AppFile
from utils import get_random


class UploadProcessor:
    def __init__(self, file, save_dir="uploads", http_dir="uploads", prefix="processed", separator="-"):
        self.file = AppFile(file)
        self.save_dir = save_dir
        self.http_dir = http_dir
        self.prefix = prefix
        self.separator = separator
        self.secure_hash = get_random()

    def __output_filename(self):
        file_parts = [self.prefix, self.secure_hash]
        return self.separator.join(file_parts) + self.file.ext

    output_filename = property(__output_filename)

    def __output_path(self):
        return os.path.abspath(os.path.join(self.save_dir, self.output_filename))

    output_path = property(__output_path)

    def __input_path(self):
        return self.file.save_path

    input_path = property(__input_path)

    def __http_path(self):
        return "/" + self.http_dir + self.output_filename

    http_path = property(__http_path)

    def save(self):
        self.file.save()

    def process(self, input_path=None, log_to_file=False):
        if input_path is None:
            input_path = self.input_path

        if log_to_file:
            stdout = open(self.output_path + '.log', mode='a')
        else:
            stdout = subprocess.DEVNULL

        # Executing Two Commands
        subprocess.Popen(['cp', input_path, self.output_path], stdout=stdout)
        subprocess.Popen(['file', input_path, self.output_path], stdout=stdout)

        return self.http_path<commit_msg>Fix HTTP path for image<commit_after># coding=utf-8
import os
import subprocess

from app_file import AppFile
from utils import get_random


class UploadProcessor:
    def __init__(self, file, save_dir="uploads", http_dir="uploads", prefix="processed", separator="-"):
        self.file = AppFile(file)
        self.save_dir = save_dir
        self.http_dir = http_dir
        self.prefix = prefix
        self.separator = separator
        self.secure_hash = get_random()

    def __output_filename(self):
        file_parts = [self.prefix, self.secure_hash]
        return self.separator.join(file_parts) + self.file.ext

    output_filename = property(__output_filename)

    def __output_path(self):
        return os.path.abspath(os.path.join(self.save_dir, self.output_filename))

    output_path = property(__output_path)

    def __input_path(self):
        return self.file.save_path

    input_path = property(__input_path)

    def __http_path(self):
        return "/" + self.http_dir + "/" + self.output_filename

    http_path = property(__http_path)

    def save(self):
        self.file.save()

    def process(self, input_path=None, log_to_file=False):
        if input_path is None:
            input_path = self.input_path

        if log_to_file:
            stdout = open(self.output_path + '.log', mode='a')
        else:
            stdout = subprocess.DEVNULL

        # Executing Two Commands
        subprocess.Popen(['cp', input_path, self.output_path], stdout=stdout)
        subprocess.Popen(['file', input_path, self.output_path], stdout=stdout)

        return self.http_path
{'fraction_non_alphanumeric': 0.10131332082551595, 'fraction_numerical': 0.0006253908692933083, 'mean_word_length': 2.92997542997543, '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': '5984752', 'n_tokens_mistral': 1004, 'n_tokens_neox': 961, 'n_words': 203}