Hi everybody.
Today I tried to run a python script memorized on my sd in the arduino yun.
This script make a simple query to google analytics in order to retrieve some data, but it seems that at a certain point it gets stuck and i don't know why; form the terminal it works perfectly. Also I've no problem with the ssl because i've installed the python-openssl package with opkg.
here is the script
import argparse
import httplib2
import os
import sys
from apiclient import discovery
from oauth2client import file
from oauth2client import client
from oauth2client import tools
# Parser for command-line arguments.
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
parents=[tools.argparser])
CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json')
FLOW = client.flow_from_clientsecrets(CLIENT_SECRETS,
scope=[
'https://www.googleapis.com/auth/analytics',
'https://www.googleapis.com/auth/analytics.edit',
'https://www.googleapis.com/auth/analytics.manage.users',
'https://www.googleapis.com/auth/analytics.readonly',
],
message=tools.message_if_missing(CLIENT_SECRETS))
print "COOKIE"
storage = file.Storage('sample.dat')
credentials = storage.get()
print "CREATE HTTP"
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with our good Credentials.
http = httplib2.Http()
print "AUTORIZE HTTP"
http = credentials.authorize(http) <---------------------------HERE IT GETS STUCK
print "INIT SERVICE"
# Construct the service object for the interacting with the Google Analytics API.
service = discovery.build('analytics', 'v3', http=http)
#YY-MM-DD
#res= service.data().ga().get(ids="ga:xxxxxxx", start_date='2014-01-25', end_date='2100-01-01', metrics='ga:newVisits,ga:percentNewVisits,ga:visitors, ga:visits').execute()
print "REQUEST"
active = service.data().realtime().get(
ids='ga:xxxxxx',
metrics='ga:activeVisitors').execute()
try:
active_users = active['rows'][0][0]
print active_users
except:
print "NO USERS"
sorry for my english