<commit_before>#!/usr/bin/env python
from __future__ import with_statement
import threading
from os.path import join
from subprocess import Popen, PIPE, STDOUT
from time import sleep
from signal import SIGINT
import os

class WebServer(threading.Thread):
    def __init__(self, pycore):
        threading.Thread.__init__(self)
        self.pycore = pycore
        self.running = True
        self.setDaemon(True)
    
    def run(self):
        host = self.pycore.config['webinterface']['host']
        port = self.pycore.config['webinterface']['port']
        self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) )
        self.p = Popen(['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)], close_fds=True, stderr=PIPE, stdin=PIPE, stdout=PIPE)
        #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port)))
        #@TODO: better would be real python code
        sleep(1)
        with open("webserver.pid", "r") as f:
            self.pid = int(f.read().strip())
        while self.running:
            sleep(1)
    
    def quit(self):
        os.kill(self.pid, SIGINT)
        self.running = False<commit_msg>webserver for win<commit_after>#!/usr/bin/env python
from __future__ import with_statement
import threading
from os.path import join
from subprocess import Popen, PIPE, STDOUT
from time import sleep
from signal import SIGINT
import os

class WebServer(threading.Thread):
    def __init__(self, pycore):
        threading.Thread.__init__(self)
        self.pycore = pycore
        self.running = True
        self.setDaemon(True)
    
    def run(self):
        host = self.pycore.config['webinterface']['host']
        port = self.pycore.config['webinterface']['port']
        command = ['python',join(self.pycore.path,"module","web","manage.py"), "runserver", "%s:%s" % (host,port)]
        self.pycore.logger.info("Starting Webserver: %s:%s" % (host,port) )
        
        if os.name == 'posix':
            self.p = Popen(command, close_fds=True, stderr=PIPE, stdin=PIPE, stdout=PIPE)
            #os.system("python " + join(self.pycore.path,"module","web","manage.py runserver %s:%s" % (host,port)))
            #@TODO: better would be real python code
            sleep(1)
            with open("webserver.pid", "r") as f:
                self.pid = int(f.read().strip())
            while self.running:
                sleep(1)
        else:
            self.p = Popen(command, stderr=PIPE, stdin=PIPE, stdout=PIPE)
            while self.running:
                sleep(1)
    
    def quit(self):
        if os.name == 'posix':
            os.kill(self.pid, SIGINT)
        else:
            self.p.kill()
        
        self.running = False
{'fraction_non_alphanumeric': 0.141723764875586, 'fraction_numerical': 0.0018031013342949874, 'mean_word_length': 2.5747422680412373, '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': '2613961', 'n_tokens_mistral': 885, 'n_tokens_neox': 872, 'n_words': 194}