I
isabellknauer
Hey!
Ive been working on an application quite some time now and i wanted to
include something to let the user load a new version. i therefore
tried to include this here:
from ftplib import FTP
import string,re
def handleDownload(block):
processfile.write(block)
print ".",
def load_new_version(old_version):
host='host.bla'
user='usr_ftp_76512'
password='45mhBLl3lXRX.332'
account='usr_ftp_76512'
download=''
directory = 'htdocs'
server = FTP(host)
server.login(user,password,account)
server.cwd(directory)
filelist=server.retrlines('LIST')
#okay this works :logged into the ftpserver,changed dir and now have a
#string that tells the files like this:
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 14454 Dec 5 14:10
Pict5.2.2.jpg
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 16174 Dec 5 12:37 Picture
3.jpg
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 14139 Dec 5 12:38 Picture
6.jpg
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 42713 Dec 5 12:38 Picture
7.jpg
#226 Transfer complete.
print filelist
files=re.findall(' .{2,20}[.][a-z]{3,3}', filelist,re.I|re.S)
#the dot means every char, because of the flag re.S
# re.I ignores case
#{2,20} this means 2 to twenty of the char that is before it
#heres the problem... if you copy the output and put it into a string
he
#finds all the files with findall, but not inside here... and i dont
get why
#help
print files
for file in files:
number=re.findall('pict([0-9])[.]([0-9])[.]?
([0-9]?)',file,re.I)
version=100*int(number[0][0])+ 10*int(number[0][1])+ int(number
[0][2])
if version >old_version:
print version
print old_version
old_version=version
download=file
if download :
processfile = open(download, 'wb')
server.retrbinary('RETR ' + download, handleDownload)
processfile.close()
server.close()
return True
else:
server.close()
return False
load_new_version(201)
#greetz
Ive been working on an application quite some time now and i wanted to
include something to let the user load a new version. i therefore
tried to include this here:
from ftplib import FTP
import string,re
def handleDownload(block):
processfile.write(block)
print ".",
def load_new_version(old_version):
host='host.bla'
user='usr_ftp_76512'
password='45mhBLl3lXRX.332'
account='usr_ftp_76512'
download=''
directory = 'htdocs'
server = FTP(host)
server.login(user,password,account)
server.cwd(directory)
filelist=server.retrlines('LIST')
#okay this works :logged into the ftpserver,changed dir and now have a
#string that tells the files like this:
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 14454 Dec 5 14:10
Pict5.2.2.jpg
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 16174 Dec 5 12:37 Picture
3.jpg
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 14139 Dec 5 12:38 Picture
6.jpg
#-rw-r--r-- 1 usr_ftp_76512 ftpgroup 42713 Dec 5 12:38 Picture
7.jpg
#226 Transfer complete.
print filelist
files=re.findall(' .{2,20}[.][a-z]{3,3}', filelist,re.I|re.S)
#the dot means every char, because of the flag re.S
# re.I ignores case
#{2,20} this means 2 to twenty of the char that is before it
#heres the problem... if you copy the output and put it into a string
he
#finds all the files with findall, but not inside here... and i dont
get why
#help
print files
for file in files:
number=re.findall('pict([0-9])[.]([0-9])[.]?
([0-9]?)',file,re.I)
version=100*int(number[0][0])+ 10*int(number[0][1])+ int(number
[0][2])
if version >old_version:
print version
print old_version
old_version=version
download=file
if download :
processfile = open(download, 'wb')
server.retrbinary('RETR ' + download, handleDownload)
processfile.close()
server.close()
return True
else:
server.close()
return False
load_new_version(201)
#greetz