def _startLoop(self, imgdata):
        """
		initilizes several parameters for a new image
		and checks if it is okay to start processing image
		"""
        if self.params['parallel']:
            if self.lockParallel(imgdata.dbid):
                apDisplay.printMsg(
                    '%s locked by another parallel run in the rundir' %
                    (imgdata['filename']))
                return False
        #calc images left
        self.stats[
            'imagesleft'] = self.stats['imagecount'] - self.stats['count']

        #only if an image was processed last
        if (self.stats['lastcount'] != self.stats['count']):
            if self.params['background'] is False:
                apDisplay.printColor(
                    "\nStarting image %d ( skip:%d, remain:%d ) id:%d, file: %s"
                    % (
                        self.stats['count'],
                        self.stats['skipcount'],
                        self.stats['imagesleft'],
                        imgdata.dbid,
                        imgdata['filename'],
                    ), "green")
            elif self.stats['count'] % 80 == 0:
                sys.stderr.write("\n")
            self.stats['lastcount'] = self.stats['count']
            if apDisplay.isDebugOn():
                self._checkMemLeak()

        # skip if image doesn't exist:
        imgpath = os.path.join(imgdata['filename'] + '.dwn.mrc')
        if not os.path.isfile(imgpath):
            apDisplay.printWarning(imgpath + " not found, skipping")
            if self.params['parallel']:
                self.unlockParallel(imgdata.dbid)
            return False

        # check to see if image has already been processed
        if self._alreadyProcessed(imgdata):
            if self.params['parallel']:
                self.unlockParallel(imgdata.dbid)
            return False

        self.stats['waittime'] = 0

        if self.reprocessImage(imgdata) is True:
            if self.params['background'] is True:
                sys.stderr.write(",")
        else:
            if self.params['background'] is True:
                sys.stderr.write(".")

        return True
	def _startLoop(self, imgdata):
		"""
		initilizes several parameters for a new image
		and checks if it is okay to start processing image
		"""
		if self.params['parallel']:
			if self.lockParallel(imgdata.dbid):
				apDisplay.printMsg('%s locked by another parallel run in the rundir' % (apDisplay.shortenImageName(imgdata['filename'])))
				return False
		#calc images left
		self.stats['imagesleft'] = self.stats['imagecount'] - self.stats['count']

		#only if an image was processed last
		if(self.stats['lastcount'] != self.stats['count']):
			if self.params['background'] is False:
				apDisplay.printColor( "\nStarting image %d ( skip:%d, remain:%d ) id:%d, file: %s"
					%(self.stats['count'], self.stats['skipcount'], self.stats['imagesleft'], 
					imgdata.dbid, apDisplay.short(imgdata['filename']),),
					"green")
			elif self.stats['count'] % 80 == 0:
				sys.stderr.write("\n")
			self.stats['lastcount'] = self.stats['count']
			if apDisplay.isDebugOn():
				self._checkMemLeak()

		# skip if image doesn't exist:
		imgpath = os.path.join(imgdata['session']['image path'], imgdata['filename']+'.mrc')
		if not os.path.isfile(imgpath):
			apDisplay.printWarning(imgpath+" not found, skipping")
			if self.params['parallel']:
				self.unlockParallel(imgdata.dbid)
			return False

		# check to see if image has already been processed
		if self._alreadyProcessed(imgdata):
			if self.params['parallel']:
				self.unlockParallel(imgdata.dbid)
			return False

		self.stats['waittime'] = 0

		if self.reprocessImage(imgdata) is True:
			if self.params['background'] is True:
				sys.stderr.write(",")
			else:
				"""apDisplay.printMsg("reprocessing "+apDisplay.shortenImageName(imgdata['filename']))"""
		else:
			if self.params['background'] is True:
				sys.stderr.write(".")
			else:
				"""apDisplay.printMsg("processing "+apDisplay.shortenImageName(imgdata['filename']))"""

		return True
	def close(self):
		self.onClose()
