TypeError at /admin/ 'set' object is not reversible - django-admin

Environment:
Request Method: GET Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.10.6 Python Version: 3.6.0 Installed Applications: ['music.apps.MusicConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\handlers\exception.py" in inner 42. response = get_response(request)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\handlers\base.py" in _legacy_get_response 249. response = self._get_response(request)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\contrib\admin\sites.py" in wrapper 229. return self.admin_view(view, cacheable)(*args, **kwargs)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\utils\decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\views\decorators\cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\contrib\admin\sites.py" in inner 211. return view(request, *args, **kwargs)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\views\decorators\cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\contrib\admin\sites.py" in index 468. app_list = self.get_app_list(request)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\contrib\admin\sites.py" in get_app_list 451. app_dict = self._build_app_dict(request)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\contrib\admin\sites.py" in _build_app_dict 418. model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name)
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\base.py" in reverse 60. app_list = resolver.app_dict[ns]
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\resolvers.py" in app_dict 256. self._populate()
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\resolvers.py" in _populate 209. for name in pattern.reverse_dict:
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\resolvers.py" in reverse_dict 242. self._populate()
File "C:\Users\Dell Laptop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\resolvers.py" in _populate 196. for pattern in reversed(self.url_patterns):
Exception Type: TypeError at /admin/ Exception Value: 'set' object is not reversible

in your urls change {} brackets to [] these

Please change {} to [] in your urls.py file.
e.g.urlpatterns=[path('', views.itemlist, name="itemlist"),]

You have to change the {} to [] in your urls.py where the urlpatterns variable is

Related

Jira create issue returns 405 python

I am using python Jira package and trying to create Jira issue:
from jira import JIRA
jiraOptions = {'server': "http://jira.xxx.com"}
jira = JIRA(options = jiraOptions, basic_auth=(
"xxx", "xxx"))
def create_new_issue(project, summary, description, issuetype, username):
issue_dict = {
'project': {'key': project},
'summary': summary,
'description': description,
'issuetype': {'name': issuetype},
'reporter': {'name': username}
}
new_issue = jira.create_issue(fields=issue_dict)
create_new_issue("p1", "test", "teseset", "Bug", "xxxx")
I get 405 error which I can't figure out where I got wrong:
Traceback (most recent call last):
File ".\jiraUtil.py", line 97, in <module>
create_new_issue("p1", "test", "teseset", "Bug", "xxxx")
File ".\jiraUtil.py", line 58, in create_new_issue
new_issue = jira.create_issue(fields=issue_dict)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\client.py", line 1473, in create_issue
r = self._session.post(url, data=json.dumps(data))
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\resilientsession.py", line 198, in post
return self.__verb("POST", str(url), data=data, json=json, **kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\resilientsession.py", line 189, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38\lib\site-packages\jira\resilientsession.py", line 64, in raise_on_error
raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 405 url: https://jira.xxx.com/rest/api/2/issue
At a guess, "xxxx" user doesn't exist in your Jira Cloud instance, try changing it to "-1" which is unassigned.
I ran into some issues myself doing this, so I built this project - https://github.com/dren79/JiraScripting_public let me know if it helps :)

SSL error trying send an email with Flask-mail

I have been trying to send an email using Flask-mail but I always got about SSL.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076) // Werkzeug Debugger also I using Mailtrap as dummy email server to test my app. I have been trying with different mail clients and always god the same error.
And what I'm trying to do, is that once a new user has registered. Send an email to confirm your account by a token.
<!--
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/usr/local/lib/python3.7/site-packages/flask_restplus/api.py", line 584, in error_router
return original_handler(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/usr/local/lib/python3.7/site-packages/flask_restplus/api.py", line 584, in error_router
return original_handler(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.7/site-packages/flask_restplus/api.py", line 325, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/usr/src/app/app/user/controller.py", line 35, in post
return UseService.register(data)
File "/usr/src/app/app/user/service.py", line 48, in register
send_confirmation_email(new_user.email)
File "/usr/src/app/app/utility/mailutility.py", line 40, in send_confirmation_email
send_email(to, "Test server - confirm your registration", html)
File "/usr/src/app/app/utility/mailutility.py", line 32, in send_email
mail.send(message)
File "/usr/local/lib/python3.7/site-packages/flask_mail.py", line 491, in send
with self.connect() as connection:
File "/usr/local/lib/python3.7/site-packages/flask_mail.py", line 144, in __enter__
self.host = self.configure_host()
File "/usr/local/lib/python3.7/site-packages/flask_mail.py", line 156, in configure_host
host = smtplib.SMTP_SSL(self.mail.server, self.mail.port)
File "/usr/local/lib/python3.7/smtplib.py", line 1031, in __init__
source_address)
File "/usr/local/lib/python3.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python3.7/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/local/lib/python3.7/smtplib.py", line 1039, in _get_socket
server_hostname=self._host)
File "/usr/local/lib/python3.7/ssl.py", line 423, in wrap_socket
session=session
File "/usr/local/lib/python3.7/ssl.py", line 870, in _create
self.do_handshake()
File "/usr/local/lib/python3.7/ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076)
My env file
MAIL_SERVER=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=mail_username
MAIL_PASSWORD=mail_password
MAIL_USE_TLS=True
MAIL_USE_SSL=False
MAIL_DEFAULT_SENDER=username#mail.com
Code
# !/usr/bin/python
# -*- coding: utf-8 -*-
from itsdangerous import URLSafeTimedSerializer
from flask_mail import Message
from flask import url_for, render_template
from flask import current_app as app
from app import mail
def generate_confirmation_token(email):
serializer = URLSafeTimedSerializer(app.config.get("SECRET_KEY"))
return serializer.dumps(email, salt=app.config.get("SECURITY_PASSWORD_SALT"))
def confirm__token(token, expiration=3000):
serializer = URLSafeTimedSerializer(app.config.get("SECRET_KEY"))
try:
email = serializer.loads(
token,
salt=app.congit.get("SECURITY_PASSWORD_SALT"),
max_age=expiration
)
except: # noqa
return False
return email
def send_email(to, subject, template):
""" Send an email """
message = Message(subject, recipients=[to], html=template, sender=app.config.get("MAIL_DEFAULT_SENDER"))
mail.send(message)
def send_confirmation_email(to):
"""Send a confirmation email to the registered user."""
token = generate_confirmation_token(to)
confirm_url = url_for("user_user_confirmation_mail", token=token, _external=True)
html = render_template('confirmation.html', confirm_url=confirm_url)
send_email(to, "Test server - confirm your registration", html)
I don't if that could make sense, but use docker to run my app
In my config file, I have only MAIL_USE_TLS=True and no MAIL_USE_SSL.
When I had MAIL_USE_TLS and MAIL_USE_SSL set to true, I got the same error as you. So maybe this can help if you still have the problem.

Installing Selected Parcels time out in CDH5

I'm trying to create a cluster after cloudera manager setup, and when Installing Selected Parcels, it stuck at activating giving the error timed out and the log gives the warning Parcel not distributed but have active state ACTIVATING.
please help, how to resolve this?
Error log
Unexpected exception during download
Traceback (most recent call last):
File "/opt/cloudera-manager/cm-5.5.3/lib/cmf/agent/src/cmf/downloader.py", line 276, in _download
response = self.opener.fetch_url(request)
File "/opt/cloudera-manager/cm-5.5.3/lib/cmf/agent/src/cmf/downloader.py", line 69, in fetch_url
return urllib2.urlopen(request)
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1187, in do_open
r = h.getresponse(buffering=True)
File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 415, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 371, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
timeout: timed out

suds to call SOAP over python

i'm quite desperate...can't use suds in my code...I try this
#!/usr/bin/python2
import suds
url = "http://scsadx02:8080/lrs/webconnect/vpsx?trid=vpsx"
client = suds.client.Client(url)
Server = client.factory.create("ns0:string")
Serverin = client.factory.create("ns0:string")
UserID = client.factory.create("ns0:string")
Password = client.factory.create("ns0:string")
NewPassword = client.factory.create("ns0:string")
Server.value = 'SPLVSVK2'
Serverin.value = 'SPLVPSK2'
UserID.value = 'serviceudp'
Password.value = 'dpuecivres'
NewPassword.value = ''
#method I have to call
#Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
#
#Service ( VPSXService ) tns="http://www.lrs.com"
# Prefixes (2)
# ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
# ns1 = "http://www.lrs.com"
# Ports (1):
# (VPSXPort)
# Methods (95):
# Logoff(xs:string SessID, )
# Logon(xs:string Server, xs:string UserID, xs:string Password, xs:string NewPassword, )
client.service.Logon(Server, UserID, Password, NewPassword)
but I obtain this error...
[davide#archy PYTHON]$ ./testina.py
Traceback (most recent call last):
File "./testina.py", line 31, in <module>
client.service.Logon(Server, UserID, Password, NewPassword)
File "/usr/lib/python2.7/site-packages/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/usr/lib/python2.7/site-packages/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/usr/lib/python2.7/site-packages/suds/client.py", line 637, in send
reply = transport.send(request)
File "/usr/lib/python2.7/site-packages/suds/transport/https.py", line 64, in send
return HttpTransport.send(self, request)
File "/usr/lib/python2.7/site-packages/suds/transport/http.py", line 77, in send
fp = self.u2open(u2request)
File "/usr/lib/python2.7/site-packages/suds/transport/http.py", line 118, in u2open
return url.open(u2request, timeout=tm)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
How I can solve???
Try
C:\Python27>python -c "import urllib2; print urllib2.urlopen('http://scsadx02:8080/lrs/webconnect/vpsx?trid=vpsx').read()"
and import os; os.environ['http_proxy']='' before importing the other modules.

Can't activate django admin screen

Error page shows the following:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.6/site-packages/django/core/handlers/wsgi.py", line 273, in call
response = self.get_response(request)
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 153, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception
return callback(request, **param_dict)
File "/Library/Python/2.6/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/Library/Python/2.6/site-packages/django/views/defaults.py", line 30, in server_error
t = loader.get_template(template_name) # You need to create a 500.html template.
File "/Library/Python/2.6/site-packages/django/template/loader.py", line 157, in get_template
template, origin = find_template(template_name)
File "/Library/Python/2.6/site-packages/django/template/loader.py", line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html
Check your Template_Loaders in settings.py. It should look like this to automatically find the default admin templates. The app_directories.Loader is important here.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

Resources