Exemple #1
0
def pushItem(url, userId):
    firebase = pyrebase.initialize_app(config)
    db = firebase.database()
    try:
        all_datas = db.child("DATA").get().val()
        for key, data in all_datas.items():
            user_id = data["userId"]
            URL = data["URL"]
            if user_id == userId and url == URL:
                strw = "Item is already being monitored. Kindly provide the URL of new element"
                print(
                    "Item is already being monitored. Kindly provide the URL of new element"
                )
                send_message(userId, strw)
                return
    except:
        print("Nothing Found")
    newItem = {
        "userId": userId,
        "pname": "null",
        "URL": url,
        "initial_price": "null",
        "lowest_price": "null",
        "difference": "null",
        "change": "null"
    }
    db.child("DATA").push(newItem)
Exemple #2
0
def make_db(service_account=False):
    if service_account:
        c = config.SERVICE_CONFIG
    else:
        c = config.SIMPLE_CONFIG

    return pyrebase.initialize_app(c).database()
Exemple #3
0
def checkDatabaseTask(url, userId):
    firebase = pyrebase.initialize_app(config)
    db = firebase.database()
    try:
        a = db.child("DATA").get()
        all_datas = a.val()
        for key, data in all_datas.items():
            user_id = data["userId"]
            user_url = data["URL"]
            if user_id == data["userId"] and url == user_url:
                change = data["change"]
                if change == 1:
                    difference = data["difference"]
                    string = str.format("The price goes down by ${}",
                                        difference)
                    difference = data["difference"]
                    string = str.format(
                        "The price has decreased by ${}, time to consider buying it!",
                        difference)
                    difference = data["difference"]
                    string = str.format("The price went down by ${}",
                                        difference)
                    print("*****************\n", string, "\n**************")
                    send_message(userId, string)
    except:
        print("lol")
Exemple #4
0
def upload_pdf():
    firebase = pyrebase.initialize_app(config)
    storage = firebase.storage()
    path_local = "./Heartbreak/1.pdf"
    path_on_cloud = "pdfs/Heartbreak/heartbreak.pdf"
    storage.child(path_on_cloud).put(path_local)
    print(storage.child(path_on_cloud).get_url(path_on_cloud))
Exemple #5
0
def remove():
    mirror_uid = request.values.get('mirrorUid')
    uid = request.values.get('uid')
    fileName = request.values.get('fileName')
    artist = request.values.get('artist')
    song = request.values.get('song')
    file_dir = os.path.join(app.config['AUDIO_FOLDER'], mirror_uid, 'music', uid)
    file = file_dir + '//' + fileName
    print(file)
    # pyrebse 접근
    firebase = pyrebase.initialize_app(config)

    # Get a reference to the auth service
    auth = firebase.auth()

    # Get a reference to the database service
    db = firebase.database()

    if os.path.isfile(file):
        os.remove(file)
        fb.remove_music(uid, artist, song)
        trigger = {'remove': fileName}

        from app import connector
        msg = connector.update_pi(mirror_uid, uid, '/PLAYLIST', trigger)

        return 'true'
    else:
        return 'false'
Exemple #6
0
def hello_world():
	d = {}

	# Instance of Google Firebase
	firebase = pyrebase.initialize_app(config)

	# Acess the storage
	storage = firebase.storage()

	path_on_cloud = 'images/main.jpg'
	path_local = 'photo.png'

	# Get the image from path_on_cloud to path_local
	storage.child(path_on_cloud).download(path_local)

	input_word = str(request.args["Query"])
	if input_word == 'start':
		photo = extract_features('photo.png')
		# generate the description for the image
		description = generate_desc(model, tokenizer, photo, max_length)

		# Remove startseq and endseq
		query = description
		stopwords = ['startseq', 'endseq']
		querywords = query.split()

		resultwords = [word for word in querywords if word.lower() not in stopwords]
		result = ' '.join(resultwords)
		d['Query'] = result
		return jsonify(d)
	else:
		return 'Error'
Exemple #7
0
def get_music():
    mirror_uid = request.values.get('mirrorUid')
    uid = request.values.get('uid')
    fileName = request.values.get('fileName')
    file_dir = ''

    try:
        print('start')
        file_dir = os.path.join(app.config['AUDIO_FOLDER'], mirror_uid, 'music', uid)
        if not os.path.isdir(file_dir):
            os.makedirs(file_dir)
    except Exception as e:
        print(e)
    finally:
        #pyrebse 접근
        firebase = pyrebase.initialize_app(config)

        # Get a reference to the auth service
        auth = firebase.auth()

        # Get a reference to the database service
        db = firebase.database()

        # Get user key in database
        storage = firebase.storage()
        print(fileName)
        storage.child(uid + "/" + fileName).download(file_dir + "//" + fileName)
        trigger = {'update': fileName}

        from app import connector
        msg = connector.update_pi(mirror_uid, uid, '/PLAYLIST', trigger)

        return 'true'
