diff --git a/agent/system/sftpapi.py b/agent/system/sftpapi.py new file mode 100644 index 0000000..d393655 --- /dev/null +++ b/agent/system/sftpapi.py @@ -0,0 +1,30 @@ +# +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Configuration controlled import of sftp functionality + +$Id: rpcapi.py +""" + +def setup(config): + global FileTransfer + if config.transport.remote.sftp == 'testing': + from cybertools.agent.testing.sftp import FileTransfer + else: + from cybertools.agent.transport.file.sftp import FileTransfer \ No newline at end of file diff --git a/agent/testing/transporter.cfg b/agent/testing/transporter.cfg index bcad40a..ad968bb 100644 --- a/agent/testing/transporter.cfg +++ b/agent/testing/transporter.cfg @@ -12,3 +12,4 @@ transport.remote.server = 'testing' transport.remote.url = 'http://localhost:8123' transport.remote.ftp.url = 'http://cy05.de' transport.remote.ftp.user = 'scrat' +transport.remote.sftp = 'testing' diff --git a/agent/transport/remote.py b/agent/transport/remote.py index 3336860..40e6f55 100644 --- a/agent/transport/remote.py +++ b/agent/transport/remote.py @@ -28,7 +28,7 @@ from twisted.internet import defer from zope.interface import implements from cybertools.agent.system import rpcapi -#from cybertools.agent.system import sftpapi +from cybertools.agent.system import sftpapi from cybertools.agent.base.agent import Master from cybertools.agent.core.agent import QueueableAgent from cybertools.agent.interfaces import ITransporter @@ -56,7 +56,7 @@ class Transporter(QueueableAgent): config = master.config self.serverURL = config.transport.remote.url self.server = rpcapi.xmlrpc.Proxy(self.serverURL) - #self.ftpServer = FileTransfer(host, port, username, password) + self.ftpServer = sftpapi.FileTransfer(host, port, username, password) #self.method = params[method] #self.machineName = params[machineName] #self.userName = params[userName] @@ -71,7 +71,10 @@ class Transporter(QueueableAgent): """ #return self.server.callRemote('getMetadata', resource.metadata) self.deferred = defer.Deferred() - # d = self.ftpServer.upload() + # here the filename is to be specified for the remote path + # the filename has to be created artificially by the tempfile + # mechanism? + d = self.ftpServer.upload(resource.path, 'remote') d = self.server.callRemote('getMetadata', resource.metadata) d.addCallback(self.transferDone) d.addErrback(self.errorHandler)