Exemple #1
0
	def redraw_graphs(self):
		def ts(x):
			return x.total_seconds()
		if self.list_of_files !=None:
			# get data from the list of	 files given
			# we'll open the files one by one, fetch the line
			# get the timestamp from the line contaning ===Current Time===
			# and then looking for any of the selected metrics
			# put the results in the the pandas dataframe
			#and then call the redraw events
			self.metric_column=self.metric_column_d[self.metric]
			rows_list=[]
			self.first_time=False
			priortime=None
			nfiles=len(self.list_of_files)
			pbar=ProgressBar(desc="Loading Files")
			n=.5/nfiles
			for fname in self.list_of_files:
				if fname[-3:]=="bz2":
					datfile=bz2.BZ2File(fname)
				else:
					datfile=open(fname,'r')
				
				lines=datfile.readlines()
				cellname=fname[fname.rindex('_',)+1:fname.index('.',fname.rindex('_',))]
				pbar.setDescription("opening:"+os.path.basename(fname))
				pbar.setValue(100*n)
				n+=.5/nfiles
				QtWidgets.QApplication.processEvents()
#				print ("cellname=",cellname)
				for s1 in lines:
					s=s1.rstrip().decode("utf-8")
					#print(s)
					if re.search("PM|AM$",s)!=None:
						# get the date after that
						timeint=dt.datetime.strptime(s,"%m/%d/%Y %I:%M:%S %p")
						timest=timeint.strftime("%Y-%m-%d_%H:%M:%S")
						if priortime is None:
							timedelta=0
						else:
							timedelta=(timeint-priortime).total_seconds()
						priortime=timeint
					else:
						if self.devices=='.':
							mre=re.search("^nvme|^sd[a-l] .*$",s)
						else:
							mre=re.search("^"+self.devices+" .*$",s)
#							mre=re.search("^nvme0n1 .*$",s)
						if mre!=None:
							#disk=s[0:mre.span()[0]].rstrip()
							#print(s)
							l2f=s.split()
							#print(timeint,float(l2f[3]))
							data_list={'Cell':cellname, 'Type':('Flash' if l2f[0][0]=='n' else 'Disk'), 'Disk':l2f[0],'Metric':float(l2f[self.metric_column]),'Timestamp':timeint}
							rows_list.append(data_list)
				datfile.close()
				pbar.setValue(100*n)
				n+=.5/nfiles
				QtWidgets.QApplication.processEvents()
			self.current_metrics=pd.DataFrame(rows_list)#, ignore_index=True)
			#print(self.current_metrics.head())
			pbar.close()
		for i in self.metric_graph:
			self.metric_graph[i].remove_graph()
		for i in self.current_metrics.Cell.unique():
			self.metric_graph[i]=CellGraphrtPage(self,i,False)
			self.metric_graph[i+'A']=CellGraphrtPage(self,i,True)
			self.metric_graph[i].redraw_events()
			self.metric_graph[i+'A'].redraw_events()