<commit_before>import logging
import multiprocessing

from twisted.internet import reactor, defer

from scanners.spiders.filespider import FileSpider
from scanners.scanner_types.filescanner import FileScanner

from run import StartScan


class StartFileScan(StartScan, multiprocessing.Process):
    """A scanner application which can be run."""

    def __init__(self, scan_id, logfile=None, last_started=None):
        """
        Initialize the scanner application.
        Takes scan id as input, which is directly related to the scan job id in the database.
        """

        multiprocessing.Process.__init__(self)
        super().__init__(scan_id, logfile, last_started)
        self.scanner = FileScanner(self.scan_id)

    def run(self):
        """Updates the scan status and sets the pid.
        Run the scanner, blocking until finished."""

        if self.scanner.scan_object.status is not "STARTED":
            self.scanner.scan_object.set_scan_status_start()
<commit_msg>Creation of FileScanner is moved to the run method. FileScanner communicates with the database and it cannot do that before the django setup has been loaded. This is now done is StartScan.run().<commit_after>import logging
import multiprocessing

from twisted.internet import reactor, defer

from run import StartScan

from scanners.spiders.filespider import FileSpider
from scanners.scanner_types.filescanner import FileScanner


class StartFileScan(StartScan, multiprocessing.Process):
    """A scanner application which can be run."""

    def __init__(self, scan_id, logfile=None, last_started=None):
        """
        Initialize the scanner application.
        Takes scan id as input, which is directly related to the scan job id in the database.
        """

        super().__init__(scan_id, logfile, last_started)
        multiprocessing.Process.__init__(self)

    def run(self):
        """Updates the scan status and sets the pid.
        Run the scanner, blocking until finished."""
        super().run()
        self.scanner = FileScanner(self.scan_id)
        if self.scanner.scan_object.status is not "STARTED":
            self.scanner.scan_object.set_scan_status_start()

{'fraction_non_alphanumeric': 0.07568807339449542, 'fraction_numerical': 0.0, 'mean_word_length': 3.441955193482688, 'pattern_counts': {'":': 2, '<': 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': '2956088', 'n_tokens_mistral': 612, 'n_tokens_neox': 590, 'n_words': 203}