intermediate check-in. Changes in remote.py and transporter.cfg added sftpapi

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2735 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
scrat 2008-07-03 21:56:29 +00:00
parent cea87a8225
commit 411c130300
3 changed files with 37 additions and 3 deletions

30
agent/system/sftpapi.py Normal file
View file

@ -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

View file

@ -12,3 +12,4 @@ transport.remote.server = 'testing'
transport.remote.url = 'http://localhost:8123' transport.remote.url = 'http://localhost:8123'
transport.remote.ftp.url = 'http://cy05.de' transport.remote.ftp.url = 'http://cy05.de'
transport.remote.ftp.user = 'scrat' transport.remote.ftp.user = 'scrat'
transport.remote.sftp = 'testing'

View file

@ -28,7 +28,7 @@ from twisted.internet import defer
from zope.interface import implements from zope.interface import implements
from cybertools.agent.system import rpcapi 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.base.agent import Master
from cybertools.agent.core.agent import QueueableAgent from cybertools.agent.core.agent import QueueableAgent
from cybertools.agent.interfaces import ITransporter from cybertools.agent.interfaces import ITransporter
@ -56,7 +56,7 @@ class Transporter(QueueableAgent):
config = master.config config = master.config
self.serverURL = config.transport.remote.url self.serverURL = config.transport.remote.url
self.server = rpcapi.xmlrpc.Proxy(self.serverURL) 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.method = params[method]
#self.machineName = params[machineName] #self.machineName = params[machineName]
#self.userName = params[userName] #self.userName = params[userName]
@ -71,7 +71,10 @@ class Transporter(QueueableAgent):
""" """
#return self.server.callRemote('getMetadata', resource.metadata) #return self.server.callRemote('getMetadata', resource.metadata)
self.deferred = defer.Deferred() 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 = self.server.callRemote('getMetadata', resource.metadata)
d.addCallback(self.transferDone) d.addCallback(self.transferDone)
d.addErrback(self.errorHandler) d.addErrback(self.errorHandler)