Ejemplo n.º 1
0
def main():
    trigger(pause)

    emailer = Emailer()
    emailer.login(pause)

    sender_names = print_email_list()

    if 'all' in sender_names:
        sender_names = list(email_list.keys())

    accessed = False
    emails_sent = 0
    for name in sender_names:
        try:
            email_list[name]
        except:
            print("[{}] is not a valid name --- SKIPPING".format(name))
            pause(.5)
            continue

        msg = Emailer.msg_builder(name, accessed)

        print(msg)
        send = input("Send Email? [Y/n]: ")
        if (send == 'Y'):
            emailer.send(msg)
            print("---MSG SENT---\n")
            emails_sent += 1
            pause(.5)
        else:
            print("---SKIPPING---\n")
            pause(.5)

        accessed = True
        clear()

    print("{} emails were sent".format(emails_sent))
    print('---Program Ended---')
    print('---CLOSING---')
    emailer.logoff()

    pause(2)
Ejemplo n.º 2
0
class Alert:
    def __init__(self):
        self.sites = self.parse_sites()
        self.emailer = Emailer()
    def parse_sites(self):
        websites = json.load(open("websites.json","r"))
        sites = []
        for website in websites:
            sites.append(website.split(".")[1])
        return sites

    def alert(self):
        for site in self.sites:
            self.send_alert(site)
        
    def send_alert(self,site):
        record_sets = glob("../storage/"+site+"*")
        today = str(date.today()).replace("-","")
        yesterday = str(date.today() - timedelta(days=1)).replace("-","")
        todays = []
        yesterdays = []
        diff = Diff()
        for record_set in record_sets:
            if today in record_set:
                todays.append(record_set)
            if yesterday in record_set:
                yesterdays.append(record_set)

        today_hashes = []
        for today in todays:
            os.chdir(today)
            with open("sha_hashes.txt","r") as f:
                today_hashes.append(f.read().split("\n"))
            os.chdir("../")

        yesterday_hashes = []
        for yesterday in yesterdays:
            os.chdir(yesterday)
            with open("sha_hashes.txt","r") as f:
                yesterday_hashes.append(f.read().split("\n"))
            os.chdir("../")

        #any variable with _t is today
        #any variable with _y is yesterday
        for hash_set_t in today_hashes:
            for ind_t,hashing_t in enumerate(hash_set_t):
                name_t = hashing_t.split("000")[1].split(":")[0]
                hash_val_t = hashing_t.split(":")[1]
                for hash_set_y in yesterday_hashes:
                    for ind_y,hashing_y in enumerate(hash_set_y):
                        hash_val_y = hashing_y.split(":")[1]
                        if name_t in hashing_y:
                            if hash_val_t != hash_val_y:
                                self.emailer.add_website(site)
                                self.emailer.add_message("the website was updated")
                                self.emailer.send()
Ejemplo n.º 3
0
 def __init__(self):
     self.sites = self.parse_sites()
     self.emailer = Emailer()