ich habe folgenden Code geschrieben:
Code: Alles auswählen
# iCal-WebSync
# 05-2009 by TjuXx
#=====================================================
import os, ftplib, time
class ICal(object):
def __init__(self, ifile='test.ics', server='000.000.000.000', path='files/ical', login='xxxxxx', password='xxxxxx'):
self.calfile = calfile
self.server = server
self.path = path
self.login = login
self.password = password
def getLocalTime(self):
return os.stat(self.calfile)[8]
def getServerStat(self):
tmp = open('stat.dat','wb')
ftp = ftplib.FTP(self.server, self.login, self.password)
ftp.cwd(self.path)
ftp.retrbinary('RETR stat.dat',tmp.write)
ftp.close()
tmp.close()
tmp = open('stat.dat','r')
sta = tmp.readline()
tmp.close()
return int(sta)
def sync(self):
if self.getLocalTime() < self.getServerStat():
self.download()
if self.getLocalTime() > self.getServerStat():
self.upload()
return None
def download(self):
tmp = open(self.calfile,'w')
ftp = ftplib.FTP(self.server, self.login, self.password)
ftp.cwd(self.path)
ftp.retrbinary('RETR '+self.calfile, tmp.write)
ftp.close()
tmp.close()
print self.calfile+'successfull downloaded.'
def upload(self):
sta = open('stat.dat','w')
sta.write(str(iCal.getLocalTime()))
sta.close()
sta = open('stat.dat','r')
tmp = open(self.calfile,'r')
ftp = ftplib.FTP(self.server, self.login, self.password)
ftp.cwd(self.path)
ftp.storbinary('STOR stat.dat', sta)
sta.close()
ftp.storbinary('STOR '+self.calfile, tmp)
tmp.close()
ftp.close()
print self.calfile+' successfull uploaded.'
iCal = ICal()
while True:
iCal.sync()
time.sleep(1)
# endOfFile "iCal.pyw"
Woran kann das liegen??
Gruß TjuXx