diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2015-02-06 15:17:51 -0500 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2015-02-06 15:17:51 -0500 |
commit | dab097d5000c4697761b6985cb3512f7bce0147f (patch) | |
tree | 7b81b7826a1e23822955560f0f73dc09cda6c8e8 /.config/maildirproc | |
parent | f50b49ef26f5c692bda1f3f13cd38f9f4f395300 (diff) | |
parent | a6f973687fb4a1a4558f74f7da595b6902a5dce0 (diff) |
Merge remote-tracking branch 'origin/master' into purdue-cs/master
Conflicts:
.config/X11/clientrc
.config/bash/rc.d/emacs.sh
.config/cron/make-config
.config/emacs/custom.el
.config/emacs/init.el
.config/git/config
.config/login.sh
.config/selected_editor
.local/bin/config-path
Diffstat (limited to '.config/maildirproc')
-rw-r--r-- | .config/maildirproc/att.rc | 214 | ||||
-rw-r--r-- | .config/maildirproc/purdue.rc | 95 |
2 files changed, 211 insertions, 98 deletions
diff --git a/.config/maildirproc/att.rc b/.config/maildirproc/att.rc index 381ce8f..6b31260 100644 --- a/.config/maildirproc/att.rc +++ b/.config/maildirproc/att.rc @@ -1,7 +1,9 @@ # -*- mode: python; indent-tabs-mode: t -*- import os +import os.path import subprocess +import datetime processor.maildir_base = "~/Maildir" processor.auto_reload_rcfile = True @@ -24,6 +26,16 @@ def is_to_or_from_re(mail,address): return ( mail["From"].matches(address) or mail.target.matches(address)) +def move_ham(mail,folder): + y = datetime.datetime.now().year + folder = "FOLDERS.Ham."+str(y)+folder + dir = processor.maildir_base+"/"+folder + if not os.path.isfile(dir+"/maildirfolder"): + os.makedirs(dir+"/tmp", 0o777, True) + os.makedirs(dir+"/new", 0o777, True) + os.makedirs(dir+"/cur", 0o777, True) + open(dir+"/maildirfolder", 'a').close() + mail.move(folder) def bogofilter_auto(mail): p = subprocess.Popen( @@ -37,28 +49,53 @@ def bogofilter_auto(mail): "Error running bogofilter: Return code = {0!r}".format( p.returncode)) return p.returncode - def bogofilter_ham(mail): subprocess.call(["bogofilter", "-S", "-n", "-I", mail.path]) - def bogofilter_spam(mail): subprocess.call(["bogofilter", "-N", "-s", "-I", mail.path]) -def handle_incoming_spam_training(mail): - bogofilter_spam(mail) - mail.move(".Bulk Mail") - def handle_incoming_ham_training(mail): bogofilter_ham(mail) handle_incoming_ham(mail) +def handle_incoming_spam_training(mail): + bogofilter_spam(mail) + mail.move("FOLDERS.Spam") def handle_incoming_ham(mail): my_filters(mail) def handle_incoming_spam(mail): - mail.move(".Bulk Mail") + mail.move("FOLDERS.Spam") def handle_incoming_unknown(mail): # Filter spam + + # Whitelist + if ( + False + or is_to_or_from(mail, "fsf.org") + or is_to_or_from(mail, "gnu.org") + or is_to_or_from(mail, "parabola.nu") + or is_to_or_from(mail, "parabolagnulinux.org") + or mail["From"] == "MAILER-DAEMON@yahoo.com" + or mail["From"].contains("@facebookmail.com>") + or mail["From"].contains("@gandi.net") + or mail["From"].contains("@goodwillindy.org>") + or mail["From"].contains("@lpi.org>") + or mail["From"].contains("@msdlt.k12.in.us>") + or mail["From"].contains("@parabola.nu") + or mail["From"].contains("@post.oreilly.com>") + or mail["From"].contains("@scouting.org>") + or mail["From"].contains("@wolframalpha.com>") + or mail["From"].contains("parabolagnulinux.org") + or mail["List-Id"].matches(".*\.(gnu|gnome|archlinux|parabolagnulinuxlibre)\.org") + or mail["List-Id"].matches(".*\.parabola\.nu") + or mail["Subject"].contains("[Dev]") + or mail["Subject"].contains("[Maintenance]") + or mail["Subject"].contains("[PATCH") + or mail["Subject"].contains("[systemd-devel]") + ): + handle_incoming_ham_training(mail) + return spam = bogofilter_auto(mail) if spam == 0: @@ -68,10 +105,10 @@ def handle_incoming_unknown(mail): handle_incoming_ham(mail) return elif spam == 2: - # maybe spam + mail.move("FOLDERS.MysteryMeat") return else: - mail.move(".Error") + mail.move("FOLDERS.BogoFail") return def my_filters(mail): @@ -82,7 +119,7 @@ def my_filters(mail): or mail["List-Id"].matches(list+"\.gnu\.org") or mail["Subject"].contains('['+list+']') ): - mail.move(".software."+list) + move_ham(mail,".software."+list) return # Sort mail from other software mailing lists @@ -91,67 +128,54 @@ def my_filters(mail): or mail["List-Id"].matches("social-discuss\.gnu\.org") or mail["Subject"].contains("social-discuss") ): - mail.move(".software.social") + move_ham(mail,".software.social") return if mail["List-Id"].matches("networkmanager-list\.gnome\.org"): - mail.move(".software.networkmanager") + move_ham(mail,".software.networkmanager") return - if mail["List-Id"].matches("maintenance.lists.parabolagnulinux.org"): - if mail["From"].contains("monit@"): - if mail["Message-Id"].contains("@repo.parabolagnulinux.org"): - if mail["Subject"].matches("^\[Maintenance\] monit alert -- (Execution|Connection) (succeeded|failed) sshd$"): - mail.move(".software.parabola-maintenance.monit-repo.sshd") - return - mail.move(".software.parabola-maintenance.monit-repo") - return - if mail["Message-Id"].contains("@rshg054.dnsready.net"): - mail.move(".software.parabola-maintenance.monit-rshg054") - return - if mail["Subject"].matches("Cron <.*@repo>"): - mail.move(".software.parabola-maintenance.cron-repo") - return - if mail["Subject"].matches("Cron <.*@rshg054>"): - mail.move(".software.parabola-maintenance.cron-rshg054") - return - mail.move(".software.parabola-maintenance") + if mail["List-Id"].matches("maintenance\.lists\.parabola(gnulinux\.org|\.nu)"): + move_ham(mail,".software.parabola.maintenance") return - if is_to_or_from(mail, "parabola.nu"): - mail.move(".software.parabola-labs") + if is_to_or_from(mail, "labs@parabola.nu"): + move_ham(mail,".software.parabola.labs") return if ( False - or mail["List-Id"].matches("parabolagnulinux.org") + or mail["List-Id"].matches("parabolagnulinux\.org") + or mail["List-Id"].matches("parabola\.nu") or is_to_or_from(mail, "parabolagnulinux.org") or is_to_or_from(mail, "kiwwwi.com.ar") + or is_to_or_from(mail, "parabola.nu") ): if mail["Subject"].contains("[Django]"): - mail.move(".software.parabola-maintenance.django") + move_ham(mail,".software.parabola.maintenance.django") + return + else: + move_ham(mail,".software.parabola.dev") return - mail.move(".software.parabola-dev") - return if (mail["List-Id"].matches("pacman-dev.archlinux.org")): - mail.move(".software.pacman-dev") + move_ham(mail,".software.pacman-dev") return - if (mail["List-Id"].matches("systemd-devel.lists.freedesktop.org")): - mail.move(".software.systemd-devel") + if (mail["List-Id"].matches("systemd-devel.lists.freedesktop.org") or is_to_or_from(mail, "systemd-devel@lists.freedesktop.org")): + move_ham(mail,".software.systemd-devel") return for subject_re in [ "\[Stow-[^\]]*\].*", ]: if mail["Subject"].matches(subject_re): - mail.move(".software") + move_ham(mail,".software") return # Sort mail from some social websites if mail["From"].matches("facebook(|mail)\.com"): - mail.move(".Social.Facebook") + move_ham(mail,".Social.Facebook") return if ( @@ -159,15 +183,24 @@ def my_filters(mail): or mail["From"].matches("identi\.ca") or mail["From"].matches("statusnet") ): - mail.move(".Social.Identica") + move_ham(mail,".Social.Identica") return + if ( + False + or mail["From"].contains("@gandi.net") + or mail["From"].contains("@ramhost.us") + or mail["From"].contains("@startcom.org") + ): + move_ham(mail,".lukeshu-com") + return + if mail["From"].matches("twitter\.com"): - mail.move(".Social.Twitter") + move_ham(mail,".Social.Twitter") return if mail["From"].matches("@xkcd\.com"): - mail.move(".Social.xkcd") + move_ham(mail,".Social.xkcd") return # Sort mail related to Troop 276 @@ -191,30 +224,24 @@ def my_filters(mail): or is_to_or_from(mail,"mytroop.us") or is_to_or_from(mail,"crossroadsbsa.org") ): - mail.move(".Troop276") + move_ham(mail,".BoyScouts") return # Sort mail from misc people - if mail["From"].matches("margieshu@sbcglobal\.net"): - mail.move(".misc.Mom") + if ( + False + or is_to_or_from(mail,"margieshu@sbcglobal.net") + or is_to_or_from(mail,"3174451635@mms.att.net") + ): + move_ham(mail,".misc.Mom") return for address in [ - "justicejade10@aol.com", - "parsonsjade@aol.com", - "parsonstjade@gmail.com", - "jadparso@umail.iu.edu", - ]: - if is_to_or_from(mail,address): - mail.move(".misc.Jade") - return - - for address in [ "nintendo.com", "nintendo-news.com", ]: if mail["From"].contains(address): - mail.move(".misc.Nintendo") + move_ham(mail,".misc.Nintendo") return for address in [ @@ -223,7 +250,7 @@ def my_filters(mail): "CompTIA", ]: if mail["From"].contains(address): - mail.move(".misc.CompTIA") + move_ham(mail,".misc.CompTIA") return # Sort mail from FRC people @@ -248,37 +275,38 @@ def my_filters(mail): "william.walk@gmail.com", ]: if is_to_or_from(mail,address): - mail.move(".School.Robotics") + move_ham(mail,".School.Robotics") return for subject_re in [ "robotics", - "1024", + "\b1024\b", + "\b4272\b", "kil-?a-?bytes", ]: if mail["Subject"].matches(subject_re): - mail.move(".School.Robotics") + move_ham(mail,".School.Robotics") return # Sort mail from software people for address in [ "@archlinux.org", + "@canonical.org", + "@cnuk.org", + "@eff.org", + "@foocorp.net", "@fsf.org", "@github.com", - "canonical.org", - "cnuk.org", - "eff.org", - "esr@thyrsus.com", - "foocorp.net", - "gitorious.org", - "gnome.org", - "gnu.org", - "ietf.org", - "kde.org", - "sourceforge.com", + "@gitorious.org", + "@gnome.org", + "@gnu.org", + "@ietf.org", + "@kde.org", + "@sourceforge.com", + "@thyrsus.com", "trustees@core3.amsl.com", ]: if is_to_or_from(mail,address): - mail.move(".software") + move_ham(mail,".software") return @@ -288,16 +316,16 @@ def my_filters(mail): or is_to_or_from(mail, "@lnnorthstar.org") or is_to_or_from(mail, "lnnorthstar.org@tigertech.net") ): - mail.move(".School.Newspaper") + move_ham(mail,".School.Newspaper") return # Sort mail from various employers/people who pay me if is_to_or_from(mail, "@precisepath.com"): - mail.move(".Work.PrecisePath") + move_ham(mail,".Work.PrecisePath") return if is_to_or_from(mail,"susyphil@aol.com"): - mail.move(".Work.PMCH") + move_ham(mail,".Work.PMCH") for address in [ "d.farrar@comcast.net", @@ -305,7 +333,7 @@ def my_filters(mail): "@vmware.com", ]: if is_to_or_from(mail,address): - mail.move(".Work.FAST") + move_ham(mail,".Work.FAST") return # Sort misc newsletters @@ -319,12 +347,13 @@ def my_filters(mail): or mail["From"].contains("info@demandprogress.org") or (mail["From"].contains("@sparkfun.com") and mail["Message-Id"].contains("rsgsv.net")) ): - mail.move(".misc.Newsletters") + move_ham(mail,".misc.Newsletters") return if ( False or mail["From"].contains("@msdlt.k12.in.us") + or mail["From"].contains("ltschoolfoundation@gmail.com") or mail["From"].contains("naviance.com") or is_to_or_from(mail,"ibwhite@comcast.net") or mail["Subject"].contains("IOA") @@ -334,7 +363,7 @@ def my_filters(mail): or mail["Subject"].contains("NHS") or mail["Subject"].contains("National Honor Society") ): - mail.move(".School") + move_ham(mail,".School") return # from college stuff @@ -343,50 +372,47 @@ def my_filters(mail): or mail["Subject"].contains("NYLF") # National Youth Leadership Conference or mail["Subject"].contains("NSHSS") ): - mail.move(".College.Societies") + move_ham(mail,".College.Societies") return if ( False - #or mail["From"].contains(".edu") or mail["From"].contains("admissions@") - #or mail["From"].contains("college") - #or mail["From"].contains("university") or mail["Subject"].contains("college") # now we get to the BS or mail["From"].contains("@dreamitdoitindiana.com") or mail["From"].contains("@indianatechinfo.org") ): - mail.move(".College") + move_ham(mail,".College") return if mail["From"].contains("@projectwonderful.com"): - mail.move(".ProjectWonderful") + move_ham(mail,".misc.ProjectWonderful") return if ( False or mail["From"].matches("@localhost") or mail["From"].matches("@[^,>]*\.local") - or mail["From"].matches("@[^,>]*\.lukeshu\.ath\.cx") + or mail["From"].matches("@[^,>]*\.lan") or mail["To"].matches("luke@") ): - mail.move(".LocalSystems") + move_ham(mail,".LocalSystems") return if ( False or mail["Subject"].contains("password") or mail["Subject"].contains("account") ): - mail.move(".misc.accounts") + move_ham(mail,".misc.accounts") return - mail.move(".Ham") + move_ham(mail,"") handle_mapping = { - ".": handle_incoming_unknown, - ".spam-training": handle_incoming_spam_training, - ".ham-training": handle_incoming_ham_training, - #".Ham": handle_incoming_ham, + "Inbox": handle_incoming_unknown, + "Bulk Mail": handle_incoming_unknown, + "FOLDERS.Spam.training": handle_incoming_spam_training, + "FOLDERS.Ham.training": handle_incoming_ham_training, } processor.maildirs = handle_mapping.keys() for mail in processor: diff --git a/.config/maildirproc/purdue.rc b/.config/maildirproc/purdue.rc index 6d4b913..9f6bf37 100644 --- a/.config/maildirproc/purdue.rc +++ b/.config/maildirproc/purdue.rc @@ -70,21 +70,38 @@ def my_filters(mail): or is_to_or_from(mail,"@propertysolutions.com") or is_to_or_from(mail,"collegestationapartments@gmail.com") or is_to_or_from_re(mail,"collegestationca\..*@gmail.com") - or is_to_or_from(mail, "@duke-energy.com") ): mail.move("INBOX.housing.CollegeStation") return + if ( + False + or is_to_or_from(mail,"@hunterlp.com") + or is_to_or_from(mail, "@duke-energy.com") + or is_to_or_from(mail, "@alerts.comcast.net") + or is_to_or_from(mail, "rentpayment.com") + or is_to_or_from(mail, "@vectren.com") + ): + mail.move("INBOX.housing.BeauJardin") + return if mail["From"].matches("facebook(|mail)\.com"): mail.move("INBOX.crap.Facebook") return + if is_to_or_from(mail,"@cerias.purdue.edu"): + mail.move("INBOX.crap.CERIAS") + return + + if is_to_or_from(mail,"royfu@purdue.edu"): + mail.move("INBOX.crap.Hackers") + return + if ( False or is_to_or_from(mail,"@cable.comcast.com") or is_to_or_from(mail,"@apexsystemsinc.com") ): - mail.move("INBOX.work.Comcast") + mail.move("INBOX.work.2013.Comcast") return if ( @@ -100,20 +117,24 @@ def my_filters(mail): # Fall 2012 ############################################################ + # SCI210 (Teaming principles) if mail["Subject"].contains("Fall-2012-SCI-21000-001:"): mail.move("INBOX.classes.2012-2.SCI210") + # CS180 (Java) if mail["Subject"].contains("fall-2012-cs-18000"): mail.move("INBOX.classes.2012-2.CS180") return if piazza_topic(mail, "CS 18000"): mail.move("INBOX.classes.2012-2.CS180.Piazza") return + # SOC100 if mail["Subject"].contains("Fall-2012-SOC-10000"): mail.move("INBOX.classes.2012-2.SOC100") return # Spring 2013 ########################################################## + # CS240 (C) if mail["Subject"].contains("[CS240] Submission result for"): mail.move("INBOX.classes.2013-1.CS240.autograder") return @@ -123,33 +144,40 @@ def my_filters(mail): if piazza_topic(mail, "CS 240"): mail.move("INBOX.classes.2013-1.CS240.Piazza") return + # PHYS220 if mail["Subject"].matches(".*(PHYS|CHIP)\s*220.*") or is_to_or_from(mail,"srdas@purdue.edu"): mail.move("INBOX.classes.2013-1.PHYS220") return + # SOC220 (Social Problems) if mail["Subject"].contains("Spring-2013-SOC-22000"): mail.move("INBOX.classes.2013-1.SOC220") return # Fall 2013 ############################################################ + # CS250 (Computer Architecture) if mail["Subject"].contains("Fall-2013-CS-25000"): mail.move("INBOX.classes.2013-2.CS250") return if piazza_topic(mail, "CS 250") or piazza_topic(mail, "CS 250-FALL2013"): mail.move("INBOX.classes.2013-2.CS250.Piazza") return + # CS251 (Intro Algo) if mail["Subject"].contains("Fall-2013-CS-25100"): mail.move("INBOX.classes.2013-2.CS251") return if piazza_topic(mail, "CS 251"): mail.move("INBOX.classes.2013-2.CS251.Piazza") return + # SPAN101 if mail["Subject"].contains("Fall-2013-SPAN-10100"): mail.move("INBOX.classes.2013-2.SPAN101") return + # MA261 (Calc III) if mail["Subject"].contains("Fall-2013-MA-26100"): mail.move("INBOX.classes.2013-2.MA261") return + # MA265 (Linear Algebra) if mail["Subject"].contains("Fall-2013-MA-26500"): mail.move("INBOX.classes.2013-2.MA265") return @@ -163,11 +191,11 @@ def my_filters(mail): if mail["From"].contains("mixable") and mail["Subject"].matches("^COM 21700"): mail.move("INBOX.classes.2014-1.COM217.Mixable") return - # CS252 + # CS252 (Systems Programming) if piazza_topic(mail, "CS 25200"): mail.move("INBOX.classes.2014-1.CS252.Piazza") return - # CS307 + # CS307 (Software Engineering) if is_to_or_from(mail, "dunsmore@purdue.edu") or mail["Subject"].contains("Spring-2014-CS-30700-LE1"): mail.move("INBOX.classes.2014-1.CS307") return @@ -183,6 +211,65 @@ def my_filters(mail): mail.move("INBOX.classes.2014-1.STAT350.Piazza") return + # Fall 2014 ############################################################ + + # CS334 (Graphics) + if (is_to_or_from(mail, "lin553@purdue.edu") or mail["Subject"].contains("Fall-2014-CS-33400")): + mail.move("INBOX.classes.2014-2.CS334") + return + # CS354 (OS) + if piazza_topic(mail, "CS 354"): + mail.move("INBOX.classes.2014-2.CS354.Piazza") + return + # CS381 (Algo) + if piazza_topic(mail, "CS 381"): + mail.move("INBOX.classes.2014-2.CS381.Piazza") + return + # CS456 (Programming languages) + if piazza_topic(mail, "CS 456"): + mail.move("INBOX.classes.2014-2.CS456.Piazza") + return + # MA416 + if mail["Subject"].contains("Fall-2014-MA-41600"): + mail.move("INBOX.classes.2014-2.MA416") + return + # PHYS221 + if (False + or is_to_or_from(mail, "cui@purdue.edu") + or is_to_or_from(mail, "shina@purdue.edu") + or is_to_or_from(mail, "ajith@purdue.edu") + ): + mail.move("INBOX.classes.2014-2.PHYS221") + return + + # Spring 2015 ######################################################### + + # CS352 (Compilers) + if is_to_or_from(mail, "wjg@cs.purdue.edu"): + mail.move("INBOX.classes.2015-1.CS352") + return + if piazza_topic(mail, "CS 352"): + mail.move("INBOX.classes.2015-1.CS352.Piazza") + return + # CS408 (Software testing) + if (False + or mail["Subject"].contains("spring-2015-cs-40800") + or is_to_or_from(mail, "li1471@purdue.edu") + or is_to_or_from(mail, "kirby@purdue.edu") + or is_to_or_from(mail, "webb39@purdue.edu") + or is_to_or_from(mail, "Jkou@purdue.edu") + or is_to_or_from(mail, "nstodda@purdue.edu") + or is_to_or_from(mail, "aryker@purdue.edu") # TA + ): + mail.move("INBOX.classes.2015-1.CS408") + return + # CS448 (Databases) + # ME297 (FRC) + if mail["Subject"].contains("[ME297]"): + mail.move("INBOX.classes.2015-1.ME297") + return + # SOC324 (Criminology) + handle_mapping = { "INBOX": my_filters, } |