[FIX] protect paramiko imports (#130)

This commit is contained in:
Holger Brunn 2017-04-02 22:10:06 +02:00 committed by Pedro M. Baeza
parent 790c568b86
commit 901bf1525a
5 changed files with 23 additions and 9 deletions

View File

@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# 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
@ -14,6 +17,7 @@ class DocumentSFTPHandle(SFTPHandle):
return self.attachment.env['document.sftp.root']._file(self.attachment)
def read(self, offset, length):
# pylint: disable=W8106
data = b64decode(self.attachment.datas)
if offset > len(data):
return SFTP_EOF

View File

@ -1,10 +1,13 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from paramiko import AUTH_SUCCESSFUL, AUTH_FAILED,\
OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_SUCCEEDED,\
RSAKey, ServerInterface
from paramiko.py3compat import decodebytes
try:
from paramiko import AUTH_SUCCESSFUL, AUTH_FAILED,\
OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_SUCCEEDED,\
RSAKey, ServerInterface
from paramiko.py3compat import decodebytes
except ImportError:
pass
from openerp.exceptions import AccessDenied

View File

@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# 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

View File

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from paramiko import Transport
from paramiko.transport import DEFAULT_WINDOW_SIZE, DEFAULT_MAX_PACKET_SIZE
try:
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.modules.registry import RegistryManager

View File

@ -6,7 +6,7 @@ import paramiko
from openerp import tools
from openerp.modules.registry import RegistryManager
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