本文整理汇总了Python中wokkel.client.XMPPClient.logTraffic方法的典型用法代码示例。如果您正苦于以下问题:Python XMPPClient.logTraffic方法的具体用法?Python XMPPClient.logTraffic怎么用?Python XMPPClient.logTraffic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wokkel.client.XMPPClient
的用法示例。
在下文中一共展示了XMPPClient.logTraffic方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeService
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def makeService(self, options):
with open(options.config, "r") as config_file:
config = json.load(config_file)
root = resource.Resource()
root.putChild('jsMath', static.File(config["global"]["jsmath"]))
bot = service.MultiService()
xmppclient = XMPPClient(JID(config["global"]["jid"]),
config["global"]["password"])
xmppclient.logTraffic = options['verbose']
xmppclient.setServiceParent(bot)
xmppclient.dbpool = DatabaseRunner(config["global"]["database"])
xmppclient.rooms = dict()
xmlrpc_port = config["global"].get("xml-rpc-port", None)
if xmlrpc_port is not None:
xmlrpcinterface = XMLRPCInterface(xmppclient)
rpc = internet.TCPServer(xmlrpc_port, server.Site(xmlrpcinterface))
rpc.setName('XML-RPC')
rpc.setServiceParent(bot)
for muc_config in config["mucs"]:
room_jid = JID(muc_config["jid"])
mucbot = KITBot(room_jid, muc_config.get("password", None),
config["global"]["logpath"])
mucbot.setHandlerParent(xmppclient)
if "xml-rpc-id" in muc_config:
xmppclient.rooms[muc_config["xml-rpc-id"]] = mucbot
# Log resource
portal = Portal(
LogViewRealm(os.path.join(config["global"]['logpath'],
room_jid.user + '.log')),
[strcred.makeChecker(muc_config["log-auth"])]
)
credential_factory = DigestCredentialFactory('md5', 'Hello Kitty!')
auth_resource = HTTPAuthSessionWrapper(portal, [credential_factory])
root.putChild(room_jid.user, auth_resource)
httpd_log_view = internet.TCPServer(config["global"]["http-port"],
server.Site(root))
httpd_log_view.setServiceParent(bot)
# REPL over SSH
def makeREPLProtocol():
namespace = dict(bot=xmppclient)
return insults.ServerProtocol(manhole.ColoredManhole, namespace)
repl_realm = manhole_ssh.TerminalRealm()
repl_realm.chainedProtocolFactory = makeREPLProtocol
repl_checker = checkers.SSHPublicKeyDatabase()
repl_portal = Portal(repl_realm, [repl_checker])
repl_factory = manhole_ssh.ConchFactory(repl_portal)
repl = internet.TCPServer(config["global"]["ssh-port"], repl_factory)
repl.setServiceParent(bot)
return bot
示例2: connect
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def connect(self):
application = service.Application("gbot")
xmppclient = XMPPClient(jid.internJID(self.username), self.password)
xmppclient.logTraffic = False
self.protocol = GBotProtocol()
self.protocol.bot = self
self.protocol.setHandlerParent(xmppclient)
xmppclient.setServiceParent(application)
return application
示例3: setupConnection
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def setupConnection(self):
xmppclient = XMPPClient(self.jid, self.password, self.jabber_server)
xmppclient.logTraffic = False
xmppbot = XMPPCassBot(self, self.state['nickname'])
xmppbot.conference_server = self.conference_server
xmppbot.setHandlerParent(xmppclient)
xmppclient.setServiceParent(self)
self.xmppbot = xmppbot
self.xmppclient = xmppclient
示例4: createService
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def createService():
bot_jid = "{0}@{1}/{2}".format(cfg.connect.jabber.jid, cfg.connect.jabber.server, cfg.connect.jabber.resource)
xmppclient = XMPPClient(jid.internJID(bot_jid), cfg.connect.jabber.password, cfg.connect.jabber.server)
xmppclient.logTraffic = cfg.connect.jabber.log_traffic
# Send some whitespace every once in a while to stay alive
KeepAlive().setHandlerParent(xmppclient)
# Hook chat instance into main app
connection = JabberConnector()
FritBot.bot.registerConnector(connection)
connection.setHandlerParent(xmppclient)
return xmppclient
示例5: makeService
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def makeService(self, options):
"""
Construct a TCPServer from a factory defined in myproject.
"""
multi_service = MultiService()
from wokkel.client import XMPPClient
from twisted.words.protocols.jabber import jid
import forwarder
xmppclient = XMPPClient(jid.internJID(options["account"]), options["password"])
xmppclient.logTraffic = False
bot = forwarder.ForwarderProtocol(options["uri"])
bot.setHandlerParent(xmppclient)
multi_service.addService(xmppclient)
return multi_service
示例6: initIrcJabberRelay
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def initIrcJabberRelay(application):
manager = RelayManager()
# Configure IRC
ircfactory = IrcBotFactory(manager, cfg["ircchannel"], cfg["ircnick"], manager.sendJabber)
# point = TCP4ClientEndpoint(reactor, 'irc.freenode.net', 6667)
# d = point.connect(ircfactory)
# d.addCallback(gotProtocol)
connector = internet.TCPClient(cfg["ircserver"], cfg["ircport"], ircfactory)
connector.setServiceParent(application)
# Configure Jabber
xmppclient = XMPPClient(jid.internJID(cfg["jabberjid"]), cfg["jabberpass"])
jabberbot = JabberBot(manager, cfg["jabberserver"], cfg["jabberchannel"], cfg["jabbernick"], manager.sendIRC)
xmppclient.logTraffic = False
jabberbot.setHandlerParent(xmppclient)
xmppclient.setServiceParent(application)
manager.setJabber(jabberbot)
示例7: makeService
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def makeService(config):
if IQ.timeout is None:
IQ.timeout = 30
xmppService = XMPPClient(config['jid'], config['secret'],
config.get('xmpp-host'),
config.get('xmpp-port', 5222))
if config['verbose']:
xmppService.logTraffic = True
presenceHandler = PresenceHandler()
presenceHandler.setHandlerParent(xmppService)
pinger = Pinger(config['service'])
pinger.setHandlerParent(xmppService)
pinger.verbose = config['verbose']
return xmppService
示例8: make_client
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def make_client(config):
keepalive = KeepAlive()
keepalive.interval = config.getint('hipchat', 'keepalive.interval')
xmppclient = XMPPClient(
jid.internJID(config.get('hipchat', 'jabber_id')),
config.get('hipchat', 'password')
)
xmppclient.logTraffic = config.getboolean('hipchat', 'logtraffic')
mucbot = HipBot(
config.get('hipchat', 'server'),
config.get('hipchat', 'channel'),
config.get('hipchat', 'botnick'),
config.get('hipchat', 'stfu_minutes'))
mucbot.setHandlerParent(xmppclient)
keepalive.setHandlerParent(xmppclient)
return xmppclient
示例9: make_client
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
def make_client(bot, config, password):
keepalive = KeepAlive()
keepalive.interval = 30
xmppclient = XMPPClient(jid.internJID(config.get("hipchat", "jid")), password)
xmppclient.logTraffic = True
team_members = [n.strip() for n in config.get("team", "members").decode("utf-8").strip().split(u",")]
mucbot = HipchatBot(
bot,
config.get("hipchat", "room_server"),
config.get("hipchat", "room_jid"),
config.get("team", "room_name"),
config.get("hipchat", "nickname"),
config.get("hipchat", "stfu_minutes"),
team_members,
)
mucbot.setHandlerParent(xmppclient)
keepalive.setHandlerParent(xmppclient)
return xmppclient
示例10: JID
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
# Configuration parameters
config = ConfigParser.RawConfigParser()
config.read('bot.conf')
myJID = JID(config.get('Connection', 'my_jid'))
roomJID = JID(config.get('Connection', 'room_jid'))
roomPassword = config.get('Connection', 'room_password')
my_nick = config.get('Connection', 'my_nick')
my_secret = config.get('Connection', 'my_secret')
rt_url = config.get('RT', 'url')
rt_display_url = config.get('RT','display_url')
rt_user = config.get('RT', 'user')
rt_pwd = config.get('RT', 'pwd')
rt_default_queue = config.get('RT','default_queue')
LOG_TRAFFIC = False
#LOG_TRAFFIC = True
# Set up the Twisted application
application = service.Application("MUC Client")
client = XMPPClient(myJID, my_secret)
client.logTraffic = LOG_TRAFFIC
client.setServiceParent(application)
mucHandler = RTBot(roomJID, my_nick, rt_url, rt_user, rt_pwd, roomPassword, rt_display_url, output_format)
mucHandler.setHandlerParent(client)
示例11: abort_job
# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import logTraffic [as 别名]
output = (self.PACKET.get_packet(packet_id), None) # Return status.
return output
def abort_job(self, vm_jid, job_id):
""" Terminate a job. """
self.__send__(self.abort_job_packet(vm_jid, job_id))
def terminate_vm(self, vm_jid):
""" Terminate a VM. """
self.__send__(packet)
# Misc.
if __name__ == "__main__":
FARM_JID = raw_input("Farm JID: ")
MY_JID = raw_input("My JID: ")
PASSWORD = raw_input("My password: ")
app = service.Application("TestVillein")
test_villein = villein(MY_JID, PASSWORD, FARM_JID)
xmpp_client = XMPPClient(test_villein.JID, PASSWORD)
xmpp_client.logTraffic = False
test_villein.setHandlerParent(xmpp_client)
xmpp_client.setServiceParent(app)