@@ -129,21 +129,24 @@ def analyser(access_file_path):
129
129
timestamp1 = ""
130
130
for line in reverse_readline (access_file_path ):
131
131
if line :
132
- ip_addr , timestamp2 , http = re .match (regex1 , line ).groups ()
133
- if not timestamp1 :
134
- timestamp1 = timestamp2
135
- if date_compare (timestamp1 , timestamp2 , hours = 1 ):
136
- searches = '{"' + timestamp1 + '": ' + str (search_count ) + '}'
137
- search_counts .append (searches )
138
- search_count = 0
139
- timestamp1 = timestamp2
140
- if "/search/?q=" in http :
141
- search_count = search_count + 1
142
- #query = regex2.search(http)
143
- #if query:
144
- #query = search_term_unescape(query.group(1))
145
- #if not "%" in query:
146
- #print query
132
+ try :
133
+ ip_addr , timestamp2 , http = re .match (regex1 , line ).groups ()
134
+ if not timestamp1 :
135
+ timestamp1 = timestamp2
136
+ if date_compare (timestamp1 , timestamp2 , hours = 1 ):
137
+ searches = '{"' + timestamp1 + '": ' + str (search_count ) + '}'
138
+ search_counts .append (searches )
139
+ search_count = 0
140
+ timestamp1 = timestamp2
141
+ if "/search/?q=" in http :
142
+ search_count = search_count + 1
143
+ #query = regex2.search(http)
144
+ #if query:
145
+ #query = search_term_unescape(query.group(1))
146
+ #if not "%" in query:
147
+ #print query
148
+ except Exception as e :
149
+ print e
147
150
json_data = '{"searches": [' + "," .join (search_counts ) + ']}'
148
151
json_pretty = valid_pretty_json (json_data )
149
152
if json_pretty :
0 commit comments