r95825 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95824‎ | r95825 | r95826 >
Date:00:29, 31 August 2011
Author:swalker
Status:deferred
Tags:
Comment:
initial commit - process mobile logs for phone and browser versions (mapper)
Modified paths:
  • /trunk/tools/wsor/mobile/mobile_logs.py (added) (history)

Diff [purge]

Index: trunk/tools/wsor/mobile/mobile_logs.py
@@ -0,0 +1,25 @@
 2+#!/usr/bin/env python
 3+
 4+import sys
 5+from wurfl import devices
 6+from pywurfl.algorithms import TwoStepAnalysis
 7+
 8+search_algorithm = TwoStepAnalysis(devices)
 9+
 10+# input comes from STDIN (standard input)
 11+for line in sys.stdin:
 12+ # remove leading and trailing whitespace
 13+ line = line.strip()
 14+ # split the line into words
 15+ words = line.split(" ")
 16+ # increase counters
 17+# for word in words:
 18+ # write the results to STDOUT (standard output);
 19+ # what we output here will be the input for the
 20+ # Reduce step, i.e. the input for reducer.py
 21+ #
 22+ # tab-delimited; the trivial word count is 1
 23+ user_agent = unicode(words[len(words)-1])
 24+ device = devices.select_ua(user_agent, search=search_algorithm)
 25+ print '%s %s (%s %s)\t%s' % (device.brand_name, device.model_name, device.mobile_browser, device.mobile_browser_version, 1)
 26+

Status & tagging log