0

I have been struggling with installing pyrebase on my second PC, which has the same python version 3.8.2 as my main PC, my main PC has this pyrebase script working properly

from pyrebase import pyrebase
import os
import time

project_root = os.path.dirname(os.path.dirname(__file__))
keys_path = os.path.join(project_root, 'keys')
hylKeyPath = os.path.join(keys_path, 'ServiceAccountKey.json')


firebase = pyrebase.initialize_app({
    "apiKey": "aksdjalksjdlkajsdlkjalkdja",
    "authDomain": "lkjsakdjlkjsad.firebaseapp.com",
    "databaseURL": "https://asdlkasjldkjaslkd.firebaseio.com",
    "storageBucket": "asdasdadjaslkjhd.appspot.com",
    "serviceAccount": asdKeyPath
})

storage = firebase.storage()


def sleepCountDown(t):
    while t > 0:
        print(f"sleeping for {t} seconds...")
        t -= 1
        time.sleep(1)


while True:
    print('fetching data')
    files = storage.child('/').list_files()

    for file in files:
        if 'records/' in file.name:
            # get the file url path
            # print(storage.child(file.name).get_url(None))

            # downloads file
            storage.child(file.name).download(os.path.basename(file.name))
            # deletes file? kinda deletes the entire folder
            storage.delete(file.name)
    sleepCountDown(10)

But somehow I am not able to install pyrebase on my second PC so I had to install pyrebase4.

But it seems this one has some bugs and keeps highlighting storage.child(file.name).download(os.path.basename(file.name)) saying that storage: No value for argument 'filename' in method call.

then when I run, it says "Crypto has no method or something"

anyone knows what is going on?

fenchai
  • 518
  • 1
  • 7
  • 21

2 Answers2

1

Just noticed the syntax was different on pyrebase4, it's .download(path, filename) the documentation was outdated.

fenchai
  • 518
  • 1
  • 7
  • 21
0

Instead of:

storage.child(file.name).download(os.path.basename(file.name))

Use:

storage.child("filename").download(filename="filename" , path="E:/ddf/")

Where E:/ddf/ is path you want to save your file.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83