eclipse - TypeError: file() argument 1 must be encoded string without NULL bytes, not str odoo -
the python version 2.8.2 , using in eclipse. getting error when trying execute following command:
the function is:
@api.one @api.depends('image') def _compute_image_details(self): if self.image: image_content = self.image.decode('base64') print type(self.image) print type(image_content) # file size self.size = len(image_content) # camera make , model exif tags img = pil.image.open(image_content) exif_tags = img._getexif() # 0x010f numeric code "make" exif field # can find list of fields here: exiv2.org/tags.html self.camera_maker = exif_tags.get(0x010f)
the error raised is:
traceback (most recent call last): file "/home/next/workspace/odoo-8.0/openerp/http.py", line 537, in _handle_exception return super(jsonrequest, self)._handle_exception(exception) file "/home/next/workspace/odoo-8.0/openerp/http.py", line 574, in dispatch result = self._call_function(**self.params) file "/home/next/workspace/odoo-8.0/openerp/http.py", line 310, in _call_function return checked_call(self.db, *args, **kwargs) file "/home/next/workspace/odoo-8.0/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) file "/home/next/workspace/odoo-8.0/openerp/http.py", line 307, in checked_call return self.endpoint(*a, **kw) file "/home/next/workspace/odoo-8.0/openerp/http.py", line 803, in __call__ return self.method(*args, **kw) file "/home/next/workspace/odoo-8.0/openerp/http.py", line 403, in response_wrap response = f(*args, **kw) file "/home/next/workspace/odoo-8.0/addons/web/controllers/main.py", line 944, in call_kw return self._call_kw(model, method, args, kwargs) file "/home/next/workspace/odoo-8.0/addons/web/controllers/main.py", line 936, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) file "/home/next/workspace/odoo-8.0/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) file "/home/next/workspace/odoo-8.0/openerp/api.py", line 363, in old_api result = method(recs, *args, **kwargs) file "/home/next/workspace/odoo-8.0/openerp/models.py", line 5873, in onchange newval = record[name] file "/home/next/workspace/odoo-8.0/openerp/models.py", line 5571, in __getitem__ return self._fields[key].__get__(self, type(self)) file "/home/next/workspace/odoo-8.0/openerp/fields.py", line 820, in __get__ self.determine_draft_value(record) file "/home/next/workspace/odoo-8.0/openerp/fields.py", line 928, in determine_draft_value self._compute_value(record) file "/home/next/workspace/odoo-8.0/openerp/fields.py", line 867, in _compute_value self.compute(records) file "/home/next/workspace/odoo-8.0/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) file "/home/next/workspace/odoo-8.0/openerp/api.py", line 397, in new_api result = [method(rec, *args, **kwargs) rec in self] file "/home/next/workspace/odoo-8.0/addons/transform_webservice_example/image_example.py", line 33, in _compute_image_details img = pil.image.open(image_content) file "/usr/lib/python2.7/dist-packages/pil/image.py", line 1955, in open fp = __builtin__.open(fp, "rb") typeerror: file() argument 1 must encoded string without null bytes, not str
please me issue.
the other references url of file. different scenario.
you're trying open base64 decoded contents of file, you're supposed open file itself.
pil.image.open(self.image)
take example, reproduce error you're getting
>>> open('\0') traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: file() argument 1 must encoded string without null bytes, not str >>>
the character '\0'
seen nullbyte
decoded image contains
Comments
Post a Comment