Skip to content

Commit

Permalink
Do not fail if result of tracker request looks like GIF beacon.
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Mar 31, 2015
1 parent 9ce7e99 commit a4d1eea
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions import_logs.py
Expand Up @@ -194,7 +194,7 @@ def get(self, key):
try:
return self.matched[key]
except KeyError:
raise BaseFormatException()
raise BaseFormatException("Cannot find group '%s'." % key)

def get_all(self,):
return self.matched
Expand Down Expand Up @@ -1555,14 +1555,19 @@ def _record_hits(self, hits):
on_failure=self._on_tracking_failure
)

# make sure the request succeeded and returned valid json
try:
result = json.loads(result)
except ValueError, e:
# make sure the request succeeded and returned valid json or string that looks like gif
if not result.startswith('GIF89') and not self._is_json(result):
fatal_error("Incorrect response from tracking API: '%s'\nIs the BulkTracking plugin disabled?" % result)

stats.count_lines_recorded.advance(len(hits))

def _is_json(self, result):
try:
json.loads(result)
return True
except ValueError, e:
return False

def _on_tracking_failure(self, response, data):
"""
Removes the successfully tracked hits from the request payload so
Expand Down

0 comments on commit a4d1eea

Please sign in to comment.