You are not logged in.
crushcoder
God
Gott hat die Welt ja nur in sieben Tagen erschaffen können, weil es keine installierte Basis gab.
Quoted from "realsmiley"
hmm, kann das programm mehr, als in der features-liste steht,
oder hat es wirklich nichts mit dem problem hier zu tun? ;D
crushcoder
God
Gott hat die Welt ja nur in sieben Tagen erschaffen können, weil es keine installierte Basis gab.
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
import ConfigParser import ftplib import sys class FTPUploader: """Upload files to ftp servers.""" def __init__(self): """Instanciate configuration file parser.""" self.cp = ConfigParser.RawConfigParser() self.cfg = {} print 'Creating ftp instance...', self.ftp = ftplib.FTP() print 'done.' def loadconfig(self, filename): """Parse configuration file.""" print 'Loading configuration file:', filename try: f = open(filename) self.cp.readfp(f) f.close() for key, value in self.cp.items('settings'): # print ' ', key, '=>', value self.cfg[key] = value print 'Configuration loaded.' except (IOError, ConfigParser.MissingSectionHeaderError), e: print 'Error:', e def uploadfiles(self, files): """Upload files to ftp server.""" try: print 'Connecting...', self.ftp.connect(self.cfg['host'], self.cfg['port']) print 'done.' print 'Welcome message:', self.ftp.getwelcome() print 'Loggin in...', self.ftp.login(self.cfg['user'], self.cfg['pass']) print 'done.' print 'Changing working directory to', self.cfg['path'], '...' self.ftp.cwd(self.cfg['path']) print 'Changed working directory to', self.ftp.pwd() print 'Uploading', str(len(files)), 'files...' for file in files: self.storefile(file) print 'Uploading files done.' except ftplib.all_errors, e: print 'Error:', e print 'Closing connection...', self.ftp.close() print 'done.' print 'Program finished.' def storefile(self, file): """Store an ascii file on the ftp server.""" print 'Opening local file...', f = open(file, 'r') print 'done.' print 'Storing file', file, 'on server...', self.ftp.storlines('STOR ' + file, f) print 'done.' print 'Closing local file...', f.close() print 'done.' if __name__ == '__main__': if len(sys.argv) < 3: print 'usage: %s <config file> <file to upload> [file to upload] ...' sys.exit(0) print 'Files:', ', '.join(sys.argv[2:]) fu = FTPUploader() fu.loadconfig(sys.argv[1]) fu.uploadfiles(sys.argv[2:]) |
![]() |
Source code |
1 2 3 4 5 6 7 8 |
# sample configuration file [settings] host = ftp.server.com port = 21 user = myusername pass = mypassword path = /home/myusername/ |
crushcoder
God
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?xml version="1.0" encoding="UTF-8"?> <project name="bookmarkSync" default="uploadOperaAdr"> <description>Upload bookmarks to FTP Server</description> <!-- DEFINITION --> <!-- Paw Props --> <property name="operaAdrFileLocation" location="C:\Programme\Opera" /> <property name="ftpServerName" value="somewhereWithoutFtpNSlashes" /> <property name="ftpServerUser" value="tester" /> <property name="ftpServerPassword" value="test" /> <property name="ftpServerDirectory" value="/software/tomcat/webapps/paw" /> <target name="uploadOperaAdr" description="..."> <echo message="=== Upoad the Bookmarks ===" /> <ftp binary="no" remotedir="${ftpServerDirectory}" depends="yes" verbose="yes" server="${ftpServerName}" userid="${ftpServerUser}" password="${ftpServerPassword}"> <fileset dir="${operaAdrFileLocation}"> <include name="opera6.adr" /> </fileset> </ftp> </target> </project> |
![]() |
Source code |
1 |
ant -f buildFileLocation |
Gott hat die Welt ja nur in sieben Tagen erschaffen können, weil es keine installierte Basis gab.
crushcoder
God
Gott hat die Welt ja nur in sieben Tagen erschaffen können, weil es keine installierte Basis gab.
-