All pastes #516568 Raw Edit

Someone

public text v1 · immutable
#516568 ·published 2007-05-28 19:33 UTC
rendered paste body
	def viewLogs(self, widget):
		#read in the logfile and count the lines using wc -l
		file1out, file1in = popen2.popen2("wc -l /var/log/moblock.log")
		numberoflines = file1out.read()
		#now read it again - count the lines and save as another file
		file2out, file2in = popen2.popen2("wc -l /var/log/moblock.log")
		numberoflines2 = file2out.read()
		#whilst the number of lines stays the same
		while numberoflines == numberoflines2:
			#keep counting
			file1out, file1in = popen2.popen2("wc -l /var/log/moblock.log")
			numberoflines = file1out.read()
			#and counting again
			file2out, file2in = popen2.popen2("wc -l /var/log/moblock.log")	
			numberoflines2 = file2out.read()
		#if the line count returned is different then
		else:
			#read the last line of the logfile
			fileout, filein = popen2.popen2("tail --lines=1 /var/log/moblock.log")
			lastline = fileout.read()
			#and print it to the screen
			self.logwindow.insert_at_cursor(lastline)
			#print lastline
			#then do it all again
			viewLogs(self)