本文整理汇总了Python中sender.Sender.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Sender.connect方法的具体用法?Python Sender.connect怎么用?Python Sender.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sender.Sender
的用法示例。
在下文中一共展示了Sender.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from sender import Sender [as 别名]
# 或者: from sender.Sender import connect [as 别名]
def main():
sender = Sender('localhost')
sender.connect()
sender.create_queue('inbox')
sender.send_message('inbox', 'hello')
sender.disconnect()
receiver = Receiver('localhost')
receiver.connect()
receiver.receive('inbox')
receiver.disconnect()
示例2: GUI
# 需要导入模块: from sender import Sender [as 别名]
# 或者: from sender.Sender import connect [as 别名]
class GUI(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self,parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.addCarriers()
self.thread = Sender()
self.connect(self.ui.actionAbout, QtCore.SIGNAL('triggered()'), self.showAbout)
self.connect(self.ui.actionQuit, QtCore.SIGNAL('triggered()'), exit)
self.connect(self.ui.button, QtCore.SIGNAL('clicked()'), self.toggle)
self.connect(self.thread, QtCore.SIGNAL("finished()"), self.done)
self.connect(self.thread, QtCore.SIGNAL("terminated()"), self.done)
self.connect(self.thread, QtCore.SIGNAL("plusOne()"), self.plusOne)
self.connect(self.thread, QtCore.SIGNAL("sendingError()"), self.stop)
self.ui.server.setText('127.0.0.1:25') #set default
self.ui.message.setPlainText('SPAM!')
self.ui.statusBar().showMessage('Ready') #broken
def toggle(self):
self.state = self.ui.button.text()
if self.state == 'Start':
self.start()
if self.state == 'Stop':
self.stop()
def stop(self):
self.thread.terminate()
print('stoping')
self.done()
def done(self):
self.ui.button.setText('Start')
self.ui.phone.setEnabled(True)
self.ui.provider.setEnabled(True)
self.ui.server.setEnabled(True)
self.ui.tls.setEnabled(True)
self.ui.user.setEnabled(True)
self.ui.password.setEnabled(True)
self.ui.message.setEnabled(True)
def start(self):
if self.ui.phone.text() != '' and self.thread.connect(
self.ui.server.text(),
self.ui.user.text(),
self.ui.password.text(),
self.ui.tls.isChecked()
):
self.ui.button.setText('Stop')
self.ui.phone.setEnabled(False)
self.ui.provider.setEnabled(False)
self.ui.server.setEnabled(False)
self.ui.tls.setEnabled(False)
self.ui.user.setEnabled(False)
self.ui.password.setEnabled(False)
self.ui.message.setEnabled(False)
self.ui.lcd.display('0')
print('starting')
self.thread.toaddr = self.ui.phone.text() + self.providers[self.ui.provider.currentText()]
self.thread.msg = self.ui.message.toPlainText()
print('sending to:', self.thread.toaddr)
def plusOne(self):
self.ui.lcd.display(str(self.ui.lcd.intValue() + 1))
def showAbout(self):
self.about = QtGui.QWidget()
ui = Ui_About()
ui.setupUi(self.about)
ui.Version.setText(str(version))
self.connect(ui.pushButton, QtCore.SIGNAL('clicked()'),self.about.close)
self.about.show()
def addCarriers(self):
'''can get more from
http://www.emailtextmessages.com/
'''
self.providers = {
'Alltel':'@message.alltel.com',
'AT&T':'@txt.att.net',
'Boost Mobile':'@myboostmobile.com',
'Metro PCS':'@mymetropcs.com',
'Sprint':'@messaging.sprintpcs.com',
'T-Mobile':'@tmomail.net',
'US Cellular':'@email.uscc.net',
'Verizon':'@vtext.com',
'Virgin Mobile':'@vmobl.com',
'Gmail':'@gmail.com',
'Other':''
}
#.........这里部分代码省略.........