xml.etree.ElementTree.ParseError deploy lambda django with zappa - django

I tried to deploy my django project through zappa to create lambda and I got this error, can anyone help me with this?
Traceback (most recent call last):
File "C:\Users\kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\parsers.py", line 504, in _parse_xml_string_to_dom
root = parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
raise ResponseParserError(
botocore.parsers.ResponseParserError: Unable to parse response (no element found: line 1, column 0), invalid XML received. Further retries may succeed:
b''

I was able to solve it, I had to create an aws-cli user profile again

Related

While airflow initdb, AttributeError: module' object has no attribute 'client_auth'

I have recently installed apache airflow 1.8.1, I executed following command:
airflow initdb
which returned following error:
Traceback (most recent call last):
File "/usr/bin/airflow", line 18, in <module>
from airflow.bin.cli import CLIFactory
File "/usr/lib/python2.7/dist-packages/airflow/bin/cli.py", line 65, in <module>
auth=api.api_auth.client_auth)
AttributeError: 'module' object has no attribute 'client_auth'
I tried several solutions but it doesn't work.
I figured out what we were doing wrong. The field auth_backend=airflow.contrib.auth.backends.password_auth needs to be under webserver and not under api. Add it if it is not already there. There are multiple fields for auth_backend as there are authenticate etc..
I had the same error with airflow 1.8.1 with python 2.7.11.
I have disabled the webserver auth ( temporarily) and switched to the default value for auth_backend. ( that solved the issue)
The final configuration in my airflow.cfg is as follows
auth_backend = airflow.api.auth.backend.default
authenticate = False

Http 404 when trying to get files with special characters from GitLab API

I am using python-gitlab driver for the Gitlab API. The following work fine on my repository:
>>> rf_blob = p.repository_blob(p_latest_commit.id, 'iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMOAuth2Authentication.h')
>>> rf_blob = p.repository_blob(p_latest_commit.id, 'iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMOAuth2SignIn.h')
However, when I try to open a file that contains a + character in it, I get the following even though that file clearly exists in the repository:
>>> rf_blob = p.repository_blob(p_latest_commit.id, 'iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMNSString+URLArguments.h')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/gitlab/objects.py", line 1521, in repository_blob
raise_error_from_response(r, GitlabGetError)
File "/usr/local/lib/python2.7/site-packages/gitlab/exceptions.py", line 140, in raise_error_from_response
response_body=response.content)
gitlab.exceptions.GitlabGetError: 404: 404 File Not Found
How exactly do I go about escaping the + in python so that I can get the blob of the file?
The solution is to use urllib.quote.
python-gitlab is a superficial wrapper upon the real Gitlab API. The Gitlab API functions on url requests so this solution seemed natural:
rf_blob = p.repository_blob(p_latest_commit.id, urllib.quote('iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMNSString+URLArguments.h'))

pyhs2 error connective to kerberos enabled hive

