def __init__(self, page_url, key=None): BackgroundTask.__init__(self, name="download video") if key is None: self.key = int(math.ceil(time.time() * 1000)) else: self.key = int(key) self.page_url = page_url
def __init__(self, url, filename, progress_callback=lambda value: None, block_size=1024 * 1024): BackgroundTask.__init__(self, name="download:" + filename) self.set_parent_progress = progress_callback self.target_url = url self.save_file = filename self.block_size = block_size
def queryDatabaseImages(self, session_name): ''' ''' username = self.ui.dbUsernameLineEdit.text() password = self.ui.dbPasswordLineEdit.text() #targetuser = self.ui.usernameLineEdit.text() #targetpass = self.ui.passwordLineEdit.text() prjhost = self.ui.projectHostnameLineEdit.text() if self.ui.projectHostnameLineEdit.text() != "" else self.ui.leginonHostnameLineEdit.text() leginonDB = self.ui.leginonHostnameLineEdit.text()+'/'+self.ui.leginonDBNameLineEdit.text() projectDB = prjhost+'/'+self.ui.projectDBNameLineEdit.text() try: session = leginondb.query_session_info(username, password, leginonDB, projectDB, session_name)#, alternteUser) except: _logger.exception("Error accessing images") messagebox.exception_message(self, "Error accessing images") self.ui.loginStackedWidget.setCurrentIndex(1) else: if len(session)==0: _logger.error("Error accessing images") return self.taskFinished.connect(self.imageLoadFinished) self.taskError.connect(self.imageLoadError) self.task = BackgroundTask.launch_mp(self, load_images_iter, session) self.ui.progressDialog.show() self.ui.progressDialog.setValue(0)
def queryDatabaseImages(self, session_name): ''' ''' username = self.ui.dbUsernameLineEdit.text() password = self.ui.dbPasswordLineEdit.text() #targetuser = self.ui.usernameLineEdit.text() #targetpass = self.ui.passwordLineEdit.text() prjhost = self.ui.projectHostnameLineEdit.text( ) if self.ui.projectHostnameLineEdit.text( ) != "" else self.ui.leginonHostnameLineEdit.text() leginonDB = self.ui.leginonHostnameLineEdit.text( ) + '/' + self.ui.leginonDBNameLineEdit.text() projectDB = prjhost + '/' + self.ui.projectDBNameLineEdit.text() try: session = leginondb.query_session_info( username, password, leginonDB, projectDB, session_name) #, alternteUser) except: _logger.exception("Error accessing images") messagebox.exception_message(self, "Error accessing images") self.ui.loginStackedWidget.setCurrentIndex(1) else: if len(session) == 0: _logger.error("Error accessing images") return self.taskFinished.connect(self.imageLoadFinished) self.taskError.connect(self.imageLoadError) self.task = BackgroundTask.launch_mp(self, load_images_iter, session) self.ui.progressDialog.show() self.ui.progressDialog.setValue(0)
def queryDatabaseForProjects(self, dummy=None): ''' ''' targetuser = self.ui.usernameLineEdit.text() targetpass = hashlib.md5(self.ui.passwordLineEdit.text()).hexdigest() username = self.ui.dbUsernameLineEdit.text() password = self.ui.dbPasswordLineEdit.text() prjhost = self.ui.projectHostnameLineEdit.text( ) if self.ui.projectHostnameLineEdit.text( ) != "" else self.ui.leginonHostnameLineEdit.text() leginonDB = self.ui.leginonHostnameLineEdit.text( ) + '/' + self.ui.leginonDBNameLineEdit.text() projectDB = prjhost + '/' + self.ui.projectDBNameLineEdit.text() limit = self.ui.entryLimitSpinBox.value() if self.login.get('username', None) == username and \ self.login.get('leginonDB', None) == leginonDB and \ self.login.get('projectDB', None) == projectDB and \ self.login.get('password', None) == password and \ self.login.get('targetpass', None) == targetpass and \ self.login.get('targetuser', None) == targetuser and \ self.login.get('limit', None) == limit: return #alternteUser = self.ui.alternateUserLineEdit.text() try: user, experiments = leginondb.query_user_info( username, password, leginonDB, projectDB, targetuser, targetpass) #, alternteUser) except leginondb.AuthenticationError: messagebox.error_message(self, "Username or password incorrect!") #self.ui.loginStackedWidget.setCurrentIndex(1) self.startTabIndex = 1 except: _logger.exception("Error accessing project") messagebox.exception_message(self, "Error accessing project") #self.ui.loginStackedWidget.setCurrentIndex(1) self.startTabIndex = 1 else: self.login['username'] = username self.login['leginonDB'] = leginonDB self.login['projectDB'] = projectDB self.login['password'] = password self.login['limit'] = limit self.login['targetuser'] = targetuser self.login['targetpass'] = targetpass self.ui.progressDialog.show() self.ui.label.setText("Welcome " + str(user.fullname)) self.taskFinished.connect(self.projectFinished) self.taskError.connect(self.projectLoadError) experiment_list = [] cnt = 0 for i in xrange(len(experiments)): if len(experiments[i].session.exposures) == 0: continue experiment_list.append(experiments[i]) cnt += 1 if cnt >= limit: break self.task = BackgroundTask.launch_mp(self, load_projects_iter, experiment_list)
def on_runPushButton_clicked(self, index=None): ''' ''' if index is None: extra = self.controlOptionValueDict() else: #model = self.ui.autopickHistoryTableView.model() extra = dict([v for v in zip(self.options, index.data(QtCore.Qt.UserRole)[2:])]) #disk_mult, mask_mult, overlap_mult = index.data(QtCore.Qt.UserRole)[2:] # Get list of micrographs files = self.parent_control.currentFileList() # Update parameters if len(files) == 0: return self.micrograph_files = files self.setEnabled(False) ''' self.ui.diskDoubleSpinBox.setEnabled(False) self.ui.maskDoubleSpinBox.setEnabled(False) self.ui.overlapDoubleSpinBox.setEnabled(False) self.ui.runPushButton.setEnabled(False) ''' bin_factor = float(self.parent_control.micrographDecimationFactor()) output, base = os.path.split(self.output_base) output+="-%.2f-%.2f-%.2f"%(extra['disk_mult'], extra['mask_mult'], extra['overlap_mult']) output = output.replace(".", "_") output = os.path.join(output, base) self.autopick_program.update(dict(input_files=self.autopick_program.values.input_files.__class__(files), #mask_mult=mask_mult, #disk_mult=disk_mult, #overlap_mult=overlap_mult, bin_factor=bin_factor, disable_bin=True, selection_file="", output=output, **extra)) self.taskFinished.connect(self.programFinished) self.taskError.connect(self.programError) def _run_worker(prog): yield 1 yield 0 _logger.info("Running "+str(prog.name())) prog.check_options_validity() prog.launch() yield 1 self.output = output self.task = BackgroundTask.launch_mp(self, _run_worker, self.autopick_program)
def queryDatabaseForProjects(self, dummy=None): ''' ''' targetuser = self.ui.usernameLineEdit.text() targetpass = hashlib.md5(self.ui.passwordLineEdit.text()).hexdigest() username = self.ui.dbUsernameLineEdit.text() password = self.ui.dbPasswordLineEdit.text() prjhost = self.ui.projectHostnameLineEdit.text() if self.ui.projectHostnameLineEdit.text() != "" else self.ui.leginonHostnameLineEdit.text() leginonDB = self.ui.leginonHostnameLineEdit.text()+'/'+self.ui.leginonDBNameLineEdit.text() projectDB = prjhost+'/'+self.ui.projectDBNameLineEdit.text() limit = self.ui.entryLimitSpinBox.value() if self.login.get('username', None) == username and \ self.login.get('leginonDB', None) == leginonDB and \ self.login.get('projectDB', None) == projectDB and \ self.login.get('password', None) == password and \ self.login.get('targetpass', None) == targetpass and \ self.login.get('targetuser', None) == targetuser and \ self.login.get('limit', None) == limit: return #alternteUser = self.ui.alternateUserLineEdit.text() try: user, experiments = leginondb.query_user_info(username, password, leginonDB, projectDB, targetuser, targetpass)#, alternteUser) except leginondb.AuthenticationError: messagebox.error_message(self, "Username or password incorrect!") #self.ui.loginStackedWidget.setCurrentIndex(1) self.startTabIndex=1 except: _logger.exception("Error accessing project") messagebox.exception_message(self, "Error accessing project") #self.ui.loginStackedWidget.setCurrentIndex(1) self.startTabIndex=1 else: self.login['username']=username self.login['leginonDB']=leginonDB self.login['projectDB']=projectDB self.login['password']=password self.login['limit']=limit self.login['targetuser']=targetuser self.login['targetpass']=targetpass self.ui.progressDialog.show() self.ui.label.setText("Welcome "+str(user.fullname)) self.taskFinished.connect(self.projectFinished) self.taskError.connect(self.projectLoadError) experiment_list = [] cnt = 0 for i in xrange(len(experiments)): if len(experiments[i].session.exposures) == 0: continue experiment_list.append(experiments[i]) cnt += 1 if cnt >= limit: break self.task = BackgroundTask.launch_mp(self, load_projects_iter, experiment_list)
def on_emdbDownloadPushButton_clicked(self): '''Called when the user clicks the download button ''' num = self.ui.emdbNumberLineEdit.text() if num == "": QtGui.QMessageBox.warning(self, "Warning", "Empty Accession Number") return url = "ftp://ftp.ebi.ac.uk/pub/databases/emdb/structures/EMD-%s/map/emd_%s.map.gz" % ( num, num) self.setEnabled(False) if not os.path.exists('data/rawmap/'): try: os.makedirs('data/rawmap/') except: pass self.task = BackgroundTask.launch(self, download_gunzip_task, url, 'data/rawmap/')
def on_runPushButton_clicked(self, index=None): ''' ''' if index is None: extra = self.controlOptionValueDict() else: #model = self.ui.autopickHistoryTableView.model() extra = dict([ v for v in zip(self.options, index.data(QtCore.Qt.UserRole)[2:]) ]) #disk_mult, mask_mult, overlap_mult = index.data(QtCore.Qt.UserRole)[2:] # Get list of micrographs files = self.parent_control.currentFileList() # Update parameters if len(files) == 0: return self.micrograph_files = files self.setEnabled(False) ''' self.ui.diskDoubleSpinBox.setEnabled(False) self.ui.maskDoubleSpinBox.setEnabled(False) self.ui.overlapDoubleSpinBox.setEnabled(False) self.ui.runPushButton.setEnabled(False) ''' bin_factor = float(self.parent_control.micrographDecimationFactor()) output, base = os.path.split(self.output_base) output += "-%.2f-%.2f-%.2f" % (extra['disk_mult'], extra['mask_mult'], extra['overlap_mult']) output = output.replace(".", "_") output = os.path.join(output, base) self.autopick_program.update( dict( input_files=self.autopick_program.values.input_files.__class__( files), #mask_mult=mask_mult, #disk_mult=disk_mult, #overlap_mult=overlap_mult, bin_factor=bin_factor, disable_bin=True, selection_file="", output=output, **extra)) self.taskFinished.connect(self.programFinished) self.taskError.connect(self.programError) def _run_worker(prog): yield 1 yield 0 _logger.info("Running " + str(prog.name())) prog.check_options_validity() prog.launch() yield 1 self.output = output self.task = BackgroundTask.launch_mp(self, _run_worker, self.autopick_program)