# Path: bnw/core/bnw_mongo.py
# def open_db():
#     global db, fs
#     if config.database_rs:
#         client = motor.MotorReplicaSetClient(config.database_uri,read_preference=ReadPreference.NEAREST, replicaSet=config.database_rs)
#     else:
#         client = motor.MotorClient(config.database_uri,read_preference=ReadPreference.NEAREST)
#     IOLoop.current().run_sync(client.open)
#     db = client[config.database]
#     fs = client[config.database_fs]
# 
# Path: bnw/xmpp/bnw_component.py
# PRESENCE = '/presence'  # this is an global xpath query to use in an observer
# MESSAGE = '/message'    # message xpath
# IQ = '/iq'              # iq xpath
# def create_reply(elem):
# def create_presence(frm, to, childs=[], **kwargs):
#     def transportConnected(self, xmlstream):
#     def rawDataIn(self, buf):
#     def rawDataOut(self, buf):
#     def componentConnected(self, xmlstream):
#     def send_plain(self, jid, src, content):
#     def send_raw(self, jid, src, content):
#     def callbackIq(self, result, original):
#     def onIq(self, iq):
#     def callbackMessage(self, result, jid, stime, src, body):
#     def errbackMessage(self, result, jid, src):
#     def onMessage(self, msg):
#     def onPresence(self, prs):
#     def send_raw_string(self, content):
#     def getRPC(self):
# class LogService(component.Service):
# class BnwService(component.Service):
# 
# Path: bnw/xmpp/xmpp_notifier.py
# class XmppNotifier(object):
# class DummyRequest(object):
#     def notify(self, user, event_type, event):
#     def __init__(self, user):
# 
# Path: bnw/handlers/throttle.py
# def throttle_check(user):
# def throttle_leak():
# def setup_throttle():


import sys
import tornado.platform.twisted
import traceback
import config
import bnw.core.base
import bnw.core.ensure_indexes
import bnw.xmpp.base
        import inspect
    import bnw.web.site
from twisted.application import service, internet
from twisted.words.protocols.jabber import component
from twisted.web import server
from twisted.manhole.telnet import ShellFactory
from time import time
from bnw.core.bnw_mongo import open_db
from bnw.xmpp import bnw_component, xmpp_notifier
from bnw.handlers import throttle, mapreduce
from twisted.internet import reactor
    from bnw.core import statsd
    from twisted.scripts.twistd import run
#!/bin/echo tac is a python source file, but should be started via twistd

try:
    sys.setappdefaultencoding('utf-8')
except:
    sys = reload(sys)
    sys.setdefaultencoding('utf-8')

tornado.platform.twisted.install()


bnw.core.base.config.register(config)
application = service.Application("BnW")

open_db()

reactor.callWhenRunning(bnw.core.ensure_indexes.index)

# Set up XMPP component.
sm = component.buildServiceManager(
    config.srvc_name, config.srvc_pwd,
    ('tcp:'+config.xmpp_server))

# Turn on verbose mode.
bnw_component.LogService().setServiceParent(sm)

# Set up our service.

# Path: bnw/core/bnw_mongo.py
# def open_db():
#     global db, fs
#     if config.database_rs:
#         client = motor.MotorReplicaSetClient(config.database_uri,read_preference=ReadPreference.NEAREST, replicaSet=config.database_rs)
#     else:
#         client = motor.MotorClient(config.database_uri,read_preference=ReadPreference.NEAREST)
#     IOLoop.current().run_sync(client.open)
#     db = client[config.database]
#     fs = client[config.database_fs]
# 
# Path: bnw/xmpp/bnw_component.py
# PRESENCE = '/presence'  # this is an global xpath query to use in an observer
# MESSAGE = '/message'    # message xpath
# IQ = '/iq'              # iq xpath
# def create_reply(elem):
# def create_presence(frm, to, childs=[], **kwargs):
#     def transportConnected(self, xmlstream):
#     def rawDataIn(self, buf):
#     def rawDataOut(self, buf):
#     def componentConnected(self, xmlstream):
#     def send_plain(self, jid, src, content):
#     def send_raw(self, jid, src, content):
#     def callbackIq(self, result, original):
#     def onIq(self, iq):
#     def callbackMessage(self, result, jid, stime, src, body):
#     def errbackMessage(self, result, jid, src):
#     def onMessage(self, msg):
#     def onPresence(self, prs):
#     def send_raw_string(self, content):
#     def getRPC(self):
# class LogService(component.Service):
# class BnwService(component.Service):
# 
# Path: bnw/xmpp/xmpp_notifier.py
# class XmppNotifier(object):
# class DummyRequest(object):
#     def notify(self, user, event_type, event):
#     def __init__(self, user):
# 
# Path: bnw/handlers/throttle.py
# def throttle_check(user):
# def throttle_leak():
# def setup_throttle():


# Path: bnw/scripts/instance.py
import sys
import tornado.platform.twisted
import traceback
import config
import bnw.core.base
import bnw.core.ensure_indexes
import bnw.xmpp.base
        import inspect
    import bnw.web.site
from twisted.application import service, internet
from twisted.words.protocols.jabber import component
from twisted.web import server
from twisted.manhole.telnet import ShellFactory
from time import time
from bnw.core.bnw_mongo import open_db
from bnw.xmpp import bnw_component, xmpp_notifier
from bnw.handlers import throttle, mapreduce
from twisted.internet import reactor
    from bnw.core import statsd
    from twisted.scripts.twistd import run

#!/bin/echo tac is a python source file, but should be started via twistd

try:
    sys.setappdefaultencoding('utf-8')
except:
    sys = reload(sys)
    sys.setdefaultencoding('utf-8')

tornado.platform.twisted.install()


bnw.core.base.config.register(config)
application = service.Application("BnW")

open_db()

reactor.callWhenRunning(bnw.core.ensure_indexes.index)

# Set up XMPP component.
sm = component.buildServiceManager(
    config.srvc_name, config.srvc_pwd,
    ('tcp:'+config.xmpp_server))

# Turn on verbose mode.
bnw_component.LogService().setServiceParent(sm)

# Set up our service.

s = bnw_component.BnwService()