# 		loadavg = os.getloadavg()[0]
# 		if loadavg > 2.0:
# 			apDisplay.printMsg("Load average is high "+str(round(loadavg,2)))
# 			time.sleep(loadavg**2)
		apParam.closeFunctionLog(functionname=self.functionname, 
			logfile=self.logfile, msg=(not self.quiet))
		if self.quiet is False:
			apDisplay.printMsg("Ended at "+time.strftime("%a, %d %b %Y %H:%M:%S"))
			if apDisplay.isDebugOn():
				apDisplay.printDebug("Memory increase during run: %.3f MB"%((mem.active()-self.startmem)/1024.0))
			apDisplay.printColor("Total run time:\t"+apDisplay.timeString(time.time()-self.t0),"green")
示例#4
0
 def close(self):
     self.onClose()
     # 		loadavg = os.getloadavg()[0]
     # 		if loadavg > 2.0:
     # 			apDisplay.printMsg("Load average is high "+str(round(loadavg,2)))
     # 			time.sleep(loadavg**2)
     apParam.closeFunctionLog(functionname=self.functionname,
                              logfile=self.logfile,
                              msg=(not self.quiet))
     if self.quiet is False:
         apDisplay.printMsg("Ended at " +
                            time.strftime("%a, %d %b %Y %H:%M:%S"))
         if apDisplay.isDebugOn():
             apDisplay.printDebug("Memory increase during run: %.3f MB" %
                                  ((mem.active() - self.startmem) / 1024.0))
         apDisplay.printColor(
             "Total run time:\t" +
             apDisplay.timeString(time.time() - self.t0), "green")
    def _startLoop(self, info):
        """
		appionLoop OVERRIDE
		initilizes several parameters for a new image
		and checks if it is okay to start processing image
		"""
        if info is None:
            self.stats['lastimageskipped'] = True
            self.stats['skipcount'] += 1
            return False
        name = info['filename']
        # check to see if image of the same name is already in leginon
        imgq = leginon.leginondata.AcquisitionImageData(session=self.session,
                                                        filename=name)
        results = imgq.query(readimages=False)
        if results:
            apDisplay.printWarning("File %s.mrc exists at the destination" %
                                   name)
            apDisplay.printWarning("Skip Uploading")
            self.stats['lastimageskipped'] = True
            self.stats['skipcount'] += 1
            return False
        #calc images left
        self.stats[
            'imagesleft'] = self.stats['imagecount'] - self.stats['count']
        #only if an image was processed last
        if (self.stats['lastcount'] != self.stats['count']):
            apDisplay.printColor( "\nStarting image "+str(self.stats['count'])\
             +" ( skip:"+str(self.stats['skipcount'])+", remain:"\
             +str(self.stats['imagesleft'])+" ) file: "\
             +apDisplay.short(name), "green")
            self.stats['lastcount'] = self.stats['count']
            if apDisplay.isDebugOn():
                self._checkMemLeak()
        # check to see if image has already been processed
        if self._alreadyProcessed(info):
            return False
        self.stats['waittime'] = 0
        return True
	def _startLoop(self, info):
		"""
		appionLoop OVERRIDE
		initilizes several parameters for a new image
		and checks if it is okay to start processing image
		"""
		if info is None:
			self.stats['lastimageskipped'] = True
			self.stats['skipcount'] += 1
			return False
		name = info['filename']
		# check to see if image of the same name is already in leginon
		imgq = leginon.leginondata.AcquisitionImageData(session=self.session, filename=name)
		results = imgq.query(readimages=False)
		if results:
			apDisplay.printWarning("File %s.mrc exists at the destination" % name)
			apDisplay.printWarning("Skip Uploading")
			self.stats['lastimageskipped'] = True
			self.stats['skipcount'] += 1
			return False
		#calc images left
		self.stats['imagesleft'] = self.stats['imagecount'] - self.stats['count']
		#only if an image was processed last
		if(self.stats['lastcount'] != self.stats['count']):
			apDisplay.printColor( "\nStarting image "+str(self.stats['count'])\
				+" ( skip:"+str(self.stats['skipcount'])+", remain:"\
				+str(self.stats['imagesleft'])+" ) file: "\
				+apDisplay.short(name), "green")
			self.stats['lastcount'] = self.stats['count']
			if apDisplay.isDebugOn():
				self._checkMemLeak()
		# check to see if image has already been processed
		if self._alreadyProcessed(info):
			return False
		self.stats['waittime'] = 0
		return True