try: import simplejson as json print "Using simplejson for faster json parsing" except ImportError: import json import sys import telemetryutils import jydoop histogram_specs = json.loads( jydoop.getResource("scripts/histogram_specs.json")) def map(uid, line, context): global histogram_specs payload = json.loads(line) try: i = payload['info'] channel = i.get('appUpdateChannel', "too_old") OS = i['OS'] appName = i['appName'] reason = i['reason'] osVersion = str(i['version']) #only care about major versions appVersion = i['appVersion'].split('.')[0] arch = i['arch'] buildDate = i['appBuildID'][:8] except (KeyError, IndexError, UnicodeEncodeError): msg = "error while unpacking the payload" print >> sys.stderr, msg
try: import simplejson as json print "Using simplejson for faster json parsing" except ImportError: import json import sys import telemetryutils import jydoop import __builtin__ verbose = False SPECS = "scripts/histogram_specs.json" histogram_specs = json.loads( jydoop.getResource(SPECS)) # hack, get an arbiratry histogram with 1..30000 exponential histogram dimensions SIMPLE_MEASURES_ = histogram_specs['HTTP_SUB_OPEN_TO_FIRST_RECEIVED'] def map(uid, line, context): global histogram_specs payload = json.loads(line) try: i = payload['info'] channel = i.get('appUpdateChannel', "too_old") OS = i['OS'] appName = i['appName'] reason = i['reason'] osVersion = str(i['version']) #only care about major versions
def test_basic(self): import sys sys.path.append('scripts') import jydoop self.assertIsNotNone(jydoop.getResource("scripts/jydoop.py"))
try: import simplejson as json print "Using simplejson for faster json parsing" except ImportError: import json import sys import telemetryutils import jydoop import __builtin__ verbose = False SPECS = "scripts/histogram_specs.json" histogram_specs = json.loads(jydoop.getResource(SPECS)) # hack, get an arbiratry histogram with 1..30000 exponential histogram dimensions SIMPLE_MEASURES_ = histogram_specs['HTTP_SUB_OPEN_TO_FIRST_RECEIVED'] def map(uid, line, context): global histogram_specs payload = json.loads(line) try: i = payload['info'] channel = i.get('appUpdateChannel', "too_old") OS = i['OS'] appName = i['appName'] reason = i['reason'] osVersion = str(i['version']) #only care about major versions