Exemple #8
0
 def photo_url(self):
     """ Récupère l'URL complète de l'image """
     # Vérifier s'il s'agit d'une URL de photo
     if self.photo.startswith('http'):
         return self.photo
     # Récupération de l'URL grâce à pyrebase
     firebase = pyrebase.initialize_app(settings.FIREBASE_CONFIG)
     storage = firebase.storage()
     return storage.child(self.photo).get_url(None)
Exemple #9
0
 def create(self, validated_data):
     fire_store_config = pyrebase.initialize_app(firebaseConfig)
     auth = fire_store_config.auth()
     user = auth.sign_in_with_email_and_password("*****@*****.**",
                                                 "5qVpDGQy4tSEcR5")
     db = fire_store_config.database()
     print("Got to the saving ")
     db.child('employee').push({
         "name": "akram",
         "age": 27
     }, user['idToken'])
     print("Saved Data")
def download(inputfile, output):

    config = {
        "serviceAccount": "",
        "apiKey": "",
        "authDomain": "",
        "databaseURL": "",
        "storageBucket": "",
    }

    firebase = pyrebase.initialize_app(config)

    firebase.storage().child(inputfile).download(filename=output)
Exemple #11
0
    def __init__(self):
        self.configuration = GlobalConfigurationWrapper()
        self.firebaseConfig = {
            "apiKey": self.configuration.fbase_apiKey(),
            "authDomain": self.configuration.fbase_authDomain(),
            "databaseURL": self.configuration.fbase_databaseUrl(),
            "storageBucket": self.configuration.fbase_storageBucket()
        }

        self.firebase = pyrebase.initialize_app(self.firebaseConfig)
        self.db = self.firebase.database()

        self.turnOffWasRequested = False
Exemple #12
0
def init_firebase(cfg) -> (Database, Any):
    fb = cfg['Firebase']

    api_key = os.getenv("INNO_API_KEY")
    if api_key:
        fb["apiKey"] = api_key
    email = os.getenv("INNO_EMAIL") or fb["email"]
    password = os.getenv("INNO_PASSWORD") or fb["password"]

    firebase = pyrebase.initialize_app(fb)
    auth = firebase.auth()
    user = auth.sign_in_with_email_and_password(email, password)
    db = firebase.database()
    return db, user
Exemple #13
0
    def __init__(self):
        config = {
            "apiKey": "AIzaSyCFj9VQyRjRoqHDX_ZtFhS2h2JwGHWbAPA",
            "authDomain": "wap-web-project.firebaseapp.com",
            "databaseURL":
            "https://wap-web-project-default-rtdb.firebaseio.com",
            "projectId": "wap-web-project",
            "storageBucket": "wap-web-project.appspot.com",
            "messagingSenderId": "283455518398",
            "appId": "1:283455518398:web:9118aedeeb91e69b0c50ef"
        }

        firebase = pyrebase.initialize_app(config)
        self.db = firebase.database()
def fireinit():
    global db, storage
    config = {
        'apiKey': "AIzaSyCGOKhfIzz84YH4N3BesWNUCJ7TMZrrLCI",
        'authDomain': "iotc2020-41f98.firebaseapp.com",
        'databaseURL': "https://iotc2020-41f98.firebaseio.com",
        'projectId': "iotc2020-41f98",
        'storageBucket': "iotc2020-41f98.appspot.com",
        'messagingSenderId': "92339853452",
        'appId': "1:92339853452:web:bb90e76f6362ede61603a9",
        'measurementId': "G-RS1ZFQ23J9"
    }

    firebasePyre = pyrebase.initialize_app(config)
    storage = firebasePyre.storage()
    db = firebasePyre.database()
 def __init__(self):
     self.configuration = GlobalConfigurationWrapper()
     self.logger = Logger()
     
     self.firebaseConfig = {
       "apiKey": self.configuration.fbase_apiKey(),
       "authDomain": self.configuration.fbase_authDomain(),
       "databaseURL": self.configuration.fbase_databaseUrl(),
       "storageBucket": self.configuration.fbase_storageBucket()
     }
     
     self.firebase = pyrebase.initialize_app(self.firebaseConfig)
     self.db = self.firebase.database()
     
     self.__load_local_default_settings()
     self.__load_default_settings_from_firebase()