I am trying to connect to hive using python 2(miniconda2 installation ).
Below is the code I am trying-
connection = hive.connect(host='psvlxihpnn1', port= '10000', authMechanism='KERBEROS', user='***',password='****', configuration={'krb_host': 'psvlxihpnn1', 'krb_service': 'ITEDM'} )
kerberos host is installed on the same host machine and has service name 'ITEDM'
Strangely, I am getting below error-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/export/home/itedm/miniconda2/lib/python2.7/site-packages/pyhs2-0.6.0-py2.7.egg/pyhs2/__init__.py", line 7, in connect
File "/export/home/itedm/miniconda2/lib/python2.7/site-packages/pyhs2-0.6.0-py2.7.egg/pyhs2/connections.py", line 46, in __init__
File "/export/home/itedm/miniconda2/lib/python2.7/site-packages/pyhs2-0.6.0-py2.7.egg/pyhs2/cloudera/thrift_sasl.py", line 66, in open
thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-1) SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (Server krbtgt/INFORMATICA.COM#ITEDM not found in Kerberos database)
I am not passing 'krbtgt' as user, not sure why this error is coming.
Thanks for any help.
This connection string will work as long as the user running the script has a valid kerberos ticket:
import pyhs2
with pyhs2.connect(host='beeline_host',
port=10000,
authMechanism="KERBEROS") as conn:
with conn.cursor() as cur:
print cur.getDatabases()
Username, password and any other configuration parameters are not passed through the KDC.

Py2neo searching error

Im still trying to make a social network with py2neo+flask+neo4j.
I've got a problem while searching my database with py2neo.I wanna find all the users that their username includes a special string.For example all the users that their username includes "dav".I wrote the code below and i dont know why i get this error...
from py2neo import Graph
graph=Graph("http://neo4j:123#localhost:7474/ ")
def search(name):
users=graph.merge("Person")
for N in users:
print N['username']
and this is my error:
Traceback (most recent call last):
File "", line 1, in
File "/home/ali/Desktop/flask/search.py", line 10, in search users=graph.cypher.execute('match (p:Person) return p'
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 659, in cypher metadata = self.resource.metadata
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 213, in metadata self.get()
File "/usr/local/lib/python2.7/dist-packages/py2neo/core.py", line 267, in get raise_from(self.error_class(message, **content), error)
File "/usr/local/lib/python2.7/dist-packages/py2neo/util.py", line 235, in raise_from raise exception py2neo.error.GraphError: HTTP GET returned response 404
Your URL is wrong, you should change it to this:
Graph("http://neo4j:123#localhost:7474/db/data")
Also, you can't execute cypher through the merge function, instead you should do this:
users = graph.cypher.execute('match (p:Person) return p')

Rebuilding ElasticSearch index using django-haystack rebuild_index command

I am trying to get ElasticSearch / Haystack set up on my local dev environment (vagrant VM running Ubuntu 12.04), and I can't work out the re-indexing process.
ES is running, and I have created a new index (I am using elasticsearch-head to view index status in the browser). I can create a new index, and query it, so I know that ES is working.
My problem is with the Haystack rebuild_index command:
(.venv)vagrant#precise32:/app$ foreman run ./manage.py rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
DEBUG Making a request equivalent to this: curl -XDELETE 'http://127.0.0.1:9200/test_app' -d '""'
INFO Starting new HTTP connection (1): 127.0.0.1
DEBUG "DELETE /test_app HTTP/1.1" 200 31
DEBUG response status: 200
DEBUG got response {u'acknowledged': True, u'ok': True}
DEBUG Making a request equivalent to this: curl -XPOST 'http://127.0.0.1:9200/test_app/_refresh' -d '""'
DEBUG "POST /test_app/_refresh HTTP/1.1" 404 66
DEBUG response status: 404
Failed to clear Elasticsearch index: (404, u'IndexMissingException[[test_app] missing]')
ERROR Failed to clear Elasticsearch index: (404, u'IndexMissingException[[test_app] missing]')
All documents removed.
Looking at this loggging - it seems as if Haystack is attempting to refresh an index that it has just deleted - which would always fail.
What am I doing wrong?
[UPDATE 1]
If I split the POST requests I can get this to run:
(.venv)vagrant#precise32:/app$ curl -XPOST 'http://127.0.0.1:9200/test_app/'
{"ok":true,"acknowledged":true}
(.venv)vagrant#precise32:/app$ curl -XPOST 'http://127.0.0.1:9200/test_app/_refresh' -d '""'
{"ok":true,"_shards":{"total":10,"successful":5,"failed":0}}
[UPDATE 2]
Digging in to the code, the ES backend method that is called when running clear_index is:
def clear(self, models=[], commit=True):
[...]
if not models:
self.conn.delete_index(self.index_name)
else:
[...]
if commit:
self.conn.refresh(index=self.index_name)
Which looks wrong as it will call conn.refresh on the index that it has just deleted?
[UPDATE 3]
I think the above errors may be a red herring, as the management commands will ignore the errors and continue, giving this error, which I think is more serious:
(.venv)vagrant#precise32:/app$ foreman run ./manage.py update_index --verbosity=3
Skipping '<class 'django.contrib.auth.models.Permission'>' - no index.
Skipping '<class 'django.contrib.auth.models.Group'>' - no index.
Skipping '<class 'django.contrib.auth.models.User'>' - no index.
Skipping '<class 'django.contrib.contenttypes.models.ContentType'>' - no index.
Skipping '<class 'django.contrib.sessions.models.Session'>' - no index.
Skipping '<class 'django.contrib.sites.models.Site'>' - no index.
Skipping '<class 'django.contrib.admin.models.LogEntry'>' - no index.
Skipping '<class 'django.contrib.flatpages.models.FlatPage'>' - no index.
ERROR Error updating test_app using default
Traceback (most recent call last):
File "/home/vagrant/.venv/src/django-haystack/haystack/management/commands/update_index.py", line 210, in handle_label
self.update_backend(label, using)
File "/home/vagrant/.venv/src/django-haystack/haystack/management/commands/update_index.py", line 239, in update_backend
end_date=self.end_date)
File "/home/vagrant/.venv/src/django-haystack/haystack/indexes.py", line 157, in build_queryset
index_qs = self.index_queryset(using=using)
TypeError: index_queryset() got an unexpected keyword argument 'using'
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/.venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/vagrant/.venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/.venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/.venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/home/vagrant/.venv/src/django-haystack/haystack/management/commands/update_index.py", line 184, in handle
return super(Command, self).handle(*items, **options)
File "/home/vagrant/.venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 341, in handle
label_output = self.handle_label(label, **options)
File "/home/vagrant/.venv/src/django-haystack/haystack/management/commands/update_index.py", line 210, in handle_label
self.update_backend(label, using)
File "/home/vagrant/.venv/src/django-haystack/haystack/management/commands/update_index.py", line 239, in update_backend
end_date=self.end_date)
File "/home/vagrant/.venv/src/django-haystack/haystack/indexes.py", line 157, in build_queryset
index_qs = self.index_queryset(using=using)
TypeError: index_queryset() got an unexpected keyword argument 'using'
[UPDATE 4]
OK - so it's my fault, I was using an old search_indexes.py file, and my index_queryset() method was incorrect. I won't close this as it may be useful for others.
Answering this one myself - albeit it's just an admission of my own stupidity in this one.
I carried a search_indexes.py file from the 1.x version of Haystack into a new branch of our project that was using the 2.x version of Haystack, which is configured slightly differently. In the new version, the index_queryset() method now requires a new using parameter (defaults to None). The older version didn't require this.
The new signature should therefore be:
def index_queryset(self, using=None):
pass