Beispiel #1
0
 def __init__(self,
              url='https://boiling-heat-5294.firebaseio.com/',
              secret_key='5zF8T37NlZB1HBHkb9T1zAZ6c2cPbXiXlzP5yJ8P',
              email='*****@*****.**'):
     self.authentication = firebase.FirebaseAuthentication(
         secret_key, email, True, True)
     self.fb = firebase.FirebaseApplication(url, self.authentication)
     self.url = url
Beispiel #2
0
    def handle(self, room_name, *args, **kwargs):
        self.firebase = firebase.FirebaseApplication(settings.FIREBASE_URL)
        auth = firebase.FirebaseAuthentication(settings.FIREBASE_TOKEN,
                                               '*****@*****.**')
        self.firebase.authentication = auth
        self.rdio = Rdio(RDIO_OAUTH2_KEY, RDIO_OAUTH2_SECRET, {})
        self.party_name = room_name
        self.party_data = self.get_party_data()
        self.currently_playing = None
        self.last_saw_users = datetime.now()

        self.currently_playing = None
        if 'player' in self.party_data and 'playingTrack' in self.party_data[
                'player']:
            track_key = self.party_data['player']['playingTrack']['trackKey']
            self.current_track_duration = self.rdio.get(
                keys=track_key)[track_key]['duration']
            self.current_start_time = datetime.now() - timedelta(
                seconds=self.party_data['player']['position'])
        else:
            self.current_track_duration = None
            self.current_start_time = None

        self.run()
Beispiel #3
0
def accessdbFirebaseWithAuth(dsn, SECRET_KEY, email, admin=False):
    '''
    ------------FUNZIONAMENTO----------------
    Funzione tramite la quale si apre la connessione col Database

    Parametri d'ingresso:  dsn -> url del database
                           SECRET_KEY -> Chiave segreta del database Firebase
                           email -> email fittizia da attribuire ad ogni centralina  (utile alla scrittura dei log)
                           admin -> possibilità di accedere al database in modalità admin  (utile all'utilizzo della funzione quando il file viene richiamato come script per effettuare test)
    Parametro di ritorno:  db -> variabile che contiene il collegamento al database tramite cui si effettuano le operazioni su di esso

    '''

    from firebase import firebase
    import datetime

    auth = firebase.FirebaseAuthentication(
        SECRET_KEY, email, admin,
        admin)  # funzione che serve a creare l'autenticazione
    db = firebase.FirebaseApplication(
        dsn, auth
    )  # accedo al database con l'url "dsn" e l'autorizzazione e istanzio l'oggetto db

    return db  # ritorna l'oggetto tramite il quale accediamo al DataBase
Beispiel #4
0
import requests 
import numpy as np
import firebase as fb
import matplotlib.pyplot as plt

(superSecret, url) = ('IMXOxXD3FjOOUoMGJlkAK5pAtn89mGIWAEnaKJhP', 'https://1678-strat-dev-2016.firebaseio.com/') 
basicURL = "http://www.thebluealliance.com/api/v2/"
headerKey = "X-TBA-App-Id"		
headerValue = "blm:OPRs:004"

auth = fb.FirebaseAuthentication(superSecret, "*****@*****.**", True, True)

def zscore(lis, x):
	return (x - np.mean(lis)) / np.std(lis)

def oprFromZScore(lis, z):
	return (z * np.std(lis)) + np.mean(lis)

firebase = fb.FirebaseApplication(url, auth)
teams = map(lambda k: k.encode('utf-8'), firebase.get('/Teams', None).keys())
fpas = map(lambda k: np.log(firebase.get('/Teams/' + k + '/calculatedData', 'firstPickAbility')), teams)
o = requests.get(basicURL + "event/" + "2016casj" + "/stats" ,headers={headerKey:headerValue}).json()["oprs"]
oprs = map(lambda k: o[k], teams)
normalOPRs = map(lambda e: np.log10(e), oprs)
zscores = map(lambda a: zscore(fpas, a), fpas)
print zscores
zScoreToLogOPR = map(lambda a: oprFromZScore(normalOPRs, a), zscores)
fpaToOPR = map(lambda a: 10 ** a, zScoreToLogOPR)
print len(fpaToOPR), len(oprs)
print zip(oprs, fpaToOPR)
plt.hist(oprs, bins=10)
Beispiel #5
0
 def __init__(self, url, api_key, collection, email):
     authentication = firebase.FirebaseAuthentication(
         api_key, email, True, True)
     self.__firebase = firebase.FirebaseApplication(url, authentication)
     self.__collection = collection