You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
763 B

  1. # coding: utf-8
  2. # @ 2016 Florian DA COSTA @ Akretion
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import logging
  5. _logger = logging.getLogger(__name__)
  6. try:
  7. from fs import sftpfs
  8. except ImportError:
  9. _logger.debug('Cannot `import fs`.')
  10. class SftpTask(sftpfs.SFTPFS):
  11. _key = 'sftp'
  12. _name = 'SFTP'
  13. _synchronize_type = None
  14. _default_port = 22
  15. _hide_login = False
  16. _hide_password = False
  17. _hide_port = False
  18. @staticmethod
  19. def connect(location):
  20. connection_string = "{}:{}".format(location.address, location.port)
  21. conn = SftpTask(connection=connection_string,
  22. username=location.login,
  23. password=location.password)
  24. return conn