Exemple #16
0
 def query_nearby_objects(self, query_ref, geohash_ref, token_id=None):
     search_region_hashes = self.__get_search_region_geohashes()
     all_nearby_objects = {}
     for search_region_hash in search_region_hashes:
         try:
             firebase = pyrebase.initialize_app(self.__config)
             db = firebase.database()
             test_node = db.child(str(query_ref))
             nearby_objects = test_node.order_by_child(str(geohash_ref)). \
                 start_at(search_region_hash).end_at(search_region_hash + '\uf8ff').get(token=token_id).val()
             all_nearby_objects.update(nearby_objects)
         except requests.HTTPError as error:
             raise error
         except:
             continue
     return all_nearby_objects
Exemple #17
0
    def __init__(self):

        # pyrebase_config.json is of format
        # {
        #     "apiKey": "xxx",
        #     "authDomain": "xxx",
        #     "databaseURL": "xxx",
        #     "storageBucket": "xxx",
        #     "serviceAccount": "xxx.json"
        # }

        # TODO make configurable
        with open('pyrebase_config.json') as fp:
            config = json.load(fp)

        firebase = pyrebase.initialize_app(config)
        self.db = firebase.database()
Exemple #18
0
def Courbe():
    i=0
    while (1):
        i += 1
        T = random.randint(30, 32)
        H = random.randint(1, 100)/100
        L = random.randint(0, 5)
        time.sleep(4)
        firebaseConfig = {
            "apiKey": "AIzaSyDzMn2-97STkm94Rex_4kyt0Vjj8wfGTOY",
            "authDomain": "powerful-loader-298710.firebaseapp.com",
            "databaseURL": "https://powerful-loader-298710-default-rtdb.firebaseio.com/",
            "storageBucket": "powerful-loader-298710.appspot.com",
        }
        firebase = pyrebase.initialize_app(firebaseConfig)
        database = firebase.database()

        database.child("cities").child("cities").update({"cp": T, "altitude": H, "lum": L})
def get_firebase():
    return pyrebase.initialize_app({
        'apiKey': FIREBASE_API_KEY,
        'databaseURL': FIREBASE_DATABASE_URL,
        'storageBucket': FIREBASE_STORAGE_BUCKET,
        'authDomain': FIREBASE_AUTH_DOMAIN,
        'serviceAccount': {
            'type': FIREBASE_TYPE,
            'private_key_id': FIREBASE_PRIVATE_KEY_ID,
            'private_key': FIREBASE_PRIVATE_KEY.replace('\\n', '\n'),
            'client_email': FIREBASE_CLIENT_EMAIL,
            'client_id': FIREBASE_CLIENT_ID,
            'auth_uri': FIREBASE_AUTH_URI,
            'token_uri': FIREBASE_TOKEN_URI,
            'auth_provider_x509_cert_url':
            FIREBASE_AUTH_PROVIDER_X509_CERT_URL,
            'client_x509_cert_url': FIREBASE_CLIENT_X509_CERT_URL
        }
    })
Exemple #20
0
    def __init__(self):

        self.__configJSON = json.load(
            open(os.path.expanduser(self.__configPath)))

        self.__configData = {
            "apiKey": self.__configJSON['apiKey'],
            "authDomain": "crittercatcher-61af4.firebaseapp.com",
            "databaseURL": "https://crittercatcher-61af4.firebaseio.com",
            "projectId": "crittercatcher-61af4",
            "storageBucket": "crittercatcher-61af4.appspot.com",
            "messagingSenderId": "745850059470",
            "serviceAccount": os.path.expanduser(self.__serviceAccountPath)
        }

        self.__firebase = pyrebase.initialize_app(self.__configData)

        self.__userData = json.load(open(os.path.expanduser(self.__userPath)))

        self.__uuid = self.__userData["uuid"]
Exemple #21
0
class FirebasetestSpider(scrapy.Spider):
    config = {
        "apiKey": "AIzaSyC6oVdbBUuBALe1l0hwcEx_E7IOw0UUEhs",
        "authDomain": "pythonproject-e0183.firebaseapp.com",
        "databaseURL": "https://pythonproject-e0183.firebaseio.com",
        "projectId": "pythonproject-e0183",
        "storageBucket": "pythonproject-e0183.appspot.com",
        "messagingSenderId": "878861089919"
    }
    firebase = pyrebase.initialize_app(config)
    auth = firebase.auth()
    user = auth.sign_in_with_email_and_password('*****@*****.**', 'admin123')
    db = firebase.database()
    data = {"name": "Its morning!"}
    results = db.child("users").push(data, user['idToken'])
    name = 'firebasetest'
    allowed_domains = ['firebase.py']
    start_urls = ['http://firebase.py/']

    def parse(self, response):
        pass
Exemple #22
0
 def __init__(self):
     config = get_value('FIREBASE')
     firebase = pyrebase.initialize_app(config)
     self.storage = firebase.storage()
Exemple #23
0
from pyrebase import pyrebase
import getpass
import os
import subprocess
from subprocess import check_output

