Hi there,
I am trying to runa py3 script in the scriptEditor that writes data to Google Firebase, but I get an unexpected error.
- The script runs fine if I run in python3.11 from the powershell, outside of Rhino.
- reading from the database works in RH8 as expected
Can anyone help me with this? (@eirannejad maybe ?)
Thanks,
Tim
"""Requirements"""
print('installing python packages once...')
# r: firebase-admin
# r: google-cloud-firestore
print('packages installed')#! python3
import sys, os
sys.path.append(os.getcwd() + '/../')
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
def main():
app = firebase_admin._apps.get('[DEFAULT]')
if not app:
cred = credentials.Certificate(r"path\to\my\credentials.json")
app = firebase_admin.initialize_app(cred)
db = firestore.client()
doc_ref = db.collection(u'application_metadata').document( u'test' )
doc_ref.set({'uuid':'test'})
if __name__ == '__main__':
main()
the error message seems to point to one of the dependencies that is not working when executing the script inside the RH8 scripteditor.
Traceback (most recent call last):
File "file:///T:/Shared%20drives/Library%20DS/Scripts/tnm_suite_dev/playground/test_firebase.py", line 33, in <module>
File "file:///T:/Shared%20drives/Library%20DS/Scripts/tnm_suite_dev/playground/test_firebase.py", line 30, in main
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\document.py", line 166, in set
batch, kwargs = self._prep_set(document_data, merge, retry, timeout)
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\base_document.py", line 217, in _prep_set
batch.set(self, document_data, merge=merge)
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\base_batch.py", line 111, in set
write_pbs = _helpers.pbs_for_set_no_merge(
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\_helpers.py", line 723, in pbs_for_set_no_merge
set_pb = extractor.get_update_pb(document_path)
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\_helpers.py", line 586, in get_update_pb
name=document_path, fields=encode_dict(self.set_fields)
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\_helpers.py", line 238, in encode_dict
return {key: encode_value(value) for key, value in values_dict.items()}
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\_helpers.py", line 238, in <dictcomp>
return {key: encode_value(value) for key, value in values_dict.items()}
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\google\cloud\firestore_v1\_helpers.py", line 195, in encode_value
return document.Value(string_value=value)
File "C:\Users\info\.rhinocode\py39-rh8\site-envs\default-vc4N90f8\proto\message.py", line 615, in __init__
super().__setattr__("_pb", self._meta.pb(**params))
TypeError: 'NoneType' object is not callable