def _waitForMoreSeries(self,timeout_min=180):
		"""
		pauses wait_time mins and then checks for more series to process
		"""
		### SKIP MESSAGE
		if(self.stats['skipcount'] > 0):
			apDisplay.printWarning("Series already processed and were therefore skipped (total "+str(self.stats['skipcount'])+" skipped).")
			apDisplay.printMsg("to process them again, remove \'continue\' option and run "+self.functionname+" again.")
			self.stats['skipcount'] = 0

		### SHOULD IT WAIT?
		if self.params['wait'] is False:
			return False
		if self.params["mrcnames"] is not None:
			return False
		if self.params["limit"] is not None:
			return False

		### CHECK FOR IMAGES, IF MORE THAN 10 JUST GO AHEAD
		apDisplay.printMsg("Finished all series, checking for more\n")
		self._getAllSeries()
		### reset counts
		self.stats['seriescount'] = len(self.seriestree)
		self.stats['seriesleft'] = self.stats['seriescount'] - self.stats['count']
		if self.stats['seriesleft'] > 0:
			return True

		### WAIT
		timeout_sec = timeout_min * 60
		# self.stats['waittime'] is in minutes
		if(self.stats['waittime'] > timeout_min):
			timeout_hr = timeout_min / 60.0
			apDisplay.printWarning("waited longer than %.1f hours for new series with no results, so I am quitting" % timeout_hr)
			return False
		apParam.closeFunctionLog(functionname=self.functionname, logfile=self.logfile, msg=False, stats=self.stats)
		twait0 = time.time()
		# Wait at least 30 sec and at most 5 % of timeout before checking for new tilt series
		dot_wait = 30
		timecheck_sec = max(timeout_sec/20,dot_wait*2)
		wait_step = max(1,int(round(timecheck_sec * 1.0 / dot_wait)))
		sys.stderr.write("\nAll Series processed. Waiting %.1f minutes for new Series (waited %.1f min so far" % (timecheck_sec / 60.0, self.stats['waittime']))
		for i in range(wait_step):
			time.sleep(dot_wait)
			#print a dot every 30 seconds
			sys.stderr.write(".")
		self.stats['waittime'] += round((time.time()-twait0)/60.0,2)
		sys.stderr.write("\n")

		### GET NEW IMAGES
		self._getAllSeries()
		### reset counts
		self.stats['seriescount'] = len(self.seriestree)
		self.stats['seriesleft'] = self.stats['seriescount'] - self.stats['count']
		return True
예제 #2
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"))
                 apDisplay.printMsg("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")
예제 #3
0
	def _waitForMoreImages(self):
		"""
		pauses 10 mins and then checks for more images to process
		"""
		### SKIP MESSAGE
		if(self.stats['skipcount'] > 0):
			apDisplay.printWarning("Images already processed and were therefore skipped (total "+str(self.stats['skipcount'])+" skipped).")
			apDisplay.printMsg("to process them again, remove \'continue\' option and run "+self.functionname+" again.")
			self.stats['skipcount'] = 0

		### SHOULD IT WAIT?
		if self.params['wait'] is False:
			return False
		if self.params["mrcnames"] is not None:
			return False
		if self.params["limit"] is not None:
			return False

		### CHECK FOR IMAGES, IF MORE THAN self.process_batch_count (default 10) JUST GO AHEAD
		apDisplay.printMsg("Finished all images, checking for more\n")
		self._getAllImages()
		### reset counts
		self.stats['imagecount'] = len(self.imgtree)
		self.stats['imagesleft'] = self.stats['imagecount'] - self.stats['count']
		### Not sure this really works since imagesleft appears to be negative value AC
		if  self.stats['imagesleft'] > self.process_batch_count:
			return True

		### WAIT
		if(self.stats['waittime'] > 180):
			apDisplay.printWarning("waited longer than three hours for new images with no results, so I am quitting")
			return False
		apParam.closeFunctionLog(functionname=self.functionname, logfile=self.logfile, msg=False, stats=self.stats)
		sys.stderr.write("\nAll images processed. Waiting %d minutes for new images (waited %.2f min so far)." % (int(self.sleep_minutes),float(self.stats['waittime'])))
		twait0 = time.time()
		repeats = int(self.sleep_minutes * 60 / 20)
		for i in range(repeats):
			apDisplay.printMsg("Sleeping 20 seconds")
			time.sleep(20)
			#print a dot every 30 seconds
			sys.stderr.write(".")
		self.stats['waittime'] += round((time.time()-twait0)/60.0,2)
		sys.stderr.write("\n")

		### GET NEW IMAGES
		self._getAllImages()
		### reset counts
		self.stats['imagecount'] = len(self.imgtree)
		self.stats['imagesleft'] = self.stats['imagecount'] - self.stats['count']
		return True
예제 #4
0
    def _waitForMoreImages(self):
        """
                pauses 10 mins and then checks for more images to process
                """
        ### SKIP MESSAGE
        if (self.stats['skipcount'] > 0):
            apDisplay.printWarning(
                "Images already processed and were therefore skipped (total " +
                str(self.stats['skipcount']) + " skipped).")
            apDisplay.printMsg(
                "to process them again, remove \'continue\' option and run " +
                self.functionname + " again.")
            self.stats['skipcount'] = 0

        ### SHOULD IT WAIT?
        if self.params['wait'] is False:
            return False
        if self.params["mrcnames"] is not None:
            return False
        if self.params["limit"] is not None:
            return False

        ### CHECK FOR IMAGES, IF MORE THAN self.process_batch_count (default 10) JUST GO AHEAD
        apDisplay.printMsg("Finished all images, checking for more\n")
        self._getAllImages()
        ### reset counts
        self.stats['imagecount'] = len(self.imgtree)
        self.stats[
            'imagesleft'] = self.stats['imagecount'] - self.stats['count']
        ### Not sure this really works since imagesleft appears to be negative value AC
        if self.stats['imagesleft'] > self.process_batch_count:
            return True

        ### WAIT
        if (self.stats['waittime'] > 180):
            apDisplay.printWarning(
                "waited longer than three hours for new images with no results, so I am quitting"
            )
            return False
        apParam.closeFunctionLog(functionname=self.functionname,
                                 logfile=self.logfile,
                                 msg=False,
                                 stats=self.stats)
        sys.stderr.write(
            "\nAll images processed. Waiting %d minutes for new images (waited %.2f min so far)."
            % (int(self.sleep_minutes), float(self.stats['waittime'])))
        twait0 = time.time()
        repeats = int(self.sleep_minutes * 60 / 20)
        for i in range(repeats):
            time.sleep(20)
            #print a dot every 30 seconds
            sys.stderr.write(".")
        self.stats['waittime'] += round((time.time() - twait0) / 60.0, 2)
        sys.stderr.write("\n")

        ### GET NEW IMAGES
        self._getAllImages()
        ### reset counts
        self.stats['imagecount'] = len(self.imgtree)
        self.stats[
            'imagesleft'] = self.stats['imagecount'] - self.stats['count']
        return True