# -*- coding: utf-8 -*-
#!/usr/bin/python

import re

#LOGFILE = "*.log"
LOGFILE = "/home/pi/rpi_log.log"
PATTERN = re.compile("\[INFO\] (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) > (.+)\n", re.DOTALL)
RPIINFO = ['HOSTNAME', 'IP', 'HDD', 'FREE MEM', 'CPU(\(.+\))', 'MEM(\(.+\))']

CNT = 0

f = open(LOGFILE,"r")
tmp_str = ''
rpi_info_list = []

lines = f.readlines()
for line in lines:
    if PATTERN.search(line):
        CNT+=1
        rpi_info = re.split(PATTERN, line)
	#if len(tmp_str) > 0: print "++++++++++\n" + tmp_str + "\n++++++++++"
	if len(tmp_str) > 0: rpi_info_list.append(tmp_str)
	tmp_str = ''
    else:
        rpi_info = [info for info in rpi_info if len(info) > 0]
	tmp_str += line
print CNT
print rpi_info_list

f.close()

@@ -81,16 +81,11 @@
  = %22
-/home/pi
+out
 /rpi
@@ -690,16 +690,28 @@
 += line%0A
+f.close()%0A%0A#
 print CN
@@ -712,16 +712,17 @@
 int CNT%0A
+#
 print rp
@@ -733,19 +733,208 @@
 fo_list%0A
-%0Af.close()
+print %22Content-type:text/html%5Cr%5Cn%5Cr%5Cn%22%0Aprint %22%3Chtml%3E%22%0Aprint %22%3Chead%3E%22%0Aprint %22%3Ctitle%3EtinyosGW%3C/title%3E%22%0Aprint %22%3C/head%3E%22%0Aprint %22%3Cbody%3E%22%0Afor i in rpi_info_list:%0A    print i%0Aprint %22%3C/body%3E%22%0Aprint %22%3C/html%3E%22
 %0A

update ParserLogFile.py