def setup_authentication(self): self._waitDialog = QtGui.QMessageBox( QtGui.QMessageBox.Information, "Hold up!", ('I\'m opening a link to goodreads for you. ' 'Once the goodreads page loads click "Yes" below to continue.' 'If this is your first time, you will have to give "Checkout" ' 'permission to access your goodreads account.'), QtGui.QMessageBox.Ok, parent=self) self.startWaitForAuth.connect(self._waitDialog.show) self.startWaitForAuth.connect(self.progress.hide) self._waitSemaphore = QtCore.QSemaphore() self._waitDialog.finished.connect(self.progress.show) self._waitDialog.finished.connect( lambda _: self._waitSemaphore.release()) self.ui.sync_button.pressed.connect( lambda: self.ui.sync_button.setEnabled(False))
def __init__(self): self.mail_sem = QtCore.QSemaphore(1) try: self.email = web.persistentData.getDict()['Email']['Address'] self.pwd = web.persistentData.getDict()['Email']['Password'] self.host = web.persistentData.getDict()['Email']['Host'] if (self.email): print("Initializing MMail...") self.smtpObj = smtplib.SMTP(self.host, timeout=3) # Say hello to the email server. self.smtpObj.ehlo() # Initialize TLS security. self.smtpObj.starttls() self.smtpObj.login(self.email, self.pwd) self.smtpObj.quit() except: MPopUp.PopUp("Notifier failed to login to email.\n\n" + traceback.format_exc(1)).exec_() traceback.print_exc()
## $QT_END_LICENSE$ ## ############################################################################# import sys import random from PyQt4 import QtCore DataSize = 100000 BufferSize = 8192 buffer = list(range(BufferSize)) freeBytes = QtCore.QSemaphore(BufferSize) usedBytes = QtCore.QSemaphore() class Producer(QtCore.QThread): def run(self): for i in range(DataSize): freeBytes.acquire() buffer[i % BufferSize] = "ACGT"[random.randint(0, 3)] usedBytes.release() class Consumer(QtCore.QThread): def run(self): for i in range(DataSize): usedBytes.acquire()