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


Python Network.is_ssl方法代码示例

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


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

示例1: MainWindow

# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import is_ssl [as 别名]

#.........这里部分代码省略.........
        if self.isFullScreen():
            self.showNormal()
        else:
            self.showFullScreen()

    def connect_weechat(self):
        """Connect to WeeChat."""
        self.network.connect_weechat(
            self.connection_dialog.fields['server'].text(),
            self.connection_dialog.fields['port'].text(),
            self.connection_dialog.fields['ssl'].isChecked(),
            self.connection_dialog.fields['password'].text(),
            int(self.connection_dialog.fields['lines'].text()),
            int(self.connection_dialog.fields['ping'].text()))
        self.connection_dialog.close()

    def _network_status_changed(self, status, extra):
        """Called when the network status has changed."""
        if self.config.getboolean('look', 'statusbar'):
            self.statusBar().showMessage(status)
        self.debug_display(0, '', status, forcecolor='#0000AA')
        self.network_status_set(status)
        self.notifier.set_icon(status)

    def network_status_set(self, status):
        """Set the network status."""
        pal = self.network_status.palette()
        if status == self.network.status_connected:
            fg_color = QtGui.QColor('green')
        else:
            fg_color = self.menu.palette().windowText().color()
        pal.setColor(QtGui.QPalette.ButtonText, fg_color)
        ssl = ' (SSL)' if status != self.network.status_disconnected \
              and self.network.is_ssl() else ''
        self.network_status.setPalette(pal)
        icon = self.network.status_icon(status)
        if icon:
            qicon = utils.qicon_from_theme(icon)
            self.network_status.setIcon(qicon)
        self.network_status.setText(status.capitalize() + ssl)
        if status == self.network.status_disconnected:
            self.actions['connect'].setEnabled(True)
            self.actions['disconnect'].setEnabled(False)
        else:
            self.actions['connect'].setEnabled(False)
            self.actions['disconnect'].setEnabled(True)

    def _network_weechat_msg(self, message):
        """Called when a message is received from WeeChat."""
        self.debug_display(0, '==>',
                           'message (%d bytes):\n%s'
                           % (len(message),
                              protocol.hex_and_ascii(message, 20)),
                           forcecolor='#008800')
        try:
            proto = protocol.Protocol()
            message = proto.decode(str(message))
            if message.uncompressed:
                self.debug_display(
                    0, '==>',
                    'message uncompressed (%d bytes):\n%s'
                    % (message.size_uncompressed,
                       protocol.hex_and_ascii(message.uncompressed, 20)),
                    forcecolor='#008800')
            self.debug_display(0, '', 'Message: %s' % message)
            self.parse_message(message)
开发者ID:rickybrent,项目名称:qweechat,代码行数:70,代码来源:qweechat.py

示例2: MainWindow

# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import is_ssl [as 别名]

#.........这里部分代码省略.........
        for option in ('server', 'port', 'ssl', 'password', 'lines'):
            values[option] = self.config.get('relay', option)
        self.connection_dialog = ConnectionDialog(values, self)
        self.connection_dialog.dialog_buttons.accepted.connect(
            self.connect_weechat)

    def connect_weechat(self):
        """Connect to WeeChat."""
        self.network.connect_weechat(
            self.connection_dialog.fields['server'].text(),
            self.connection_dialog.fields['port'].text(),
            self.connection_dialog.fields['ssl'].isChecked(),
            self.connection_dialog.fields['password'].text(),
            int(self.connection_dialog.fields['lines'].text()))
        self.connection_dialog.close()

    def _network_status_changed(self, status, extra):
        """Called when the network status has changed."""
        if self.config.getboolean('look', 'statusbar'):
            self.statusBar().showMessage(status)
        self.debug_display(0, '', status, forcecolor='#0000AA')
        self.network_status_set(status)

    def network_status_set(self, status):
        """Set the network status."""
        pal = self.network_status.palette()
        if status == self.network.status_connected:
            pal.setColor(self.network_status.foregroundRole(),
                         QtGui.QColor('green'))
        else:
            pal.setColor(self.network_status.foregroundRole(),
                         QtGui.QColor('#aa0000'))
        ssl = ' (SSL)' if status != self.network.status_disconnected \
              and self.network.is_ssl() else ''
        self.network_status.setPalette(pal)
        icon = self.network.status_icon(status)
        if icon:
            self.network_status.setText(
                '<img src="%s"> %s' %
                (resource_filename(__name__, 'data/icons/%s' % icon),
                 status.capitalize() + ssl))
        else:
            self.network_status.setText(status.capitalize())
        if status == self.network.status_disconnected:
            self.actions['connect'].setEnabled(True)
            self.actions['disconnect'].setEnabled(False)
        else:
            self.actions['connect'].setEnabled(False)
            self.actions['disconnect'].setEnabled(True)

    def _network_weechat_msg(self, message):
        """Called when a message is received from WeeChat."""
        self.debug_display(0, '==>',
                           'message (%d bytes):\n%s'
                           % (len(message),
                              protocol.hex_and_ascii(message, 20)),
                           forcecolor='#008800')
        try:
            proto = protocol.Protocol()
            message = proto.decode(str(message))
            if message.uncompressed:
                self.debug_display(
                    0, '==>',
                    'message uncompressed (%d bytes):\n%s'
                    % (message.size_uncompressed,
                       protocol.hex_and_ascii(message.uncompressed, 20)),
开发者ID:caustin,项目名称:qweechat,代码行数:70,代码来源:qweechat.py


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