Не скачиваются книги
6 years 7 months ago - 6 years 7 months ago #2122
by Nevskiy
Nevskiy created the topic: Не скачиваются книги
Добрый день!
При попытке скачать книги получаю ошибку питона
Помогите починить, пожалуйста. Спасибо
При попытке скачать книги получаю ошибку питона
UnicodeEncodeError at /opds/download/2008/0/
'ascii' codec can't encode characters in position 13-20: ordinal not in range(128)
Request Method: GET
Request URL: http://172.16.0.115/opds/download/2008/0/
Django Version: 2.0.6
Exception Type: UnicodeEncodeError
Exception Value:
'ascii' codec can't encode characters in position 13-20: ordinal not in range(128)
Exception Location: /usr/lib/python3.6/genericpath.py in getsize, line 50
Python Executable: /usr/bin/python3
Python Version: 3.6.5
Python Path:
['/var/www/.virtualenvs/sopdsenv/lib/python3.6/site-packages',
'/var/www/sopds',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages',
'/var/www/.virtualenvs/sopdsenv/local/lib/python3.6/site-packages',
'/var/www/sopds',
'/var/www/sopds/sopds']
Помогите починить, пожалуйста. Спасибо
Last Edit: 6 years 7 months ago by Nevskiy.
Please Войти or Create an account to join the conversation.
- Nevskiy
-
Topic Author
- Offline
- Новый участник
-
Less
More
- Posts: 7
6 years 7 months ago - 6 years 7 months ago #2123
by mitshel
mitshel replied the topic: Не скачиваются книги
Как работает сервер - встроенный (python3 manage.py sopds_server) или используете Apache или Nginx?
Last Edit: 6 years 7 months ago by mitshel.
Please Войти or Create an account to join the conversation.
- mitshel
-
- Offline
- Администратор
-
Less
More
- Posts: 297
- Karma: 8
6 years 7 months ago - 6 years 7 months ago #2124
by Nevskiy
Nevskiy replied the topic: Не скачиваются книги
Apache 2.4.
И еще все обложки пропали.
Ошибка вчера появилась, после обновления системы.
И еще все обложки пропали.
Ошибка вчера появилась, после обновления системы.
Environment:
Request Method: GET
Request URL: http://172.16.0.115/opds/download/2268/0/
Django Version: 2.0.6
Python Version: 3.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'opds_catalog',
'sopds_web_backend',
'django.contrib.admin',
'django.contrib.staticfiles',
'constance.backends.database',
'constance']
Installed Middleware:
['django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'opds_catalog.middleware.SOPDSLocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/var/www/.virtualenvs/sopdsenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/var/www/.virtualenvs/sopdsenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/var/www/.virtualenvs/sopdsenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/sopds/opds_catalog/dl.py" in Download
181. book_size=os.path.getsize(file_path)
File "/usr/lib/python3.6/genericpath.py" in getsize
50. return os.stat(filename).st_size
Exception Type: UnicodeEncodeError at /opds/download/2268/0/
Exception Value: 'ascii' codec can't encode characters in position 13-19: ordinal not in range(128)
Last Edit: 6 years 7 months ago by Nevskiy.
Please Войти or Create an account to join the conversation.
- Nevskiy
-
Topic Author
- Offline
- Новый участник
-
Less
More
- Posts: 7
6 years 7 months ago - 6 years 7 months ago #2125
by mitshel
mitshel replied the topic: Не скачиваются книги
Думаю проблема настройке вашей системы. А конкретно Apache не использует кодировку UTF-8. Посмотрите в вашем конфигурационном файле есть чтото вроде этого:
WSGIDaemonProcess sopds processes=2 threads=15 python-path=/home/apache/sopds/ lang='en_US.UTF-8' locale='en_US.UTF-8'
WSGIDaemonProcess sopds processes=2 threads=15 python-path=/home/apache/sopds/ lang='en_US.UTF-8' locale='en_US.UTF-8'
Last Edit: 6 years 7 months ago by mitshel.
Please Войти or Create an account to join the conversation.
- mitshel
-
- Offline
- Администратор
-
Less
More
- Posts: 297
- Karma: 8
6 years 7 months ago #2126
by Nevskiy
Nevskiy replied the topic: Не скачиваются книги
Добавил строчку lang='en_US.UTF-8' locale='en_US.UTF-8' в свой cfg. Не помогло
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
#ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
ServerAdmin lib@localhost
ServerName sopds.local
ErrorLog /var/log/apache2/sopds_error.log
WSGIScriptAlias / /var/www/sopds/sopds/wsgi.py
WSGIDaemonProcess sopds processes=2 threads=15 python-path=/var/www/sopds lang='en_US.UTF-8' locale='en_US.UTF-8'
WSGIProcessGroup sopds
WSGIScriptReloading On
WSGIPassAuthorization On
<Directory "/var/www/sopds/sopds/">
Require all granted
</Directory>
<Directory "/var/www/sopds/static/">
Require all granted
</Directory>
Alias /static "/var/www/sopds/static"
</VirtualHost>
root@lib:~# locale
LANG=ru_RU.UTF-8
LANGUAGE=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
Please Войти or Create an account to join the conversation.
- Nevskiy
-
Topic Author
- Offline
- Новый участник
-
Less
More
- Posts: 7
6 years 7 months ago #2127
by mitshel
mitshel replied the topic: Не скачиваются книги
Ну попробуйте сами в настройкаха Apacha поковырятся, чтобы он UTF-8 использовать мог.
habr.com/post/130511/
stackoverflow.com/questions/913869/how-t...-to-utf-8-for-apache
habr.com/post/130511/
stackoverflow.com/questions/913869/how-t...-to-utf-8-for-apache
Please Войти or Create an account to join the conversation.
- mitshel
-
- Offline
- Администратор
-
Less
More
- Posts: 297
- Karma: 8
Time to create page: 0.103 seconds