Пример #1
0
    def schedule(self, file_path):
        track = Firebase(FIREBASE_URL + "tracks/")

        track_data = {}
        track_data["url"] = file_path.replace(os.path.join(os.getcwd(), "jukebox"), "")
        track_data["offset"] = self.play_time(file_path)

        track.post(track_data)
Пример #2
0
def process(file):
    f = open(file, 'rU')
    reader = csv.DictReader(f, fieldnames=fieldnames)
    i = 0
    rows = list(reader)
    l = len(rows)
    for row in rows:
        id = row['CAMIS']
        inspect_loc = "https://eat-here-or-there.firebaseio.com/nyc/restaurants/{0}/inspections".format(id)

        fire_inspection = Firebase(inspect_loc, token)

        del row['CAMIS']
        try:
            fire_inspection.post(row)
        except (UnicodeDecodeError, requests.exceptions.ConnectionError) as e:
            print row
        i += 1
        printProgress(i, l, prefix = 'Progress:', suffix = 'Complete', barLength = 50)
Пример #3
0
def smsReciever():
    """
        Handle the SMS when is coming and save it in Firebase
    """
    r = twiml.Response()

    # Limit the request to my phone number
    if not request.form.has_key('From') \
    and request.form['Body'] != current_app.config['MY_PHONE_NUMBER']:
        r.message('Not allowed to send a message !')
        return Response(response=str(r), status=401, mimetype="text/plain")

    # initiate the connexion to Firebase
    token = create_token(FIREBASE_SECRET, AUTH_PAYLOAD)

    firebase_project = FIREBASE_PROJECT + '/' + ROOT_OBJECT + '.json'
    firebase = Firebase(firebase_project, token)

    # Get the message
    if request.form.has_key('Body'):
        body = request.form['Body']

        # Get the next firebase Id and parse the content to firebase
        next_id = get_next_id(firebase)

        content = get_content(body, next_id)

        # saved the content in firebase
        if content is not None:
            try:
                firebase.post(content)
                r.message("Record saved ! id = {}".format(next_id))
            except Exception:
                r.message("Can't save the record in firebase")
        else:
            r.message("Bad body format")
    else:
        r.message("Can't get the body message")

    return str(r)
#     # collect the files
#     if f.rsplit('.', 1)[1].lower() in ['mp3', 'aif', 'aiff', 'aifc', 'wav']:
#         # file_list.append(os.path.join(directory,f))
#         data = {}
#         data['file_name'] = f
#         data['bpm'] = 140
#         data['RNG'] = 1
#         data['file_type'] = "instrumental"
#         data['start_time'] = 30
#         data['volume'] = 1.0
#         data['song_name'] = f[:-4]
#         # Need to add in ID by hand
#         song_db.post(data)


ff = os.listdir(VOCAL_DIR)
for f in ff:
    # collect the files
    if f.rsplit('.', 1)[1].lower() in ['mp3', 'aif', 'aiff', 'aifc', 'wav']:
        # file_list.append(os.path.join(directory,f))
        data = {}
        data['file_name'] = f
        data['bpm'] = 140
        data['RNG'] = 1
        data['file_type'] = "vocal"
        data['start_time'] = 30
        data['volume'] = 1.0
        data['song_name'] = f[:-4]
        # Need to add in ID by hand
        song_db.post(data)
Пример #5
0
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 06 11:42:45 2016

@author: Claudio
"""
from firebase import Firebase
f = Firebase('https://wesee-dw.firebaseio.com/teste')
f.post({'text': 'Hello'})
Пример #6
0
data = []

ff = os.listdir(INSTRUMENTAL_DIR)
for f in ff:
    # collect the files
    if f.rsplit('.', 1)[1].lower() in ['mp3', 'aif', 'aiff', 'aifc', 'wav']:
        # file_list.append(os.path.join(directory,f))
        file_path = os.path.join(INSTRUMENTAL_DIR, f)
        song = audio.LocalAudioFile(file_path).analysis
        song_feats = {}
        song_feats['loudness'] = song.loudness
        song_feats['tempo'] = song.tempo.get('value')
        song_feats['name'] = f.rsplit('.',1)[0]
        data.append(song_feats)

similarity_instrumental.post(data)

#################### COPY PASTED ##################
# similarity_vocal = Firebase(FIREBASE_URL + "similarity_vocal/")
# data = []

# ff = os.listdir(VOCAL_DIR)
# for f in ff:
#     # collect the files
#     if f.rsplit('.', 1)[1].lower() in ['mp3', 'aif', 'aiff', 'aifc', 'wav']:
#         # file_list.append(os.path.join(directory,f))
#         file_path = os.path.join(VOCAL_DIR, f)
#         song = audio.LocalAudioFile(file_path).analysis
#         song_feats = {}
#         song_feats['loudness'] = song.loudness
#         song_feats['tempo'] = song.tempo.get('value')
from firebase import Firebase
from firebase_token_generator import create_token
import time
import random


auth_payload = {"uid":"k6wJ1M33MnaTiuRGU5IrFTwM5H53"}
token = create_token("1ufUtMReQxZlUe8kHdCs2WDfcmWdDKNeIziMg49o", auth_payload)


for i in range (1,100):

	spotId = random.randrange(1,127)
	f = Firebase("https://parking-monitor.firebaseio.com/lots/S17", auth_token=token)
	distance = random.randrange(0,400)
	randTime = random.randrange(1435255107,1465265107)
	rp = f.post({"date":randTime, "serial":"HC-SR04-1", "distance":distance, "spot":spotId})
	print("POST: " + str(rp))
	time.sleep(1)