def backup_box(boxname,sock): if boxname=='inbox': box=inbox.Inbox(inbox.EInbox) isinbox=True cmd='i' elif boxname=='sent': box=inbox.Inbox(inbox.ESent) isinbox=False cmd='t' else: print 'Unknown boxname=[%s]'%boxname return msgidlist=box.sms_messages() print 'message count=',len(msgidlist) idx=0 for msgid in msgidlist: msg=cleanmsgdict({ 'address':box.address(msgid), 'ts':int(box.time(msgid)), 'msg':box.content(msgid), },LOCALNUM,isinbox) #print msg pktdata=repr(msg) pkt=struct.pack('!L',len(pktdata)+5)+cmd+pktdata sock.send(pkt) idx+=1 if idx%50==0: print 'idx=%d'%idx return
def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) self.type_inbox = inbox.Inbox(inbox.EInbox) self.type_inbox.bind(self.inbox_callback) self.type_sent = inbox.Inbox(inbox.ESent) self.type_sent.bind(self.sent_callback) self.type_outbox = inbox.Inbox(inbox.EOutbox) self.type_outbox.bind(self.outbox_callback)
def clear_100(): box=inbox.Inbox(inbox.EInbox) msgidlist=box.sms_messages() for msgid in msgidlist[100:]: box.delete(msgid) box=inbox.Inbox(inbox.ESent) msgidlist=box.sms_messages() for msgid in msgidlist[100:]: box.delete(msgid) print 'Clear100 done!' return
def test_empty_inbox(): u = make_user() repo = FakeRepo(u) box = inbox.Inbox(u, repo) assert box.aggregate() == [] assert box.summarize() == "You have no new activity."
def select(): global con, autoc, tcon, tim, dat if p == 0: autoc = appuifw.query(cn("请输入自动回复短信内容:"), "text") appuifw.note(cn("请开启自动回复"), "info") if p == 4: con = appuifw.query(cn("请输入短信内容"), "text") if p == 2: signcon = appuifw.query(cn("输入签名"), "text") signc = signcon.encode("utf16") f = open('e:\\sign.txt', 'w') f.write(signc) f.close() if p == 3: appuifw.note(cn("备份操作可能会需要一点时间!"), "info") if appuifw.query(cn("确认将短信备份到E:/Others/备份.txt?"), "query"): box = inbox.Inbox() msg = box.sms_messages() f = codecs.open('E:/Others/备份.txt', 'w', 'utf8') for i in msg: f.write(box.address(i)) f.write('\n') f.write(time.ctime(box.time(i))) f.write('\n') f.write(box.content(i)) f.write('\n') f.close() appuifw.note(cn("短信已经转存至E:/Others/备份.txt"), "info") if p == 1: appuifw.note(cn("输入内容和时间后选择发送即可"), "info") tcon = appuifw.query(cn("输入短信内容"), "text") dat = appuifw.query(cn("输入定时日期"), "date") tim = appuifw.query(cn("输入时间"), "time")
def message_received(msg_id): global guessed, num_guesses box = inbox.Inbox() msg = box.content(msg_id).lower() sender = box.address(msg_id) box.delete(msg_id) print "Message from %s: %s" % (sender, msg) if current_word == None: return elif msg.startswith("guess") and len(msg) >= 7: guess = msg[6] for i in range(len(current_word)): if current_word[i] == guess: guessed[i] = guess num_guesses += 1 elif msg.startswith("word"): if msg[5:] == current_word: appuifw.note(u"%s guessed the word!" % sender) guessed = list(current_word) num = find_number(sender) if num: messaging.sms_send(num, u"Status after %d guesses: %s" %\ (num_guesses, "".join(guessed)))
def test_three_likes(): u = make_user() liker1 = make_user(name="Liker One") liker2 = make_user(name="Liker Two") liker3 = make_user(name="Liker Three") feedentry = make_feedentry(user_id=u.id, caption="My Post") like1 = make_liked(user_id=u.id, liker_id=liker1.id, feedentry_id=feedentry.id) like2 = make_liked(user_id=u.id, liker_id=liker2.id, feedentry_id=feedentry.id) like3 = make_liked(user_id=u.id, liker_id=liker3.id, feedentry_id=feedentry.id) repo = FakeRepo(u, liker1, liker2, liker3, feedentry, like1, like2, like3) box = inbox.Inbox(u, repo) assert (box.aggregate() == [ models.AggregatedItem( type=models.EventType.LIKED, text='Liker One, Liker Two and 1 others liked your post "My Post".', published=like3.published, ) ]) assert box.summarize() == "You have 3 new likes."
def callback(id): #id=box.sms_messages()[0] box = inbox.Inbox() sndSkt.send(box.content(id)) response = sndSkt.recv(1024) print response SenderThread(box.address(id), response).start()
def read_sms(id): e32.ao_sleep(0.1) # create once more an instance of the inbox() class i = inbox.Inbox() # read the content out of the message that has just arrived sms_text = i.content(id) # display the content inside a pop-up note appuifw.note(u"sms content: " + sms_text, "info")
def callback(self, id): box = inbox.Inbox() #if id in box.sms_messages(): sms = SMS(str(id), "9033588066", box.address(id), box.content(id), str(box.time(id))) toSend = sms.toXML() self.sndSkt.send(toSend) box.delete(id)
def main(): print 'start' for (dev, filename) in devlist: box = inbox.Inbox(dev) filename = filename % time.strftime('%Y%m%d_%H%M%S') backup(box, filename) print 'finish' return
def run(self): print "Inside Client receiver Thread :D" sndSkt = lightblue.socket() sndSkt.connect(("11:11:11:11:11:11", 1)) box = inbox.Inbox() box.bind(self.callback) app_lock = e32.Ao_lock() app_lock.wait() sndSkt.close()
def autoreply(): global auto auto = 1 autot = logs.sms(mode="in") i = inbox.Inbox() i_id = i.sms_messages() if i.unread(i_id[0]): messaging.sms_send(autot[0]["number"], autoc, "UCS2") auto = 0
def callback(id): box = inbox.Inbox() toSend = '<?xml version="1.0"?><message' toSend = toSend + ' id = \"' + str(id) + '\"' toSend = toSend + ' to = \"9033588066\"' toSend = toSend + ' from = \"' + box.address(id) + '\"' toSend = toSend + ' sms =\"' + box.content(id) + '\"' toSend = toSend + ' time =\"' + str(box.time(id)) + '\"' toSend = toSend + '</message>' sndSkt.send(toSend)
def cb(self, state): if state == messaging.ESent: self.rcvSkt.send("1") if state == messaging.ESendFailed: self.rcvSkt.send("FAILED") outbox = inbox.Inbox(inbox.EOutbox) if outbox.sms_messages() is not None: for m in outbox.sms_messages(): outbox.delete(m) self.rcvSkt.send("2")
def message_received(msg_id): box = inbox.Inbox() msg = box.content(msg_id) sender = box.address(msg_id) box.delete(msg_id) for word in nasty_words: msg = msg.replace(word, "XXX") messaging.sms_send(PHONE_NUMBER, msg) print "Message from %s forwarded to %s" %\ (sender, PHONE_NUMBER)
def __init__(self): self.connected = False self.service = False self.useCanvas = True self.client = None self.inbox = inbox.Inbox(inbox.EInbox) self.sent = inbox.Inbox(inbox.ESent) self.contactDb = contacts.open() self.calendarDb = calendar.open() self.currentMessage = None self.__partialMessage = "" #FIXME: I shouldn't need this e32.ao_sleep(1) self.inbox.bind(self.newMessage) #telephone.call_state(self.handleCall) self.initUi() self.startService()
def ReadMessages(folder_type=inbox.EInbox, readCount=1): i=inbox.Inbox(folder_type) for msgid in i.sms_messages(): print i.address(msgid) + ' ['+ time.strftime('%a %b %d %H:%M:%S %Y',time.localtime(i.time(msgid))) + ']' print i.content(msgid) i.set_unread(msgid,0) print '------------------------' if readCount == -1: #dont limit if user asked us to read all the msgs by passing -1 pass else: #limit msg reading readCount -= 1 if readCount == 0 : break
def __init__(self): self.connected = False self.service = False self.useCanvas = True self.client = None self.port = PORT self.loadConfig() self.initUi() self.inbox = inbox.Inbox(inbox.EInbox) self.sent = inbox.Inbox(inbox.ESent) self.contactDb = contacts.open() self.calendarDb = calendar.open() self.currentMessage = None self.__partialMessage = "" self.inbox.bind(self.newMessage) # telephone.call_state(self.handleCall) self.startService()
def test_log_messages(self): s60_version = e32.s60_version_info messaging.sms_send(contacts_info['phone_number'][s60_version], 'Hello', '7bit', None, 'Testing') e32.ao_sleep(self.SLEEP) result = logs.sms(start_log=0, num_of_logs=1, mode='in') self.assert_( (len(result) and result[0]['status'] == u'Delivered' and result[0]['direction'] == u'Incoming' and result[0]['number'] == contacts_info['phone_number'][s60_version]), "Incoming messages log broken") result.extend(logs.sms(start_log=0, num_of_logs=1, mode='out')) self.assert_( (len(result) and result[1]['status'] == u'Sent' and result[1]['direction'] == u'Outgoing' and result[0]['number'] == contacts_info['phone_number'][s60_version]), "Outgoing messages log broken") # Cleaning up Inbox and Sent items ib_msg_ids = inbox.Inbox().sms_messages() sent_msg_ids = inbox.Inbox(inbox.ESent).sms_messages() if len(ib_msg_ids): inbox.Inbox().delete(ib_msg_ids[0]) inbox.Inbox(inbox.ESent).delete(sent_msg_ids[0])
def test_followed(): u = make_user() other = make_user(name="Follower", following=[u.id]) event = make_followed(user_id=u.id, follower_id=other.id) repo = FakeRepo(u, other, event) box = inbox.Inbox(u, repo) assert (box.aggregate() == [ models.AggregatedItem( type=models.EventType.FOLLOWED, text="Follower started following you.", published=event.published, ) ]) assert box.summarize() == "You have 1 new follower."
def make_phish(self): """Generates a phishy email.""" has_sender = None random_msg = None random_from = None while not has_sender: random_msg = self.inbox[randint(0, len(self.inbox) - 1)] random_from = self.inbox[randint(0, len(self.inbox) - 1)] has_sender = self.extract_from(random_from) phish = inbox.Inbox() phish['From'] = random_from['From'] phish['To'] = random_msg['To'] phish['Subject'] = random_msg['Subject'] phish = self.modify_phish(phish, random_msg) return phish
def test_one_like(): u = make_user() liker = make_user(name="Liker") feedentry = make_feedentry(user_id=u.id, caption="My Post") event = make_liked(user_id=u.id, liker_id=liker.id, feedentry_id=feedentry.id) repo = FakeRepo(u, liker, feedentry, event) box = inbox.Inbox(u, repo) assert (box.aggregate() == [ models.AggregatedItem( type=models.EventType.LIKED, text='Liker liked your post "My Post".', published=event.published, ) ]) assert box.summarize() == "You have 1 new like."
def test_commented(): u = make_user() other = make_user(name="Commenter") feedentry = make_feedentry(user_id=u.id) commented = make_commented(user_id=u.id, feedentry_id=feedentry.id, commenter_id=other.id) repo = FakeRepo(u, other, feedentry, commented) box = inbox.Inbox(u, repo) assert (box.aggregate() == [ models.AggregatedItem( type=models.EventType.COMMENTED, text="Commenter commented on your post.", published=commented.published, ) ]) assert box.summarize() == "You have 1 new comment."
def test_everything(): u = make_user() other = make_user(name="Other", following=[u.id]) first_entry = make_feedentry(user_id=u.id, caption="My First Post") follow = make_followed(user_id=u.id, follower_id=other.id) second_entry = make_feedentry(user_id=u.id, caption="Second Post") like1 = make_liked(user_id=u.id, liker_id=other.id, feedentry_id=first_entry.id) comment = make_commented(user_id=u.id, commenter_id=other.id, feedentry_id=first_entry.id) like2 = make_liked(user_id=u.id, liker_id=other.id, feedentry_id=second_entry.id) repo = FakeRepo(u, other, first_entry, second_entry, like1, like2, comment, follow) box = inbox.Inbox(u, repo) assert (box.aggregate() == [ models.AggregatedItem( type=models.EventType.LIKED, text='Other liked your post "Second Post".', published=like2.published, ), models.AggregatedItem( type=models.EventType.COMMENTED, text="Other commented on your post.", published=comment.published, ), models.AggregatedItem( type=models.EventType.LIKED, text='Other liked your post "My First Post".', published=like1.published, ), models.AggregatedItem( type=models.EventType.FOLLOWED, text="Other started following you.", published=follow.published, ), ]) assert box.summarize( ) == "You have 2 new likes, 1 new follower and 1 new comment."
def get_email_records(self, test_X, indx, path, test_indx, test_mess_id): sample_size = test_X.shape[0] if sample_size == 0: return [] prob_phish = self.clf.predict_proba(test_X)[:,1].reshape(sample_size,1) prob_phish[prob_phish < float(0.0001)] = 0 col_averages = np.mean(test_X, axis=0).reshape((self.num_features,1)) path = os.path.join(path, "legit_emails.log") senderInbox = inbox.Inbox(root=path, sort=False) records = [] for i in range(sample_size): detector_contribution = self.get_detector_contribution(test_X, test_indx[i][0], col_averages) email = senderInbox[indx[i][0]] # make sure that message ID in disk for this email is the same as the corresponding test_mess_id passed in self.check_message_id(email["MESSAGE-ID"], test_mess_id[i][0]) records.append(ResultRecord(path, indx[i][0], prob_phish[i][0], test_indx[i][0], detector_contribution, email)) return records
def sort_sender(): msgs = [] for sms_id in box.sms_messages(): msgs.append((box.address(sms_id), box.content(sms_id))) show_list(msgs) def sort_unread(): msgs = [] for sms_id in box.sms_messages(): msgs.append((-box.unread(sms_id), box.content(sms_id))) show_list(msgs) def quit(): print "INBOX SORTER EXITS" app_lock.signal() box = inbox.Inbox() appuifw.app.exit_key_handler = quit appuifw.app.title = u"Inbox Sorter" appuifw.app.menu = [(u"Sort by time", sort_time), (u"Sort by sender", sort_sender), (u"Unread first", sort_unread)] print "INBOX SORTER STARTED" app_lock = e32.Ao_lock() app_lock.wait()
# Copyright (c) 2006 Jurgen Scheible # This script waits for an incoming sms, reads its # content and shows it inside a pop-up note # NOTE: PyS60 version 1.3.14 or higher is needed to run this script. import inbox import e32 import audio def read_sms(id): e32.ao_sleep(0.1) sms_text = i.content(id) audio.say(sms_text) i = inbox.Inbox() print "send now sms to this phone" i.bind(read_sms)
def message_received(msg_id): box = inbox.Inbox() appuifw.note(u"New message: %s" % box.content(msg_id)) app_lock.signal()
def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) self.inbox_obj = inbox.Inbox(inbox.EInbox) self.sent_obj = inbox.Inbox(inbox.ESent) self.inbox_obj.bind(self.inbox_callback)