I am receiving a 504 Deadline Exceeded error trying to run a simple python script to add a document to Firestore.
from firebase_admin import firestore, credentials
cred = credentials.Certificate("<path to service account>")
firebase_admin.initialize_app(cred)
print("initialized firebase successfully")
product_dict={
'test1': 'test',
'test2': 'test2'
}
firestore_client = firestore.client()
doc_ref = firestore_client.collection('products').document('test')
doc_ref.set(product_dict)
Output:
intialized firebase successfully
Traceback (most recent call last):
File "test.py", line 14, in <module>
doc_ref.set(product_dict)
File "/Users/.../env/lib/python2.7/site-packages/google/cloud/firestore_v1/document.py", line 234, in set
write_results = batch.commit()
File "/Users/.../env/lib/python2.7/site-packages/google/cloud/firestore_v1/batch.py", line 147, in commit
metadata=self._client._rpc_metadata,
File "/Users/.../env/lib/python2.7/site-packages/google/cloud/firestore_v1/gapic/firestore_client.py", line 1042, in commit
request, retry=retry, timeout=timeout, metadata=metadata
File "/Users/.../env/lib/python2.7/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
return wrapped_func(*args, **kwargs)
File "/Users/.../env/lib/python2.7/site-packages/google/api_core/retry.py", line 273, in retry_wrapped_func
on_error=on_error,
File "/Users/.../env/lib/python2.7/site-packages/google/api_core/retry.py", line 182, in retry_target
return target()
File "/Users/.../env/lib/python2.7/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "/Users/.../env/lib/python2.7/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "/Users/.../env/lib/python2.7/site-packages/six.py", line 737, in raise_from
raise value
google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded
I've tried using Pipenv with Python 3.7, and virtualenv with python 2, same results.
Running from terminal on macOS Mojave 10.14.3
Related
I am using the Google Translate API v2 and I am able to get the translations but I also get these errors on the side which I am not able to resolve.
Failed to submit 1 logs.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 67, in error_remapped_callable
return callable_(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "Permission 'logging.logEntries.create' denied on resource (or it may not exist)."
debug_error_string = "{"created":"#1659523475.735415900","description":"Error received from peer ipv4:142.250.194.234:443","file":"src/core/lib/surface/call.cc","file_line":966,"grpc_message":"Permission 'logging.logEntries.create' denied on resource (or it may not exist).","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/handlers/transports/background_thread.py", line 114, in _safely_commit_batch
batch.commit()
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/logger.py", line 385, in commit
client.logging_api.write_entries(entries, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/_gapic.py", line 149, in write_entries
self._gapic_api.write_log_entries(request=request)
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/services/logging_service_v2/client.py", line 615, in write_log_entries
metadata=metadata,
File "/usr/local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 291, in retry_wrapped_func
on_error=on_error,
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 189, in retry_target
return target()
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 69, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 Permission 'logging.logEntries.create' denied on resource (or it may not exist).
Failed to submit 1 logs.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 67, in error_remapped_callable
return callable_(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "Permission 'logging.logEntries.create' denied on resource (or it may not exist)."
debug_error_string = "{"created":"#1659523476.318220100","description":"Error received from peer ipv4:142.250.194.234:443","file":"src/core/lib/surface/call.cc","file_line":966,"grpc_message":"Permission 'logging.logEntries.create' denied on resource (or it may not exist).","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/handlers/transports/background_thread.py", line 114, in _safely_commit_batch
batch.commit()
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/logger.py", line 385, in commit
client.logging_api.write_entries(entries, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/_gapic.py", line 149, in write_entries
self._gapic_api.write_log_entries(request=request)
File "/usr/local/lib/python3.7/site-packages/google/cloud/logging_v2/services/logging_service_v2/client.py", line 615, in write_log_entries
metadata=metadata,
File "/usr/local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 291, in retry_wrapped_func
on_error=on_error,
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 189, in retry_target
return target()
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 69, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 Permission 'logging.logEntries.create' denied on resource (or it may not exist).
I am guesing that this issue is because of the logging but I am not able to turn off the logging. I used the following reference - https://cloud.google.com/translate/docs/basic/translating-text#translating_text and the Python code mentioned here.
I am writing the code inside Django.
It looks like your Python client is attempting to write in Google Cloud log.
Either this is a feature / setting in your client (that you might want to disable), or you might want to add the permission to your API keys to allow the API key to write in Google Cloud Log
I have a simple Google App Engine web app that runs fine in my local development environment (including being able to post to the datastore), but when deployed to Google App Engine I get the following error messages in the console.
Note that the second traceback is abridged - above it is a call to the put method of the datastore.Client() instance.
I have tried re-deploying and have tried googling the error messages but no luck so far. Is there somewhere I need to tell GAE that my app should have permission to the datastore?
Any pointers much appreciated.
Traceback (most recent call last):
File "/env/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/env/lib/python3.7/site-packages/grpc/_channel.py", line 923, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/env/lib/python3.7/site-packages/grpc/_channel.py", line 826, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
File "/layers/google.python.pip/pip/google/cloud/datastore/client.py", line 565, in put
self.put_multi(entities=[entity], retry=retry, timeout=timeout)
File "/layers/google.python.pip/pip/google/cloud/datastore/client.py", line 605, in put_multi
current.commit(retry=retry, timeout=timeout)
File "/layers/google.python.pip/pip/google/cloud/datastore/batch.py", line 293, in commit
self._commit(retry=retry, timeout=timeout)
File "/layers/google.python.pip/pip/google/cloud/datastore/batch.py", line 257, in _commit
commit_response_pb = self._client._datastore_api.commit(
File "/layers/google.python.pip/pip/google/cloud/datastore_v1/gapic/datastore_client.py", line 645, in commit
return self._inner_api_calls["commit"](
File "/layers/google.python.pip/pip/google/api_core/gapic_v1/method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "/layers/google.python.pip/pip/google/api_core/retry.py", line 281, in retry_wrapped_func
return retry_target(
File "/layers/google.python.pip/pip/google/api_core/retry.py", line 184, in retry_target
return target()
File "/layers/google.python.pip/pip/google/api_core/timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "/layers/google.python.pip/pip/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 Missing or insufficient permissions.
Your account that runs the app (probably your App Engine service account) should have the required permissions for the Datastore. Please give roles/datastore.user as described here
If I run in the shell:
mongo ds0219xx.mlab.com:219xx/dbname -u user -p pass
It works and allows me to connect to the database and pull information. But if I'm within my python application (Flask) and run this:
import pymongo
client = pymongo.MongoClient("mongodb://user:pass#ds0219xx.mlab.com:219xx/dbname")
db = client["dbname"]
db.users.insert_one({
"user1": "hello"
})
It gives me an:
pymongo.errors.OperationFailure: Authentication failed.
I'm pretty sure it's failing before it gets to the insert_one() call, but I'm not completely sure.
Thanks!
Edit:
By request, here is the full callback:
Traceback (most recent call last):
File "run.py", line 1, in <module>
from app import app
File "/Users/Derek/Documents/programming/shenalum/app/__init__.py", line 6, in <module>
from app import views
File "/Users/Derek/Documents/programming/shenalum/app/views.py", line 4, in <module>
from data import get_posts, get_user_info
File "/Users/Derek/Documents/programming/shenalum/app/data.py", line 9, in <module>
"user1": "hello"
File "/usr/local/lib/python2.7/site-packages/pymongo/collection.py", line 622, in insert_one
with self._socket_for_writes() as sock_info:
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 718, in _get_socket
with server.get_socket(self.__all_credentials) as sock_info:
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/pymongo/server.py", line 152, in get_socket
with self.pool.get_socket(all_credentials, checkout) as sock_info:
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 541, in get_socket
sock_info.check_auth(all_credentials)
File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 306, in check_auth
auth.authenticate(credentials, self)
File "/usr/local/lib/python2.7/site-packages/pymongo/auth.py", line 436, in authenticate
auth_func(credentials, sock_info)
File "/usr/local/lib/python2.7/site-packages/pymongo/auth.py", line 416, in _authenticate_default
return _authenticate_scram_sha1(credentials, sock_info)
File "/usr/local/lib/python2.7/site-packages/pymongo/auth.py", line 188, in _authenticate_scram_sha1
res = sock_info.command(source, cmd)
File "/usr/local/lib/python2.7/site-packages/pymongo/pool.py", line 213, in command
read_concern)
File "/usr/local/lib/python2.7/site-packages/pymongo/network.py", line 99, in command
helpers._check_command_response(response_doc, None, allowable_errors)
File "/usr/local/lib/python2.7/site-packages/pymongo/helpers.py", line 196, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Authentication failed.
I figured it out. You can do this from the python file and it will work:
connection = pymongo.MongoClient(ab123456.mlab.com, 123456)
db = connection[databasename]
db.authenticate(database_user, database_pass)
Appending /?authSource=admin helped me.
Full Example:
uri = 'mongodb://username:password#r1.example.net:27017/?authSource=admin'
client = MongoClient(uri)
db = client.test
result = db.users.find()
for document in result:
print(document)
Version: pymongo 3.7.2
You need to authenticate after selecting the database for mongo < 4.0
I'm using python2.7 and fabric to connect to an sftp server.
Here's what I'm doing:
from fabric.api import env, get, run
env.key_filename = '/path/to/keyfile'
env.host_string = 'host.string'
env.user = 'user'
At this point, get('filename') successfully downloads a file from the sftp server. But run('ls') gives me:
[host.string] run: ls
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 647, in host_prompting_wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 1054, in run
shell_escape=shell_escape)
File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 923, in _run_command
stderr=stderr, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 764, in _execute
channel.get_pty(width=cols, height=rows)
File "/usr/local/lib/python2.7/dist-packages/paramiko/channel.py", line 60, in _check
return func(self, *args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/paramiko/channel.py", line 177, in get_pty
self._wait_for_event()
File "/usr/local/lib/python2.7/dist-packages/paramiko/channel.py", line 1086, in _wait_for_event
raise e
paramiko.ssh_exception.SSHException: Channel closed.
When I manually log into the sftp server, using the same creds, I can ls just fine.
Any ideas? Thanks.
I've installed trac 0.12 on my ubuntu 10.04, running the tracd internal webserver. When i access the page at http://127.0.0.1/myTracProject, I get the error message:
Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/api.py", line 376, in send_error
'text/html') File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/chrome.py", line 733, in render_template
message = req.session.pop('chrome.%s.%d' % (type_, i)) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/api.py", line 195, in __getattr__
value = self.callbacks[name](self) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/main.py", line 265, in _get_session
return Session(self.env, req) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/session.py", line 157, in __init__
self.get_session(sid) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/session.py", line 178, in get_session
super(Session, self).get_session(sid, authenticated) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/web/session.py", line 59, in get_session
(sid, int(authenticated))) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/db/util.py", line 64, in execute
return self.cursor.execute(sql_escape_percent(sql), args) File "/usr/local/lib/python2.6/dist-packages/Trac-0.11.7-py2.6.egg/trac/db/util.py", line 64, in execute
return self.cursor.execute(sql_escape_percent(sql), args) InternalError: current transaction is aborted, commands ignored until end of transaction block
You installed Trac 0.12? Your traceback shows "Trac-0.11.7-py2.6.egg". Looks like you need to do some cleanup.