mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 10:28:40 -06:00
Fix flake8
This commit is contained in:
parent
5f9e5b1f44
commit
2c461fdffe
@ -6,6 +6,11 @@ from base64 import b64encode
|
|||||||
|
|
||||||
class AbstractTask(object):
|
class AbstractTask(object):
|
||||||
|
|
||||||
|
_name = None
|
||||||
|
_key = None
|
||||||
|
_synchronize_type = None
|
||||||
|
_default_port = None
|
||||||
|
|
||||||
def create_file(self, filename, data):
|
def create_file(self, filename, data):
|
||||||
ir_attachment_id = self.env['ir.attachment.metadata'].create({
|
ir_attachment_id = self.env['ir.attachment.metadata'].create({
|
||||||
'name': filename,
|
'name': filename,
|
||||||
|
@ -50,10 +50,9 @@ class Task(models.Model):
|
|||||||
return [('move', 'Move'), ('delete', 'Delete')]
|
return [('move', 'Move'), ('delete', 'Delete')]
|
||||||
|
|
||||||
def _get_method(self):
|
def _get_method(self):
|
||||||
print 'get method'
|
|
||||||
res = []
|
res = []
|
||||||
for cls in itersubclasses(AbstractTask):
|
for cls in itersubclasses(AbstractTask):
|
||||||
if cls._synchronize_type: #\
|
if cls._synchronize_type: # \
|
||||||
# and cls._key == self._context.get('protocol'):
|
# and cls._key == self._context.get('protocol'):
|
||||||
cls_info = (cls._key + '_' + cls._synchronize_type,
|
cls_info = (cls._key + '_' + cls._synchronize_type,
|
||||||
cls._name + ' ' + cls._synchronize_type)
|
cls._name + ' ' + cls._synchronize_type)
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from ..abstract_task import AbstractTask
|
from ..abstract_task import AbstractTask
|
||||||
from base64 import b64decode
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@ -31,6 +30,7 @@ class AbstractFSTask(AbstractTask):
|
|||||||
_name = None
|
_name = None
|
||||||
_key = None
|
_key = None
|
||||||
_synchronize_type = None
|
_synchronize_type = None
|
||||||
|
_default_port = None
|
||||||
|
|
||||||
def __init__(self, env, config):
|
def __init__(self, env, config):
|
||||||
self.env = env
|
self.env = env
|
||||||
@ -127,7 +127,8 @@ class AbstractFSTask(AbstractTask):
|
|||||||
def _target_name(self, fs_conn, upload_directory, filename):
|
def _target_name(self, fs_conn, upload_directory, filename):
|
||||||
return os.path.join(upload_directory, filename)
|
return os.path.join(upload_directory, filename)
|
||||||
|
|
||||||
def _upload_file(self, conn, host, port, user, pwd, path, filename, filedata):
|
def _upload_file(self, conn, host, port, user, pwd,
|
||||||
|
path, filename, filedata):
|
||||||
upload_directory = path or '.'
|
upload_directory = path or '.'
|
||||||
target_name = self._target_name(conn,
|
target_name = self._target_name(conn,
|
||||||
upload_directory,
|
upload_directory,
|
||||||
|
@ -21,11 +21,8 @@
|
|||||||
|
|
||||||
from .abstract_fs import AbstractFSTask
|
from .abstract_fs import AbstractFSTask
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
import fs
|
|
||||||
from fs.osfs import OSFS
|
from fs.osfs import OSFS
|
||||||
from ftputil.error import FTPIOError
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +67,7 @@ class FileStoreExportTask(FileStoreTask):
|
|||||||
for attachment in self.attachment_ids:
|
for attachment in self.attachment_ids:
|
||||||
if attachment.state in ('pending', 'failed'):
|
if attachment.state in ('pending', 'failed'):
|
||||||
self.attachment_id = attachment
|
self.attachment_id = attachment
|
||||||
with OSFS(host) as fs_conn:
|
with OSFS(self.host) as fs_conn:
|
||||||
self._upload_file(fs_conn,
|
self._upload_file(fs_conn,
|
||||||
self.host,
|
self.host,
|
||||||
self.port,
|
self.port,
|
||||||
|
@ -23,7 +23,6 @@ from .abstract_fs import AbstractFSTask
|
|||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from fs.ftpfs import FTPFS
|
from fs.ftpfs import FTPFS
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ from .abstract_fs import AbstractFSTask
|
|||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
from fs.sftpfs import SFTPFS
|
from fs.sftpfs import SFTPFS
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -72,8 +71,7 @@ class SftpExportTask(SftpTask):
|
|||||||
if attachment.state in ('pending', 'failed'):
|
if attachment.state in ('pending', 'failed'):
|
||||||
self.attachment_id = attachment
|
self.attachment_id = attachment
|
||||||
connection_string = "{}:{}".format(self.host, self.port)
|
connection_string = "{}:{}".format(self.host, self.port)
|
||||||
root = "/home/{}".format(self.user)
|
with SFTPFS(connection=connection_string,
|
||||||
with SFTPFS(connection=connection_string, root_path=root,
|
|
||||||
username=self.user,
|
username=self.user,
|
||||||
password=self.pwd) as sftp_conn:
|
password=self.pwd) as sftp_conn:
|
||||||
self._upload_file(sftp_conn, self.host, self.port,
|
self._upload_file(sftp_conn, self.host, self.port,
|
||||||
|
Loading…
Reference in New Issue
Block a user