def test1(): #url ="http://en.wikipedia.org/wiki/Topness" #Works url = "https://en.wikipedia.org/wiki/Bottom_quark" #Doesn't work page = getPage(url) for chunk in emulateSms(page, size=160): print chunk print byte_len(chunk) print "-------------------------------"
def test1(): #url ="http://en.wikipedia.org/wiki/Topness" #Works url ="https://en.wikipedia.org/wiki/Bottom_quark" #Doesn't work page = getPage(url) for chunk in emulateSms(page, size=160): print chunk print byte_len(chunk) print "-------------------------------"
def emulateSms(data, size=160, add_prologue=True): """ Emulates how some arbitrary text string will be fragmented when sent over SMS using Twilio """ #Twilio enforces this restriction if byte_len(data) > 1600: print "Unable to end message longer than 1600 chars" return if add_prologue: prologue = "Sent from your Twilio trial account - " data = prologue + data for chunk in chunk_iter(data, size=size): yield chunk
def test2(): data = "012345678[9" for sms in chunk_iter_offset(data, size=5, offset=3): print '"{}", byte_len is {}'.format(sms, byte_len(sms)) print "------------------"
def test1(): data = "012345678[9" for sms in emulateSms(data, size=5, add_prologue=False): print '"{}", byte_len is {}'.format(sms, byte_len(sms)) print "------------------"