Grundlegende Funktionalität hinzugefügt
This commit is contained in:
parent
1bd80e59d0
commit
b8ae21f48b
1 changed files with 53 additions and 0 deletions
53
Mail.py
Normal file
53
Mail.py
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
def download(url):
|
||||||
|
#return None
|
||||||
|
filename = 'mpg/'+url+'.pdf'
|
||||||
|
url = 'http://www.mpglu.de/vps/'+url+'.pdf'
|
||||||
|
req = requests.get(url, auth=('schueler', 'Ing8gresk'))
|
||||||
|
file = open(filename, 'wb')
|
||||||
|
for chunk in req.iter_content(100000):
|
||||||
|
file.write(chunk)
|
||||||
|
file.close()
|
||||||
|
return None
|
||||||
|
|
||||||
|
def modification_date(filename):
|
||||||
|
t = os.path.getmtime(filename)
|
||||||
|
return datetime.datetime.fromtimestamp(t)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.rename('mpg/heute.pdf', 'mpg/heute1.pdf')
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("File Heute.PDF not found")
|
||||||
|
print("Will try to download it from the MPG-Server")
|
||||||
|
url = 'heute'
|
||||||
|
download(url)
|
||||||
|
os.rename('mpg/heute.pdf', 'mpg/heute1.pdf')
|
||||||
|
try:
|
||||||
|
os.rename('mpg/morgen.pdf', 'mpg/morgen1.pdf')
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("File Morgen.PDF not found")
|
||||||
|
print("Will try to download it from the MPG-Server")
|
||||||
|
url = 'morgen'
|
||||||
|
download(url)
|
||||||
|
os.rename('mpg/morgen.pdf', 'mpg/morgen1.pdf')
|
||||||
|
|
||||||
|
|
||||||
|
url = 'morgen'
|
||||||
|
download(url)
|
||||||
|
url = 'heute'
|
||||||
|
download(url)
|
||||||
|
|
||||||
|
x=os.stat('mpg/heute.pdf')
|
||||||
|
x = x.st_size
|
||||||
|
y=os.stat('mpg/heute1.pdf')
|
||||||
|
y = y.st_size
|
||||||
|
if x != y :
|
||||||
|
print("die Dateien sind ungleich")
|
||||||
|
os.system('s-nail -a mpg/heute.pdf -s "Alpha-MPG-Vertretungsliste" schneeschieben@web.de')
|
||||||
|
else:
|
||||||
|
print ("Es gibt keine neuen Mals")
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue