<commit_before># -*- coding: utf8 -*-
import ConfigParser
import traceback
import sys

g_port = '5000'
g_bind = '::'
g_refresh = '30'
g_ssl = 'False'
g_standalone = 'True'
g_sslcert = ''
g_sslkey = ''
g_version = '1'
g_auth = 'basic'
g_acl = ''

class BUIServer:
    def __init__(self, app=None):
        self.init = False
        self.app = app

    def setup(self, conf=None):
        global g_refresh, g_port, g_bind, g_ssl, g_sslcert, g_sslkey, g_version, g_auth, g_standalone, g_acl
        self.sslcontext = None
        if not conf:
            conf = self.app.config['CFG']

        if not conf:
            raise IOError('No configuration file found')

        config = ConfigParser.ConfigParser({'port': g_port,'bind': g_bind,
                    'refresh': g_refresh, 'ssl': g_ssl, 'sslcert': g_sslcert,
                    'sslkey': g_sslkey, 'version': g_version, 'auth': g_auth,
                    'standalone': g_standalone, 'acl': g_acl})
        with open(conf) as fp:
            config.readfp(fp)
            try:
                self.port = config.getint('Global', 'port')
                self.bind = config.get('Global', 'bind')
                self.vers = config.getint('Global', 'version')
                try:
                    self.ssl = config.getboolean('Global', 'ssl')
                except ValueError:
                    self.app.logger.error("Wrong value for 'ssl' key! Assuming 'false'")
                    self.ssl = False
                try:
                    self.standalone = config.getboolean('Global', 'standalone')
                except ValueError:
                    self.app.logger.error("Wrong value for 'standalone' key! Assuming 'True'")
                    self.standalone = True
                self.sslcert = config.get('Global', 'sslcert')
                self.sslkey = config.get('Global', 'sslkey')
                self.auth = config.get('Global', 'auth')
                if self.auth and self.auth != 'none':
                    try:
                        mod = __import__('burpui.misc.auth.{0}'.format(self.auth), fromlist=['UserHandler'])
                        UserHandler = mod.UserHandler
                        self.uhandler = UserHandler(self.app)
                    except Exception, e:
                        traceback.print_exc()
                        self.app.logger.error('Import Exception, module \'%s\': %s', self.auth, str(e))
                        sys.exit(1)
                else:
                    # I know that's ugly, but hey, I need it!
                    self.app.login_manager._login_disabled = True
                self.acl_engine = config.get('Global', 'acl')
                if self.acl_engine and self.acl_engine != 'none':
                    try:
                        mod = __import__('burpui.misc.acl.{0}'.format(self.acl_engine), fromlist=['ACLloader'])
                        ACLloader = mod.ACLloader
                        self.acl_handler = ACLloader(self.app, self.standalone)
                    except Exception, e:
                        traceback.print_exc()
                        self.app.logger.error('Import Exception, module \'%s\': %s', self.acl_engine, str(e))
                        sys.exit(1)
                else:
                    self.acl_handler = False
            except ConfigParser.NoOptionError, e:
                self.app.logger.error(str(e))

            self.app.config['REFRESH'] = config.getint('UI', 'refresh')

        self.app.config['STANDALONE'] = self.standalone

        self.app.logger.info('burp version: %d', self.vers)
        self.app.logger.info('listen port: %d', self.port)
        self.app.logger.info('bind addr: %s', self.bind)
        self.app.logger.info('use ssl: %s', self.ssl)
        self.app.logger.info('standalone: %s', self.standalone)
        self.app.logger.info('sslcert: %s', self.sslcert)
        self.app.logger.info('sslkey: %s', self.sslkey)
        self.app.logger.info('refresh: %d', self.app.config['REFRESH'])

        if self.standalone:
            module = 'burpui.misc.backend.burp{0}'.format(self.vers)
        else:
            module = 'burpui.misc.backend.multi'
        try:
            mod = __import__(module, fromlist=['Burp'])
            Client = mod.Burp
            self.cli = Client(self, conf=conf)
        except Exception, e:
            traceback.print_exc()
            self.app.logger.error('Failed loading backend for Burp version %d: %s', self.vers, str(e))
            sys.exit(2)

        self.init = True

    def run(self, debug=False):
        if not self.init:
            self.setup()

        if self.ssl:
            from OpenSSL import SSL
            self.sslcontext = SSL.Context(SSL.SSLv23_METHOD)
            self.sslcontext.use_privatekey_file(self.sslkey)
            self.sslcontext.use_certificate_file(self.sslcert)

        if self.sslcontext:
            self.app.config['SSL'] = True
            self.app.run(host=self.bind, port=self.port, debug=debug, ssl_context=self.sslcontext)
        else:
            self.app.run(host=self.bind, port=self.port, debug=debug)
<commit_msg>add a dummy object to make the development completion more accurate<commit_after># -*- coding: utf8 -*-
import ConfigParser
import traceback
import sys

from burpui.misc.backend.burp1 import Burp as BurpGeneric

