Naposledy aktivní 1 month ago

racerxdl's Avatar Lucas Teske revidoval tento gist 7 years ago. Přejít na revizi

1 file changed, 29 insertions

separatesent.py(vytvořil soubor)

@@ -0,0 +1,29 @@
1 + #!/usr/bin/env python
2 +
3 + import os, email, sys
4 + from os.path import isfile
5 +
6 + if len(sys.argv) < 3:
7 + print "Usage: separatesent folder emailFrom"
8 + exit(1)
9 +
10 + content = os.listdir(sys.argv[1])
11 + files = [ "%s/%s" %(sys.argv[1], f) for f in content if isfile("%s/%s" %(sys.argv[1], f)) ]
12 +
13 + emailFrom = sys.argv[2].lower()
14 +
15 +
16 + def isSentAction(file):
17 + print "File is sent by user: %s"%file
18 +
19 + for f in files:
20 + #print "Opening %s" %f
21 + z = open(f, "r")
22 + e = email.message_from_file(z)
23 + z.close()
24 + ef = e.get('From')
25 + if ef != None:
26 + ef = ef.lower()
27 + issent = emailFrom in ef
28 + if issent:
29 + isSentAction(f)
Novější Starší