mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-16 12:12:57 -06:00
[FIX] protect paramiko imports (#130)
This commit is contained in:
parent
790c568b86
commit
901bf1525a
@ -1,7 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2016 Therp BV <http://therp.nl>
|
# © 2016 Therp BV <http://therp.nl>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from paramiko import SFTP_EOF, SFTPHandle
|
try:
|
||||||
|
from paramiko import SFTP_EOF, SFTPHandle
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
|
|
||||||
|
|
||||||
@ -14,6 +17,7 @@ class DocumentSFTPHandle(SFTPHandle):
|
|||||||
return self.attachment.env['document.sftp.root']._file(self.attachment)
|
return self.attachment.env['document.sftp.root']._file(self.attachment)
|
||||||
|
|
||||||
def read(self, offset, length):
|
def read(self, offset, length):
|
||||||
|
# pylint: disable=W8106
|
||||||
data = b64decode(self.attachment.datas)
|
data = b64decode(self.attachment.datas)
|
||||||
if offset > len(data):
|
if offset > len(data):
|
||||||
return SFTP_EOF
|
return SFTP_EOF
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2016 Therp BV <http://therp.nl>
|
# © 2016 Therp BV <http://therp.nl>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from paramiko import AUTH_SUCCESSFUL, AUTH_FAILED,\
|
try:
|
||||||
OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_SUCCEEDED,\
|
from paramiko import AUTH_SUCCESSFUL, AUTH_FAILED,\
|
||||||
RSAKey, ServerInterface
|
OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_SUCCEEDED,\
|
||||||
from paramiko.py3compat import decodebytes
|
RSAKey, ServerInterface
|
||||||
|
from paramiko.py3compat import decodebytes
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
from openerp.exceptions import AccessDenied
|
from openerp.exceptions import AccessDenied
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2016 Therp BV <http://therp.nl>
|
# © 2016 Therp BV <http://therp.nl>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from paramiko import SFTP_PERMISSION_DENIED, SFTPServerInterface, SFTPServer
|
try:
|
||||||
|
from paramiko import SFTP_PERMISSION_DENIED, SFTPServerInterface,\
|
||||||
|
SFTPServer
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
from openerp import api
|
from openerp import api
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# © 2016 Therp BV <http://therp.nl>
|
# © 2016 Therp BV <http://therp.nl>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
from paramiko import Transport
|
try:
|
||||||
from paramiko.transport import DEFAULT_WINDOW_SIZE, DEFAULT_MAX_PACKET_SIZE
|
from paramiko import Transport
|
||||||
|
from paramiko.transport import DEFAULT_WINDOW_SIZE, DEFAULT_MAX_PACKET_SIZE
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
from openerp import api, SUPERUSER_ID
|
from openerp import api, SUPERUSER_ID
|
||||||
from openerp.modules.registry import RegistryManager
|
from openerp.modules.registry import RegistryManager
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import paramiko
|
|||||||
from openerp import tools
|
from openerp import tools
|
||||||
from openerp.modules.registry import RegistryManager
|
from openerp.modules.registry import RegistryManager
|
||||||
from openerp.tests.common import TransactionCase
|
from openerp.tests.common import TransactionCase
|
||||||
from openerp.addons.document_sftp.models.document_sftp import _db2thread
|
from ..models.document_sftp import _db2thread
|
||||||
from ..hooks import post_init_hook
|
from ..hooks import post_init_hook
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user