<commit_before># coding=utf-8
import os
import platform
import sys
from datetime import datetime
from logging import Logger

import psutil
from gevent.queue import Queue

from .configparser import Config
from .console import ConsoleManager
from .enums import PluginType
from .filesystem import FileSystemWatcher
from .plugin.api import PluginAPI
from .plugin.manager import PluginManager
from .plugin.storage import LocalStorage
from .thread.manager import ThreadManager
from .twitter.manager import UserStreamManager
from .utils import getLogger, makeDirs
from .webui.manager import WebUIManager
from .discord.manager import WebSocketManager

class Core:
    def __init__(self, prompt: bool=True) -> None:
        pidFile = f"{os.getcwd()}/lock"
        if os.path.isfile(pidFile):
            running = False
            with open(pidFile) as f:
                pid = f.read()
                if pid.isdigit() and psutil.pid_exists(int(pid.strip())):
                    running = True
            if running:
                print("PyChroner is already running.")
                exit(1)
        with open(pidFile, "w") as f:
            f.write(str(os.getpid()))

        self.prompt: bool = prompt
        self.config: Config = Config()
        sys.path.append(self.config.directory.library)

        makeDirs(self.config.directory.dirs)
        self.queue = Queue()
        self.logger: Logger = getLogger(
                name="pychroner", directory=self.config.directory.logs, logLevel=self.config.logging.level,
                slack=self.config.logging.slack,
                queue=self.queue
        )
        self.logger.info(f"Logger started. Current time is {datetime.now()}.")
        self.logger.info(f"Working directory is {os.getcwd()}. Running as {os.getlogin()}, PID {os.getpid()}.")
        self.logger.info(
                f"Operating System is {platform.system()} {platform.release()} "
                f"[version {platform.version()}] ({platform.architecture()[0]}). "
        )
        self.logger.info(
                f"Running Python is version {platform.python_version()} ({platform.python_implementation()}) "
                f"build {platform.python_compiler()} [{ platform.python_build()[1]}]."
        )
        if os.getlogin() in ["root", "Administrator"]:
            self.logger.warning(f"You are running as root or Administrator. Bot should be running as a normal user.")

        self.UM: UserStreamManager = UserStreamManager(self)
        self.WSM: WebSocketManager = WebSocketManager(self)
        self.TM: ThreadManager = ThreadManager(self)

        self.PM: PluginManager = PluginManager(self)
        self.PM.loadPluginsFromDir()

        self.FS: FileSystemWatcher = FileSystemWatcher(self)
        self.CM = ConsoleManager(self)
        self.WM = WebUIManager(self)
        self.LS = LocalStorage()

        self.logger.info(f"Initialization Complate. Current time is {datetime.now()}.")

    def run(self) -> None:
        self.WSM.start()
        self.TM.start()
        self.FS.start()
        [
            self.TM.startThread(<commit_msg>Fix: You are→PyChroner is の表記ゆれの修正<commit_after># coding=utf-8
import os
import platform
import sys
from datetime import datetime
from logging import Logger

import psutil
from gevent.queue import Queue

from .configparser import Config
from .console import ConsoleManager
from .discord.manager import WebSocketManager
from .enums import PluginType
from .filesystem import FileSystemWatcher
from .plugin.api import PluginAPI
from .plugin.manager import PluginManager
from .plugin.storage import LocalStorage
from .thread.manager import ThreadManager
from .twitter.manager import UserStreamManager
from .utils import getLogger, makeDirs
from .webui.manager import WebUIManager


class Core:
    def __init__(self, prompt: bool=True) -> None:
        pidFile = f"{os.getcwd()}/lock"
        if os.path.isfile(pidFile):
            running = False
            with open(pidFile) as f:
                pid = f.read()
                if pid.isdigit() and psutil.pid_exists(int(pid.strip())):
                    running = True
            if running:
                print("PyChroner is already running.")
                exit(1)
        with open(pidFile, "w") as f:
            f.write(str(os.getpid()))

        self.prompt: bool = prompt
        self.config: Config = Config()
        sys.path.append(self.config.directory.library)

        makeDirs(self.config.directory.dirs)
        self.queue = Queue()
        self.logger: Logger = getLogger(
                name="pychroner", directory=self.config.directory.logs, logLevel=self.config.logging.level,
                slack=self.config.logging.slack,
                queue=self.queue
        )
        self.logger.info(f"Logger started. Current time is {datetime.now()}.")
        self.logger.info(f"Working directory is {os.getcwd()}. Running as {os.getlogin()}, PID {os.getpid()}.")
        self.logger.info(
                f"Operating System is {platform.system()} {platform.release()} "
                f"[version {platform.version()}] ({platform.architecture()[0]}). "
        )
        self.logger.info(
                f"Running Python is version {platform.python_version()} ({platform.python_implementation()}) "
                f"build {platform.python_compiler()} [{ platform.python_build()[1]}]."
        )
        if os.getlogin() in ["root", "Administrator"]:
            self.logger.warning(f"PyChroner is running as root or Administrator. Bot should be running as a normal user.")

        self.UM: UserStreamManager = UserStreamManager(self)
        self.WSM: WebSocketManager = WebSocketManager(self)
        self.TM: ThreadManager = ThreadManager(self)

        self.PM: PluginManager = PluginManager(self)
        self.PM.loadPluginsFromDir()

        self.FS: FileSystemWatcher = FileSystemWatcher(self)
        self.CM = ConsoleManager(self)
        self.WM = WebUIManager(self)
        self.LS = LocalStorage()

        self.logger.info(f"Initialization Complate. Current time is {datetime.now()}.")

    def run(self) -> None:
        self.WSM.start()
        self.TM.start()
        self.FS.start()
        [
            self.TM.startThread(
{'fraction_non_alphanumeric': 0.1110932217034294, 'fraction_numerical': 0.0012880373530832394, 'mean_word_length': 2.4977477477477477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6768657', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1736, 'n_words': 435}