def CheckUnread(user, folder='inbox', index=0): mbox = mailbox.MailBox(user.GetName()) folder = mbox.get_folder(folder) if (index == 0): index = folder.count() entry = folder.get_entry(index - 1) if (entry is None): raise OutOfRange('index out of range') return not entry.IsRead()
def doMailCheck(): global users global userMap mbox = mailbox.MailBox('*****@*****.**', 'thisisastrongpassword') mbox.__enter__() while True: print mbox.get_count() dats = mbox.get_addrs() for k, v in dats.iteritems(): users[userMap[k]]["sendTo"] = v pickle.dump(users, open("users.pic", "wb")) pickle.dump(userMap, open("userMap.pic", "wb")) time.sleep(5)
def View(user, folder, index, start, count): mbox = mailbox.MailBox(user.GetName()) folder = mbox.get_folder(folder) entry = folder.get_entry(index - 1) if (entry is None): raise OutOfRange('out of range') post = folder.get_content(index - 1) if (post is None): raise OutOfRange('out of range') info = dict(entry.GetInfo().items() + post.GetInfo(start, count).items()) info['id'] = index if not entry.IsRead(): entry.SetRead(True) folder.set_entry(index - 1, entry) # session.GetUserInfo().SetMailCheck() return json.dumps(info)
def __loadData(self): """ Loads all system data. """ """ import createworld world = createworld.CreateWorld(self) world.create() """ roomList = ggmodel.GGModel.readAll("room") for room in roomList: if room: self.__rooms.append(room) if room.getStartRoom(): self.__startRooms.append(room) if len(self.__rooms) == 0: import createworld word = createworld.CreateWorld(self) word.create() #newRoom = GG.model.room.GGRoom(GG.utils.TILES_SNOW, "Habitacion entrada", [8, 8], 12, True, True) #self.__rooms.append(newRoom) #self.__startRooms.append(newRoom) self.mailBox = mailbox.MailBox()
def List(user, folder, start, count, end): mbox = mailbox.MailBox(user.GetName()) folder = mbox.get_folder(folder) total = folder.count() start, end = Util.CheckRange(start, end, count, DEFAULT_MAIL_VIEW_COUNT, total) if (start <= end and start >= 1 and end <= total): result = '{ "start": %d, "end": %d, "mails": [\n' % (start, end) first = True for i in range(start - 1, end): entry = folder.get_entry(i) if entry is None: continue if not first: result += ',\n' post = entry.GetInfo('mail') post['id'] = i + 1 result += json.dumps(post) first = False result += '\n]}' return result else: raise OutOfRange('out of range')
def __init__(self, user, userec, umemo): self.name = user self.userec = userec self.memo = umemo self.mbox = mailbox.MailBox(user)
import bank import mailbox from uwldap import getUser import pickle import comms imap_username = '******' imap_password = '******' #Our mailbox for receiving addresses mbox = mailbox.MailBox(imap_username, imap_password) #watcoind bnk = bank.Bank() bnk.ensureServer() #load users from database users= pickle.load(open( "users.pic", "rb" ) ) #Each user is a dictionary: # bank - the account name. Same as quest. # quest - The quest ID # name - Real name # sendTo - BTC address to send coins to. #serial responder: sr = comms.SerialResponder(bnk,users)