"NameError" when trying to upload a new NumberSet from excel
Closed this issue · 17 comments
Tried to upload a Number Set with BIB and License headers, but received "NameError" :
name 'ms_write' is not defined
NameError
name 'ms_write' is not defined
/RaceDB/core/init_number_set.py, line 94, in init_number_set
/usr/local/bin/python
3.9.7
['/RaceDB', '/RaceDB', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages', '/RaceDB/src/pyllrp']
I've updated to the latest release, but for some reason Firefox does not want to open the "http://localhost:8000/RaceDB/Login/?next=/RaceDB/" path as it used to. Did the upgrade change something to the firewall settings (Windows 10)? I get the below error message:
**_The connection was reset
The connection to the server was reset while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web._**
Hi Ed, it seems to be with the security setting of the application launch path (http & https). The browser path to open from Docker is:
"http://localhost:8000/RaceDB/Login/?next=/RaceDB/" and I've tried all the web browsers (Firefox / Chrome / MS Edge) and all if them throws out a "You are not securely connected to this site". I've googled and tried various options to allow a "http" connection setting (firewall off etc), but to no avail. Any other suggestions?
I also found that when I open the "http://localhost:8000/RaceDB/Login/?next=/RaceDB/" path, it restarts the running of the racedb_app in Docker. It does not restart the postgresql_racedb_app. With my database quite big, I normally let docker/RaceDB run for at least 5 minutes before I open the browser path, otherwise I also get a error message. Now that the opening of the browser path/or refreshing it restarts the app, it does not reach the required running time (+- 5 minutes) to enable me to access the database.
I've read on Stack overflow about "bind-address" :
Where you have host: 'localhost' in your server declaration, does changing that to host: '0.0.0.0' help? That matches the bind-address option you've seen elsewhere.
Could this maybe be the problem?
Also here (https://stackoverflow.com/questions/60183313/the-connection-was-reset-in-localhost8000-using-django-and-docker) they discussed the error I received - but I have no idea where to make theses adjustments.
The racedb_app image is restarting every 2min 5sec. The postgresql_racedb_app keeps on running. Below is the Docker log file for the racedb_app. It seems that there is an import error as well as that "TESTING" was not set?
Docker log file
logFileName="/racedb-data/RaceDB-log.txt"
Traceback (most recent call last):
File "/RaceDB/manage.py", line 38, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/init.py", line 425, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/init.py", line 263, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python3.9/site-packages/django/core/management/init.py", line 39, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/RaceDB/core/management/commands/launch.py", line 16, in
import RaceDB.urls
File "/RaceDB/RaceDB/urls.py", line 1, in
from django.conf.urls import include, re_path
ImportError: cannot import name 're_path' from 'django.conf.urls' (/usr/local/lib/python3.9/site-packages/django/conf/urls/init.py)
/usr/sbin/entrypoint.sh: sourcing bash script: /docker-entrypoint-init.d/40-import.sh
No SQLITE data to import from /racedb-data/RaceDB.sqlite3
No JSON data to import from /racedb-data/racedb-import.json
/usr/sbin/entrypoint.sh: sourcing bash script: /docker-entrypoint-init.d/95-start.sh
Starting RaceDB...
RaceDB exited with code 1.
/usr/sbin/entrypoint.sh: sourcing bash script: /docker-entrypoint-init.d/99-zdontstart.sh
TESTING not set. Exiting normally...
Shutting down in 10 secs!
Running init scripts stored in /docker-entrypoint-init.d
/usr/sbin/entrypoint.sh: sourcing bash script: /docker-entrypoint-init.d/01-logstart.sh >
The new update (RaceDB v3.0.76-20220115145857) worked like a dream, thank you. I future I will keep an eye open for changes when Docker updates. Thank you once again. I will close this issue now.
Apologies. The database now runs but the "Number Set" upload gives the below error:
Environment:
Request Method: POST
Request URL: http://localhost:8000/RaceDB/NumberSets/NumberSetManage/11/NumberSetUploadExcel/11/
Django Version: 4.0.1
Python Version: 3.9.9
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'crispy_forms',
'core')
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 (most recent call last):
File "/RaceDB/core/init_number_set.py", line 92, in init_number_set
message_stream_write( 'Reading sheet "{}"\n'.format(sheet_name) )
During handling of the above exception (name 'message_stream_write' is not defined), another exception occurred:
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/RaceDB/core/views_common.py", line 108, in wrap
response = response or decorated_func( request, *args, **kwargs )
File "/RaceDB/core/WriteLog.py", line 90, in new_f
return f( *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/RaceDB/core/number_set.py", line 182, in UploadNumberSet
results_str = handle_upload_number_set( numberSetId, request.FILES['excel_file'] )
File "/RaceDB/core/number_set.py", line 166, in handle_upload_number_set
init_number_set(
File "/RaceDB/core/init_number_set.py", line 94, in init_number_set
message_stream_write( 'Cannot find sheet "{} ({})"\n'.format(sheet_name, e) )
Exception Type: NameError at /RaceDB/NumberSets/NumberSetManage/11/NumberSetUploadExcel/11/
Exception Value: name 'message_stream_write' is not defined
I've upgraded but it gives a 'int' object has no attribute 'lower' error. Below is the error log.
Environment:
Request Method: POST
Request URL: http://localhost:8000/RaceDB/NumberSets/NumberSetManage/18/NumberSetUploadExcel/18/
Django Version: 4.0.1
Python Version: 3.9.9
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'crispy_forms',
'core')
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 (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/RaceDB/core/views_common.py", line 108, in wrap
response = response or decorated_func( request, *args, **kwargs )
File "/RaceDB/core/WriteLog.py", line 90, in new_f
return f( *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/RaceDB/core/number_set.py", line 182, in UploadNumberSet
results_str = handle_upload_number_set( numberSetId, request.FILES['excel_file'] )
File "/RaceDB/core/number_set.py", line 166, in handle_upload_number_set
init_number_set(
File "/RaceDB/core/init_number_set.py", line 106, in init_number_set
fields_lower = set( f.lower() for f in fields.keys() )
File "/RaceDB/core/init_number_set.py", line 106, in
fields_lower = set( f.lower() for f in fields.keys() )
Exception Type: AttributeError at /RaceDB/NumberSets/NumberSetManage/18/NumberSetUploadExcel/18/
Exception Value: 'int' object has no attribute 'lower'
Hi Edward, you've spend enough time on this already, it is not urgent. It seems that although the column headers "Bib" & "License" are in the upload file, the application do not accept it. See below screen shot:
**
Reading sheet "RedMen" Header Row: License Bib License column not found in Header Row. Aborting.
Import a Number Set from Excel.
Adds or Updates Bib Numbers in the number set.
The Excel spreadsheet must consist of a Bib column, and a License column. All other colums are ignored.
Column | Description |
---|---|
Bib or Bib Number | Optional. Bib number for the rider. |
License or License Code or License Numbers | Required. License code (not UCI code). If the License Code is empty, the Bib will be marked as Lost. |
Worked perfect! Thank you Edward.