g_port = '5000'
g_bind = '::'
g_refresh = '30'
g_ssl = 'False'
g_standalone = 'True'
g_sslcert = ''
g_sslkey = ''
g_version = '1'
g_auth = 'basic'
g_acl = ''


class BUIServer:
    def __init__(self, app=None):
        self.init = False
        self.app = app

    def setup(self, conf=None):
        global g_refresh, g_port, g_bind, g_ssl, g_sslcert, g_sslkey, g_version, g_auth, g_standalone, g_acl
        self.sslcontext = None
        if not conf:
            conf = self.app.config['CFG']

        if not conf:
            raise IOError('No configuration file found')

        config = ConfigParser.ConfigParser({'port': g_port, 'bind': g_bind,
                    'refresh': g_refresh, 'ssl': g_ssl, 'sslcert': g_sslcert,
                    'sslkey': g_sslkey, 'version': g_version, 'auth': g_auth,
                    'standalone': g_standalone, 'acl': g_acl})
        with open(conf) as fp:
            config.readfp(fp)
            try:
                self.port = config.getint('Global', 'port')
                self.bind = config.get('Global', 'bind')
                self.vers = config.getint('Global', 'version')
                try:
                    self.ssl = config.getboolean('Global', 'ssl')
                except ValueError:
                    self.app.logger.error("Wrong value for 'ssl' key! Assuming 'false'")
                    self.ssl = False
                try:
                    self.standalone = config.getboolean('Global', 'standalone')
                except ValueError:
                    self.app.logger.error("Wrong value for 'standalone' key! Assuming 'True'")
                    self.standalone = True
                self.sslcert = config.get('Global', 'sslcert')
                self.sslkey = config.get('Global', 'sslkey')
                self.auth = config.get('Global', 'auth')
                if self.auth and self.auth != 'none':
                    try:
                        mod = __import__('burpui.misc.auth.{0}'.format(self.auth), fromlist=['UserHandler'])
                        UserHandler = mod.UserHandler
                        self.uhandler = UserHandler(self.app)
                    except Exception, e:
                        traceback.print_exc()
                        self.app.logger.error('Import Exception, module \'%s\': %s', self.auth, str(e))
                        sys.exit(1)
                else:
                    # I know that's ugly, but hey, I need it!
                    self.app.login_manager._login_disabled = True
                self.acl_engine = config.get('Global', 'acl')
                if self.acl_engine and self.acl_engine != 'none':
                    try:
                        mod = __import__('burpui.misc.acl.{0}'.format(self.acl_engine), fromlist=['ACLloader'])
                        ACLloader = mod.ACLloader
                        self.acl_handler = ACLloader(self.app, self.standalone)
                    except Exception, e:
                        traceback.print_exc()
                        self.app.logger.error('Import Exception, module \'%s\': %s', self.acl_engine, str(e))
                        sys.exit(1)
                else:
                    self.acl_handler = False
            except ConfigParser.NoOptionError, e:
                self.app.logger.error(str(e))

            self.app.config['REFRESH'] = config.getint('UI', 'refresh')

        self.app.config['STANDALONE'] = self.standalone

        self.app.logger.info('burp version: %d', self.vers)
        self.app.logger.info('listen port: %d', self.port)
        self.app.logger.info('bind addr: %s', self.bind)
        self.app.logger.info('use ssl: %s', self.ssl)
        self.app.logger.info('standalone: %s', self.standalone)
        self.app.logger.info('sslcert: %s', self.sslcert)
        self.app.logger.info('sslkey: %s', self.sslkey)
        self.app.logger.info('refresh: %d', self.app.config['REFRESH'])

        if self.standalone:
            module = 'burpui.misc.backend.burp{0}'.format(self.vers)
        else:
            module = 'burpui.misc.backend.multi'
        self.cli = BurpGeneric(dummy=True)
        try:
            mod = __import__(module, fromlist=['Burp'])
            Client = mod.Burp
            self.cli = Client(self, conf=conf)
        except Exception, e:
            traceback.print_exc()
            self.app.logger.error('Failed loading backend for Burp version %d: %s', self.vers, str(e))
            sys.exit(2)

        self.init = True

    def run(self, debug=False):
        if not self.init:
            self.setup()

        if self.ssl:
            from OpenSSL import SSL
            self.sslcontext = SSL.Context(SSL.SSLv23_METHOD)
            self.sslcontext.use_privatekey_file(self.sslkey)
            self.sslcontext.use_certificate_file(self.sslcert)

        if self.sslcontext:
            self.app.config['SSL'] = True
            self.app.run(host=self.bind, port=self.port, debug=debug, ssl_context=self.sslcontext)
        else:
            self.app.run(host=self.bind, port=self.port, debug=debug)
{'fraction_non_alphanumeric': 0.12590239676581, 'fraction_numerical': 0.0031764366156511693, 'mean_word_length': 1.7356503422854135, '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': '458202', 'n_tokens_mistral': 3138, 'n_tokens_neox': 2993, 'n_words': 629}