Django AllAuth generate_username_candidates NoneType issue - django-allauth

I'm trying to use AllAuth and dj-rest-auth to do facebook and google social login; however, when I submit via the /dj-rest-auth/google api, I get a 500 error with the following message:
File "/usr/local/lib/python3.10/site-packages/allauth/account/adapter.py", line 218, in generate_unique_username
return generate_unique_username(txts, regex)
File "/usr/local/lib/python3.10/site-packages/allauth/utils.py", line 107, in generate_unique_username
candidates = generate_username_candidates(basename)
File "/usr/local/lib/python3.10/site-packages/allauth/utils.py", line 93, in generate_username_candidates
max_suffix_length = min(get_username_max_length(), MAX_USERNAME_SUFFIX_LENGTH)
TypeError: '<' not supported between instances of 'int' and 'NoneType'
It seems like there is a problem with the AllAuth package based on this error. I've tried multiple different packages, but haven't had any luck. Any ideas what could be causing this?

Related

jira - 401 Client Error: Unauthorized for url

I'm creating a Slack bot to connect to Jira. The whole thing works on my local machine, however, when I deploy the server on a VM (Azure), it gives me this error. Any thoughts?
Error:
401 Client Error: Unauthorized for url: https://***.atlassian.net/rest/api/2/search?startAt=0&fields=%2Aall&jql=project%3Dtest
2022-11-09 17:31:40,851 - ERROR - slack_bolt.App - Failed to run listener function (error: Object of type HTTPError is not JSON serializable)
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_bolt/listener/thread_runner.py", line 120, in run_ack_function_asynchronously
listener.run_ack_function(request=request, response=response)
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_bolt/listener/custom_listener.py", line 50, in run_ack_function
return self.ack_function(
File "/home/ubuntu/flask/src/helpers/slack_controller.py", line 87, in handle_jira_action
sj_view_one(slack_app, body)
File "/home/ubuntu/flask/src/helpers/slack_jira_services.py", line 41, in sj_view_one
slack_app.client.views_open(trigger_id=body['trigger_id'], view={
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_sdk/web/client.py", line 4452, in views_open
return self.api_call("views.open", json=kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 156, in api_call
return self._sync_send(api_url=api_url, req_args=req_args)
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 187, in _sync_send
return self._urllib_api_call(
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 294, in _urllib_api_call
response = self._perform_urllib_http_request(url=url, args=request_args)
File "/home/ubuntu/.local/lib/python3.8/site-packages/slack_sdk/web/base_client.py", line 339, in _perform_urllib_http_request
body = json.dumps(args["json"])
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type HTTPError is not JSON serializable
After hours of research, I found the answer. There are two problems here:
First, Unauthorized.
This is a problem I have with Atlassian API. (Have a ticket opened for it, however, they couldn't help me with it yet).
Second, TypeError.
For fixing this, one way is to map the exception error to a string. For example:
try:
something()
exception Exception as error:
logger.error(str(error))
return str(error)
instead of returning the error, I sent str(error).

Retrieving SwissProt from ExPASy server - error

I've just started learning my way around Biopython and I'm trying to use ExPASy to retrieve SwissProt records, just like described in page 180 of the Biopython tutorial (http://biopython.org/DIST/docs/tutorial/Tutorial.pdf), but also in a relevant ROSALIND exercise (http://rosalind.info/problems/dbpr/ - click to expand the "Programming shortcut" section).
The code I'm using is basically the same as in the ROSALIND exercise:
from Bio import ExPASy
from Bio import SwissProt
handle = ExPASy.get_sprot_raw('Q5SLP9')
record = SwissProt.read(handle)
However, the SwissProt.read function gives the following error messages (I've trimmed some of the filepaths):
Traceback (most recent call last): File "code.py", line 4, in <module>
record = SwissProt.read(handle) File "lib\site-packages\Bio\SwissProt\__init__.py", line 151, in read
record = _read(handle) File "lib\site-packages\Bio\SwissProt\__init__.py", line 255, in _read
_read_ft(record, line) File "lib\site-packages\Bio\SwissProt\__init__.py", line 594, in _read_ft
assert not from_res and not to_res, line AssertionError: /note="Single-stranded DNA-binding protein"
I found this has been reported in GitHub (https://github.com/biopython/biopython/issues/2417), so I'm not the first one who gets this, but I don't really find any updated version of the package or any way to fix the issue. Maybe it's because I'm very new to using packages. Could someone help me please?
Please update your BioPython to version 1.77. The issue has been fixed with pull request 2484.

SeqIO.parse throwing error in genbank files

I'm working with some genbank seq files and have the following code:
for seq_record in SeqIO.parse("datafile_location, "genbank"):
And while it can run through most of the seqs in the seq file (which contains multiple seqs) I get the following error. Any thoughts about how to fix this?
Maybe delete the offending seq? It gets to record 92126 of 93145 and then throws the error.
I have tried re-downloading the seq file, but that doesn't fix the problem.
File "C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 516,
in parse_records record = self.parse(handle, do_features) File
"C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 499, in
parse if self.feed(handle, consumer, do_features): File
"C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 466, in
feed self._feed_header_lines(consumer, self.parse_header()) File
"C:\python38\lib\site-packages\Bio\GenBank\Scanner.py", line 1801, in
feed_header_lines previous_value_line = structured_comment_dict[ KeyError: 'Assembly-Data'
Seems similar like BioPython issue #2844.
A pull request was recently merged to address this.

element.set_value not working in python appium for fill the application form

I am trying to fill the data like name, email, and other details on android app using python appium client getting below error.
Appium server version -1.4.16.1
python appium client = 0.22 and 0.24
getting below error not getting ant resolution.
element.set_value('Test_Uder')
File "build\bdist.win-amd64\egg\appium\webdriver\webelement.py", line 123, in set_value
self._execute(Command.SET_IMMEDIATE_VALUE, data)
File "D:\vikas_python_venv\my_appium\lib\site-packages\selenium-3.7.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 501, in _execute
return self._parent.execute(command, params)
File "D:\vikas_python_venv\my_appium\lib\site-packages\selenium-3.7.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "build\bdist.win-amd64\egg\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
WebDriverException: Message: Not yet implemented. Please help us:
http://appium.io/get-involved.html
did you try using "send_keys" instead?
Something like this:
self.driver = webdriver.Remote('http://localhost:4723/wd/hub',
desired_caps)
self.driver.find_element_by_id(
'com.matchbook.client:id/editTextUsername').send_keys("username_here")
where "com.matchbook.client" is your package name, you can find element ID (com.matchbook.client:id/editTextUsername) using Appium Inspector which is included in Appium desktop app.

is it possible to catch 404 error without exit run in python?

I want to download a bunch of url list by:
urllib.request.urlretrieve(url, filename)
but sadly, few links are broken. and when urlretrieve meets that broken link
Traceback (most recent call last):
File "D:/Users/hyungsoo/PycharmProjects/untitled/check.py", line 71, in <module>
....blah_blah....
urllib.error.HTTPError: HTTP Error 404: Not Found
give me this error sign and program exited.
how to pass the broken url?
and moreover, is it possible to program tells me what link is broken?
You could try a "try...except..." statement, which you may find helpful. The "try" portion will attempt the given code, but the
"except" portion will be ready for the error message. It is really a wonderful feature. See teh following example:
while True:
... try:
... x = int(raw_input("Please enter a number: "))
... break
... except ValueError:
... print "Oops! That was no valid number. Try again..."
Note: Code taken from python APIs.

Resources