<commit_before>#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2014 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import socket
import time
import sys
import os
import threading
import traceback
import json
import Queue

import util
from network import Network
from util import print_error, print_stderr, parse_json
from simple_config import SimpleConfig

DAEMON_PORT=8001


def do_start_daemon(config):
    import subprocess
    logfile = open(os.path.join(config.path, 'daemon.log'),'w')
    p = subprocess.Popen(["python",__file__], stderr=logfile, stdout=logfile, close_fds=True)
    print_stderr("starting daemon (PID %d)"%p.pid)


def get_daemon(config, start_daemon=True):
    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    daemon_port = config.get('daemon_port', DAEMON_PORT)
    daemon_started = False
    while True:
        try:
            s.connect(('', daemon_port))
            return s
        except socket.error:
            if not start_daemon:
                return False
            elif not daemon_started:
                do_start_daemon(config)
                daemon_started = True
            else:
                time.sleep(0.1)



class ClientThread(threading.Thread):

    def __init__(self, server, s):
        threading.Thread.__init__(self)
        self.server = server
        self.daemon = True<commit_msg>Fix issue with daemon socket on OS X<commit_after>#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2014 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import socket
import time
import sys
import os
import threading
import traceback
import json
import Queue

import util
from network import Network
from util import print_error, print_stderr, parse_json
from simple_config import SimpleConfig

DAEMON_PORT=8001


def do_start_daemon(config):
    import subprocess
    logfile = open(os.path.join(config.path, 'daemon.log'),'w')
    p = subprocess.Popen(["python",__file__], stderr=logfile, stdout=logfile, close_fds=True)
    print_stderr("starting daemon (PID %d)"%p.pid)


def get_daemon(config, start_daemon=True):
    import socket
    daemon_port = config.get('daemon_port', DAEMON_PORT)
    daemon_started = False
    while True:
        try:
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.connect(('', daemon_port))
            return s
        except socket.error:
            if not start_daemon:
                return False
            elif not daemon_started:
                do_start_daemon(config)
                daemon_started = True
            else:
                time.sleep(0.1)



class ClientThread(threading.Thread):

    def __init__(self, server, s):
        threading.Thread.__init__(self)
        self.server = server
        self.daemon = True
{'fraction_non_alphanumeric': 0.0774385703648548, 'fraction_numerical': 0.005460412012906428, 'mean_word_length': 3.146090534979424, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2168840', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1130, 'n_words': 414}