config = {
    "apiKey": "AIzaSyA11FpqG-RKNpZ0loNU8HhunHUgk7EFCqY ",
    "authDomain": "seniorsemgit.firebaseapp.com",
    "databaseURL": "https://seniorsemgit.firebaseio.com",
    "storageBucket": "seniorsemgit.appspot.com"
}
firebase = pyrebase.initialize_app(config)

# Database constants
boards = "Boards"
repository = "Repository"
repPath = "RepositoryPath"
userRep = "User"
users = "Users"
lastCommitId = "LastCommitId"
gitLog = "GitLog"
commitsRef = "Commits"
tasksRef = "Tasks"

# Variables
db = firebase.database()
userId = getpass.getuser()


# Task class
Exemple #24
0
def init_firebase():
    firebase = pyrebase.initialize_app(FB_CONFIG)
    # Firebase Database Intialization
    db = firebase.database()
    return db
from datetime import date
from dateutil.relativedelta import relativedelta
import pyrebase.pyrebase
from django.shortcuts import get_object_or_404

# Connection for employees to firebase login authentification
config = {
    'apiKey': "AIzaSyBIiU-vYyoHB3WqAkzgX9B2FtMzyKu9PSk",
    'authDomain': "database-258713.firebaseapp.com",
    'databaseURL': "https://database-258713.firebaseio.com/",
    'projectId': "database-258713",
    'storageBucket': "database-258713.appspot.com",
    'messagingSenderId': "225140590988",
    'appId': "1:225140590988:web:b5f4f273d0250782e6eea9"
}
firebase = pyrebase.initialize_app(config)

auth = firebase.auth()

# Admin connection
configAdmin = {
    'apiKey': "AIzaSyCX3rg4fptOdNpsll4iUu0JgjGHMLiAOOE",
    'authDomain': "homework4-256814.firebaseapp.com",
    'databaseURL': "https://homework4-256814.firebaseio.com",
    'projectId': "homework4-256814",
    'storageBucket': "homework4-256814.appspot.com",
    'messagingSenderId': "999208004782",
    'appId': "1:999208004782:web:cf8047d08b5e438725913f"
}
# Initialize FirebaseAdmin
firebaseAdmin = pyrebase.initialize_app(configAdmin)
Exemple #26
0
from pyrebase import pyrebase
import numpy as np

firebaseConfig = {"apiKey": "AIzaSyABh5NA4kJSWoPS_3Q8vwX-fqDoy63HjYg",
                  "authDomain": "medicineatm-7d374.firebaseapp.com",
                  "databaseURL": "https://medicineatm-7d374-default-rtdb.firebaseio.com/",
                  "projectId": "medicineatm-7d374",
                  "storageBucket": "medicineatm-7d374.appspot.com",
                  "messagingSenderId": "961671499065",
                  "appId": "1:961671499065:web:c6080afb602762b8a06ce8",
                  "measurementId": "G-SL89Z8HNWX"
                  }

global usersAccounts

firebase = pyrebase.initialize_app(firebaseConfig)

db = firebase.database()

users = db.child("Customers").get()

for user in users.each():

    usersAccounts = (user.val().get('accountNumber'))


Exemple #27
0
 def __init__(self):
     config = get_value('FIREBASE')
     firebase = pyrebase.initialize_app(config)
     self.db = firebase.database()
Exemple #28
0
def get_pdf(story, number):
    firebase = pyrebase.initialize_app(config)
    storage = firebase.storage()
    path_on_cloud = "pdfs/{}/{}.pdf".format(str(story), str(number))
    print(storage.child(path_on_cloud).get_url(path_on_cloud))
    return storage.child(path_on_cloud).get_url(path_on_cloud)
Exemple #29
0
                for x in sent:
                    commandId = x["command_id"]
                p.updateStatus(commandId, "ANSWERED")
                db.child("Commands").child(k).update(data)


@app.route('/sms', methods=['POST'])
def sms():
    number = request.form['From']
    message_body = request.form['Body']
    print('mensaje: ' + message_body)
    log.debug('Mensaje: ' + message_body)
    resp = MessagingResponse()
    print("Respuesta: " + str(resp))
    #log('Respuesta: ' + str(resp))
    #resp.message('Hello {}, you said: {}'.format(number, message_body))
    saveResponse(number, message_body)
    return str(resp)


@app.route('/sms', methods=['GET'])
def test():
    print('get en sms')


fireb = pyrebase.initialize_app(config.firebaseConf)
db = fireb.database()

if __name__ == '__main__':
    app.run(host='0.0.0.0')
Exemple #30
0
 def get_firebase_instance(self, **kwargs):
     if kwargs:
         if kwargs['type'] == 'admin':
             return pyrebase.initialize_app(self.config_a)
     else:
         return pyrebase.initialize_app(self.config)