Skip to content

Instantly share code, notes, and snippets.

@georgf
Created August 22, 2016 10:52
Show Gist options
  • Save georgf/3b305ce613689c9ff30c8b6cf31b03e6 to your computer and use it in GitHub Desktop.
Save georgf/3b305ce613689c9ff30c8b6cf31b03e6 to your computer and use it in GitHub Desktop.
activePlugins is not an array
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
# In[2]:
from moztelemetry import get_pings
get_ipython().magic(u'pylab inline')
# In[3]:
pings = get_pings(sc, app="Firefox", channel="nightly", submission_date="20160820")
# In[7]:
class NoPlugins:
dummy = 1
# In[8]:
def get_active_plugins(x):
try:
return x["environment"]["addons"]["activePlugins"]
except:
return NoPlugins()
# In[9]:
print pings.map(get_active_plugins).filter(lambda x: not isinstance(x, list)).first()
# In[14]:
def name(x):
s = str(type(x))
if s != "<type 'instance'>":
return s
else:
return x.__class__.__name__
# In[15]:
print pings.map(get_active_plugins) .map(lambda x: (name(x), 1)) .countByKey()
# In[ ]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment