当前位置: 首页>>代码示例>>Python>>正文


Python XMPPClient.stopService方法代码示例

本文整理汇总了Python中wokkel.client.XMPPClient.stopService方法的典型用法代码示例。如果您正苦于以下问题:Python XMPPClient.stopService方法的具体用法?Python XMPPClient.stopService怎么用?Python XMPPClient.stopService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wokkel.client.XMPPClient的用法示例。


在下文中一共展示了XMPPClient.stopService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Output

# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import stopService [as 别名]
class Output(cowrie.core.output.Output):

    def __init__(self):
        cowrie.core.output.Output.__init__(self)

    def start(self):
        from random import choice
        import string

        server = CONFIG.get('output_xmpp', 'server')
        user = CONFIG.get('output_xmpp', 'user')
        password = CONFIG.get('output_xmpp', 'password')
        muc = CONFIG.get('output_xmpp', 'muc')
        resource = ''.join([choice(string.ascii_letters)
                            for i in range(8)])
        jid = user + '/' + resource
        application = service.Application('honeypot')
        self.run(application, jid, password, JID(None, [muc, server, None]), server)

    def run(self, application, jidstr, password, muc, server):

        self.xmppclient = XMPPClient(JID(jidstr), password)
        if CONFIG.has_option('output_xmpp', 'debug') and \
                CONFIG.getboolean('output_xmpp', 'debug') is True:
            self.xmppclient.logTraffic = True  # DEBUG HERE
        (user, host, resource) = jid.parse(jidstr)
        self.muc = XMPPLoggerProtocol(
            muc, server, user + '-' + resource)
        self.muc.setHandlerParent(self.xmppclient)
        self.xmppclient.setServiceParent(application)
        self.anonymous = True
        self.xmppclient.startService()

    def write(self, logentry):
        for i in list(logentry.keys()):
            # Remove twisted 15 legacy keys
            if i.startswith('log_'):
                del logentry[i]
            elif i == "time":
                del logentry[i]
        msgJson = json.dumps(logentry, indent=5)

        self.muc.groupChat(self.muc.jrooms, msgJson)

    def stop(self):
        self.xmppclient.stopService()
开发者ID:davegermiquet,项目名称:cowrie,代码行数:48,代码来源:xmpp.py

示例2: StatusBotService

# 需要导入模块: from wokkel.client import XMPPClient [as 别名]
# 或者: from wokkel.client.XMPPClient import stopService [as 别名]
class StatusBotService(service.Service):
    def __init__(self):
        self.client = XMPPClient(JID(config.JABBER_CLIENT_USER),
                                 config.JABBER_CLIENT_PASS,
                                 config.JABBER_CLIENT_HOST)
        self.presenceFetcher = PresenceFetcher()
        self.presenceFetcher.setHandlerParent(self.client)
        self.tweeter = Tweeter()
        self.loopingCall = LoopingCall(self.makeRequest)

    def startService(self):
        service.Service.startService(self)
        self.client.startService()
        self.loopingCall.start(config.REFRESH_INTERVAL_SECS)

    def stopService(self):
        service.Service.stopService(self)
        self.loopingCall.stop()
        self.client.stopService()

    def makeRequest(self):
        d = self.presenceFetcher.doProbe(config.JABBER_TARGET)
        d.addCallbacks(self._sendTweet, log.err)
        return d

    def _sendTweet(self, statuses):
        if not statuses:
            log.msg("No statuses received")
            return succeed(None)
        else:
            d = self.tweeter.tweet(statuses[0])
            d.addCallback(self._receiveTweetResponse)
            return d

    def _receiveTweetResponse(self, result):
        code, body = result
        # 403 is probably a duplicate tweet
        if code == 200:
            decoded = json.loads(body)
            log.msg("Tweeted new status: " + decoded['text'])
        elif code == 403:
            log.msg("Duplicate tweet, ignoring")
        else:
            log.err("Error tweeting {}: {}".format(code, body))
开发者ID:stillinbeta,项目名称:statusbot,代码行数:46,代码来源:service.py


注:本文中的wokkel.client.XMPPClient.stopService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。