천정현 2009. 4. 3. 14:46

snpsftp Module

This module simplifies the use of FTP (File Transfer Protocol) with Jython

Using Jython in Oracle Data Integrator

It implements the class SnpsFTP

SnpsFTP Class

Constructor / Methode Description



SnpsFTP([host [,user [,passwd[, acct[, port]]]]]) Constructor: creates an ftp object and connects to the host FTP server on port number port using user, passwd and acct for the authentication.
connect(host [,port]) Connects to the FTP host server on port number port
login([user [,passwd [,acct]]]) Performs authentication against the FTP server.
setmode(mode) Sets the mode to ASCII or BINARY. Possible values are: 'ASCII' or 'BINARY'. The default value for transfers is ASCII.
setpassive(0 | 1) Sets the FTP connection in passive (1) or active (0) mode.
get(src[, dest [, mode]]) Downloads the file described with its full path src (on the FTP erver) into the file or directory dest. The mode can be forced to 'ASCII' or 'BINARY'.
mget(srcdir, pattern [, destdir [,mode]]) Downloads a set of files from the directory srcdir that matches the filter pattern in the directory destdir using the mode mode.
put(src [, dest [, mode='' [, blocksize=8192]]]) Puts the local file src in the server file dest using the mode mode. Uses a bloc transfer size of blocksize bytes.
mput(srcdir, pattern [, destdir [,mode [, blocksize=8192]]]) Puts several local files from the directory srcdir that match the filter pattern into the server directory destdir using the mode mode. Uses a transfer bloc size of blocksize octets.
quit() Sends a QUIT command, then closes the connection with the FTP server.
close() Closes the connection with the FTP server.

Examples
Retrieve the *.txt files from /home/odi on the server ftp.myserver.com in the local directory c:\temp

import snpsftp
ftp = snpsftp.SnpsFTP('ftp.myserver.com', 'mylogin', 'mypasswd')
ftp.setmode('ASCII')
ftp.mget('/home/odi', '*.txt', 'c:/temp')
ftp.close()


Put the *.zip files from C:\odi\lib onto the server'ftp.myserver.com in the remote
directory /home/odi/lib

import snpsftp
ftp = snpsftp.SnpsFTP('ftp.myserver.com', 'mylogin', 'mypasswd')
ftp.setmode('BINARY')
ftp.mput('C:/odi/lib', '*.zip', '/home/odi/lib')
ftp.close()