<commit_before>from __future__ import with_statement

import time
import sys
import json

from os.path import exists
from StringIO import StringIO
import ConfigParser

from helpers import get_upstream_from_central
from simpleauth import SimpleAuth


class FurionConfig(object):

    last_update = 0

    @classmethod
    def init(cls, path):

        default_cfg = StringIO("""
[main]
local_ip = 127.0.0.1
local_port = 11080
rpc_port = 11081
local_ssl = off
pem_path = 
local_auth = off
allowed_ports = 22,53,80,443
ping_server = off
dns_server = on
dns_server_port = 15353
dns_proxy = off
dns_proxy_port = 11053
remote_tcp_dns = 8.8.4.4
log_level = 20
log_path = 

[upstream]
central_url = 
autoupdate_upstream_list = off
update_frequency = weekly
upstream_list_path = upstream.json
# upstream_ip =
# upstream_port = 443
# upstream_ssl = on
# upstream_auth = on
# upstream_username = 
# upstream_password =

[plugin]
auth_plugin = 
        """)
        
        cls.config = ConfigParser.ConfigParser()
        cls.config.readfp(default_cfg)
        cls.config.read(path)    

        auth_plugin = cls.config.get('plugin', 'auth_plugin')

        cls.authority = None
        if auth_plugin == 'simpleauth':
            cls.authority = SimpleAuth()

        cls.local_ip = cls.config.get('main', 'local_ip')
        cls.local_port = cls.config.getint('main', 'local_port')
        cls.rpc_port = cls.config.getint('main', 'rpc_port')

        cls.local_ssl = cls.config.getboolean('main', 'local_ssl')
        cls.local_auth = cls.config.getboolean('main', 'local_auth')
        cls.pem_path = cls.config.get('main', 'pem_path')
        if cls.pem_path and not exists(cls.pem_path):
            print 'Fatal error: pem "%s" cannot be found.' % cls.pem_path
            time.sleep(3)
            sys.exit(-1)
        ports = cls.config.get('main', 'allowed_ports').strip()
        if ports == 'all' or ports == ''<commit_msg>bug fix<commit_after>from __future__ import with_statement

import time
import sys
import json

from os.path import exists
from StringIO import StringIO
import ConfigParser

from helpers import get_upstream_from_central
from simpleauth import SimpleAuth


class FurionConfig(object):

    last_update = 0

    @classmethod
    def init(cls, path):

        default_cfg = StringIO("""
[main]
local_ip = 127.0.0.1
local_port = 11080
rpc_port = 11081
local_ssl = off
pem_path = 
local_auth = off
allowed_ports = 22,53,80,443
ping_server = off
dns_server = on
dns_server_port = 15353
dns_proxy = off
dns_proxy_port = 11053
remote_tcp_dns = 8.8.4.4
log_level = 20
log_path = 

[upstream]
central_url = 
autoupdate_upstream_list = off
update_frequency = weekly
upstream_list_path = upstream.json
# upstream_ip =
# upstream_port = 443
# upstream_ssl = on
# upstream_auth = on
# upstream_username = 
# upstream_password =

[plugin]
auth_plugin = 
        """)
        
        cls.config = ConfigParser.ConfigParser()
        cls.config.readfp(default_cfg)
        cls.config.read(path)    

        auth_plugin = cls.config.get('plugin', 'auth_plugin')

        cls.authority = None
        if auth_plugin == 'simpleauth':
            cls.authority = SimpleAuth()

        cls.local_ip = cls.config.get('main', 'local_ip')
        cls.local_port = cls.config.getint('main', 'local_port')
        cls.rpc_port = cls.config.getint('main', 'rpc_port')

        cls.local_ssl = cls.config.getboolean('main', 'local_ssl')
        cls.local_auth = cls.config.getboolean('main', 'local_auth')
        cls.pem_path = cls.config.get('main', 'pem_path')
        if cls.pem_path and not exists(cls.pem_path):
            print 'Fatal error: pem "%s" cannot be found.' % cls.pem_path
            time.sleep(3)
            sys.exit(-1)
        ports = cls.config.get('main', 'allowed_ports').strip()
        if ports == 'all' or ports == '':
{'fraction_non_alphanumeric': 0.11047569534702366, 'fraction_numerical': 0.02443462438263582, 'mean_word_length': 3.119914346895075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1611419', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1292, 'n_words': 287}