def inDequeued(self,targetlist):
		dequeuedquery = leginondata.DequeuedImageTargetListData(list=targetlist)
		dequeuedlists = self.research(datainstance=dequeuedquery)
		if len(dequeuedlists) > 0:
			return True
		else:
			return False
Beispiel #2
0
 def getListsInQueue(self, queuedata):
     '''
                     get a list of all active (not done) target lists in the queue
                     '''
     if queuedata is None:
         return []
     # get targetlists relating to this queue
     tarlistquery = leginondata.ImageTargetListData(queue=queuedata)
     targetlists = self.research(datainstance=tarlistquery)
     # need FIFO queue (query returns LIFO)
     targetlists.reverse()
     dequeuedquery = leginondata.DequeuedImageTargetListData(
         queue=queuedata)
     dequeuedlists = self.research(datainstance=dequeuedquery)
     keys = [targetlist.dbid for targetlist in targetlists]
     active = ordereddict.OrderedDict(zip(keys, targetlists))
     keys = [
         dequeuedlist.special_getitem('list', dereference=False).dbid
         for dequeuedlist in dequeuedlists
     ]
     done = ordereddict.OrderedDict(zip(keys, keys))
     for id in done:
         try:
             del active[id]
         except:
             self.logger.warning('done %s list not in target list' % (id, ))
     return active.values()
    def importDeQueue(self):
        source_session = self.getSourceSession()
        # ImageTargetLists that have no targets on will also be imported in this function
        print "Importing dequeuing...."
        sinedon.setConfig('leginondata', db=self.source_dbname)
        q = leginondata.DequeuedImageTargetListData(session=source_session)
        r = q.query()
        r.reverse()

        sinedon.setConfig('leginondata', db=self.destination_dbname)
        for queue in r:
            queue.insert(archive=True)
Beispiel #4
0
    def handleQueuePublish(self, pubevent):
        '''
                filter just passes input queuedata to the output, but the target lists
                in that queue are filtered.  The old target list is dequeued.
                '''
        queuedata = pubevent['data']
        ## this is only active (not dequeued) target lists
        oldtargetlists = self.getListsInQueue(queuedata)

        for oldtargetlist in oldtargetlists:
            newtargetlist = self.__filterTargetList(
                oldtargetlist, self.settings['target type'])
            if newtargetlist is not oldtargetlist:
                # newtargetlist has already been put in queue, now dequeue old one
                donetargetlist = leginondata.DequeuedImageTargetListData(
                    list=oldtargetlist, queue=queuedata)
                self.publish(donetargetlist, database=True)
        self.publish(queuedata, pubevent=True)
        self.setStatus('idle')
Beispiel #5
0
    def queueProcessor(self):
        '''
                this is run in a thread to watch for and handle queue updates
                '''
        while 1:
            # wait for a queue update
            self.setStatus('idle')

            ## hard coded idletime before giving up
            if self.queueidleactive:
                idletime = 20
            else:
                idletime = None
            self.queueupdate.wait(idletime)
            if not self.queueupdate.isSet():
                self.queueIdleFinish()
                # close valves, stop doing everything or quit

            self.setStatus('processing')
            self.queueupdate.clear()
            self.logger.info('received queue update')

            active = self.getListsInQueue(self.getQueue())

            # process all target lists in the queue
            for targetlist in active:
                state = self.player.wait()
                if state == 'stopqueue' or self.inDequeued(targetlist):
                    self.logger.info('Queue aborted, skipping target list')
                else:
                    self.revertTargetListZ(targetlist)
                    self.processTargetList(targetlist)
                    state = self.player.wait()
                    if state != 'stopqueue':
                        self.player.play()
                donetargetlist = leginondata.DequeuedImageTargetListData(
                    session=self.session,
                    list=targetlist,
                    queue=self.targetlistqueue)
                self.publish(donetargetlist, database=True)
            self.player.play()
            if self.settings['reset tilt']:
                self.resetTiltStage()