From 400b0cd8f2233cccf27d989b06f323573834480e Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 28 May 2019 16:11:08 +0200 Subject: [PATCH] [11.0][MIG] base_directory_file_download --- base_directory_file_download/README.rst | 10 +++++----- base_directory_file_download/__init__.py | 1 - base_directory_file_download/__manifest__.py | 5 ++--- base_directory_file_download/models/__init__.py | 1 - .../models/ir_filesystem_directory.py | 3 +-- .../models/ir_filesystem_file.py | 8 ++++---- base_directory_file_download/tests/__init__.py | 1 - .../tests/test_directory_files_download.py | 6 +++--- 8 files changed, 15 insertions(+), 20 deletions(-) diff --git a/base_directory_file_download/README.rst b/base_directory_file_download/README.rst index 23290292d..2e81f4a4f 100644 --- a/base_directory_file_download/README.rst +++ b/base_directory_file_download/README.rst @@ -14,13 +14,13 @@ Directory Files Download :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/10.0/base_directory_file_download + :target: https://github.com/OCA/server-tools/tree/11.0/base_directory_file_download :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-10-0/server-tools-10-0-base_directory_file_download + :target: https://translation.odoo-community.org/projects/server-tools-11-0/server-tools-11-0-base_directory_file_download :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/149/10.0 + :target: https://runbot.odoo-community.org/runbot/149/11.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -63,7 +63,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -93,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/server-tools `_ project on GitHub. +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_directory_file_download/__init__.py b/base_directory_file_download/__init__.py index b44d76594..31660d6a9 100644 --- a/base_directory_file_download/__init__.py +++ b/base_directory_file_download/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import models diff --git a/base_directory_file_download/__manifest__.py b/base_directory_file_download/__manifest__.py index 52bd1f347..043eadc36 100644 --- a/base_directory_file_download/__manifest__.py +++ b/base_directory_file_download/__manifest__.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2017-2018 Onestein () +# Copyright 2017-2019 Onestein () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { @@ -8,7 +7,7 @@ 'author': 'Onestein, Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/server-tools', 'category': 'Tools', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'license': 'AGPL-3', 'depends': [ 'base_setup', diff --git a/base_directory_file_download/models/__init__.py b/base_directory_file_download/models/__init__.py index c88871f05..38cb57ad8 100644 --- a/base_directory_file_download/models/__init__.py +++ b/base_directory_file_download/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import ir_filesystem_directory diff --git a/base_directory_file_download/models/ir_filesystem_directory.py b/base_directory_file_download/models/ir_filesystem_directory.py index ddd615a67..4084cce58 100644 --- a/base_directory_file_download/models/ir_filesystem_directory.py +++ b/base_directory_file_download/models/ir_filesystem_directory.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2017-2018 Onestein () +# Copyright 2017-2019 Onestein () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import logging diff --git a/base_directory_file_download/models/ir_filesystem_file.py b/base_directory_file_download/models/ir_filesystem_file.py index bd875e21a..501d1d23e 100644 --- a/base_directory_file_download/models/ir_filesystem_file.py +++ b/base_directory_file_download/models/ir_filesystem_file.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- -# Copyright 2017-2018 Onestein () +# Copyright 2017-2019 Onestein () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 import logging import os @@ -43,14 +43,14 @@ class IrFilesystemDirectoryLine(models.TransientModel): if bin_size: r = human_size(os.path.getsize(full_path)) else: - r = open(full_path, 'rb').read().encode('base64') + r = base64.b64encode(open(full_path, 'rb').read()) except (IOError, OSError): _logger.info("_read_file reading %s", fname, exc_info=True) return r @api.depends('stored_filename') def _compute_file(self): - bin_size = self._context.get('bin_size') + bin_size = self.env.context.get('bin_size') for line in self: if line.stored_filename: content = line._file_read(line.stored_filename, bin_size) diff --git a/base_directory_file_download/tests/__init__.py b/base_directory_file_download/tests/__init__.py index 1375a4413..b940b19c3 100644 --- a/base_directory_file_download/tests/__init__.py +++ b/base_directory_file_download/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from . import test_directory_files_download diff --git a/base_directory_file_download/tests/test_directory_files_download.py b/base_directory_file_download/tests/test_directory_files_download.py index 7105c5a44..001392ef0 100644 --- a/base_directory_file_download/tests/test_directory_files_download.py +++ b/base_directory_file_download/tests/test_directory_files_download.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- -# Copyright 2017-2018 Onestein () +# Copyright 2017-2019 Onestein () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import base64 import os from tempfile import gettempdir @@ -36,7 +36,7 @@ class TestBaseDirectoryFilesDownload(common.TransactionCase): filename = file.stored_filename directory = test_dir.get_dir() with open(os.path.join(directory, filename), 'rb') as f: - content = f.read().encode('base64') + content = base64.b64encode(f.read()) self.assertEqual(file.file_content, content) # test onchange directory (to not existing)