ИМ
Игорь МаксимовDec. 9, 2018, 1:55 p.m.
a bytes-like object is required, not 'str' в videokit
Доброго времени суток. Нашел приложение для конвертации видео + celery что очень радует. Не радует только то что оно отказывается работать под python3
Трейсбек прикладываю:
File "/home/django/venv/example/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner response = get_response(request) File "/home/django/venv/example/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/django/venv/example/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/django/example/media/views.py", line 32, in item_create media_item.save() File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/base.py", line 796, in save force_update=force_update, update_fields=update_fields) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/base.py", line 824, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/base.py", line 908, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/base.py", line 947, in _do_insert using=using, raw=raw) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/query.py", line 1045, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1053, in execute_sql for sql, params in self.as_sql(): File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1006, in as_sql for obj in self.query.objs File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1006, in <listcomp> for obj in self.query.objs File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1005, in <listcomp> [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields] File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 955, in pre_save_val return field.pre_save(obj, add=True) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/fields/files.py", line 292, in pre_save file.save(file.name, file, save=False) File "/home/django/venv/example/lib/python3.5/site-packages/django/db/models/fields/files.py", line 92, in save setattr(self.instance, self.field.name, self.name) File "/home/django/example/videokit/fields.py", line 198, in __set__ self.field.update_dimension_fields(instance, force = True) File "/home/django/example/videokit/models.py", line 119, in update_dimension_fields width = file.width File "/home/django/example/videokit/fields.py", line 133, in _get_width return self._get_video_dimensions()[0] File "/home/django/example/videokit/fields.py", line 164, in _get_video_dimensions self._dimensions_cache = get_video_dimensions(self) File "/home/django/example/videokit/fields.py", line 25, in get_video_dimensions width = stdout.strip(' \t\n\r') TypeError: a bytes-like object is required, not 'str' [09/Dec/2018 18:34:05] "POST /item_create/ HTTP/1.1" 500 151897
И функцию в которой ошибка:
from django.conf import settings from django.core.files import File from django.db.models.fields.files import FieldFile from django.db.models.fields.files import FileDescriptor from datetime import datetime import hashlib import os.path import subprocess from videokit.apps import VideokitConfig from videokit.tasks import generate_video def get_video_dimensions(file): path = os.path.join(settings.MEDIA_ROOT, file.name) if os.path.isfile(path): try: process = subprocess.Popen( ['mediainfo', '--Inform=Video;%Width%', path], stdout = subprocess.PIPE, stderr = subprocess.PIPE) stdout, stderr = process.communicate() if process.wait() == 0: width = int(stdout.strip(' \t\n\r')) else: return (0,0) process = subprocess.Popen( ['mediainfo', '--Inform=Video;%Height%', path], stdout = subprocess.PIPE, stderr = subprocess.PIPE) stdout, stderr = process.communicate() if process.wait() == 0: height = int(stdout.strip(' \t\n\r')) else: return (None, None) return (width, height) except OSError: pass return (None, None)
Очень надеюсь на вашу помощь. Заранее благодарен.
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
AD
- Akiv Doros
- Nov. 11, 2024, 2:58 p.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:50points,
- Rating points-4
m
- molni99
- Oct. 26, 2024, 1:37 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
m
- molni99
- Oct. 26, 2024, 1:29 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:20points,
- Rating points-10
Last comments
Qt/C++ - Lesson 065. The correspondence of HTTP errors to server response errors in QNetworkAccessManager s Midsummer Classic in Kansas City priligy online pharmacy
Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column? Many OPKs would advise users to start using the test strips around day 9 of your cycle, considering day 1 to be the first day of full menstrual flow buy priligy australia
Release of C++/Qt and QML application deployment utility CQtDeployer v1.4.0 (Binary Box) optionally substituted alkoxy, optionally substituted alkenyloxy, optionally substituted alkynyloxy, optionally substituted aryloxy, OCH, OC H, OC H, OC H, OC H, OC H, OC H, O C CH, OCH CH OH, O…
Qt/C++ - Lesson 031. QCustomPlot – The build of charts with time buy generic priligy We can just chat, and we will not lose too much time anyway
Qt/C++ - Lesson 060. Configuring the appearance of the application in runtime I didnt have an issue work colors priligy dapoxetine 60mg revia cost uk August 3, 2022 Reply
Now discuss on the forum
t
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
tonypeachey1Nov. 15, 2024, 6:04 a.m.
добавить qlineseries в функции priligy for sale Gently flush using an ear syringe
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
IscanderCheOct. 31, 2024, 3:43 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…
Добрый день!
Вам не нужно было сначала считать это всё из stdout?
Автор кода не я. Решение нашел на одном забугорном ресурсе.
Все работает, но я не уверен что это правильное решение. Что скажете?
Если не ошибаюсь, то decode должен возвращать str в с декодированием из utf8 в данном случае, а потом вы вырезаете лишние элементы, так что всё правильно на мой взгляд. Ну и напоследок преобразуете строку в int. В принципе всё верно. Не вижу причин, чтобы данный код был неправильным.
Спасибо за пояснение.