def loadMessages(storage): if a.findStorage(storage): with open(storage, "r") as f: msgs = j.loads(j.load(f)) f.close() return msgs return None
def loadRunAt(storage): global RUNAT if findStorage(storage): with open(storage, "r") as saved: RUNAT = j.loads(j.load(saved)) saved.close() return RUNAT = []
def distribute(): for key in a.ACCOUNTS.keys(): location = "resources/outbox/{}.json".format(key) if a.findStorage(location): with open(location, "r") as store: msgs = j.loads(j.load(store)) store.close() for msg in msgs.values(): sendEmail(key, msg)
def appendToMail(name, body): fileName = "resources/outbox/{}.json".format(name) if a.findStorage(fileName): with open(fileName, "r") as openFile: currentMail = j.loads(j.load(openFile)) openFile.close() currentMail[len(currentMail.keys())] = body else: currentMail = {0: body} toSave = j.dumps(currentMail) with open(fileName, "w") as openFile: j.dump(toSave, openFile) openFile.close()
def clearOutbox(): path = "{}/resources/outbox".format(o.path.dirname(__file__)) if a.findStorage(path): fileList = o.listdir(path) for f in fileList: o.remove(o.path.join(path, f))