pmarti/python-messaging

Setting (relative) sms.validity causes TypeError

amilkh opened this issue · 6 comments

Hi,

I downloaded the latest version of python-messaging with sudo apt-get install python-messaging
I also built the documentation using the pmarti git-hub repository and tried the sample code. However, I get an error.
Below is the complete trace. I am on Ubuntu 12.04

Any ideas?

amil@amil-ubuntu:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import timedelta
>>> from messaging.sms import SmsSubmit
>>> 
>>> sms = SmsSubmit("+44123231231", "this SMS will auto-destroy in 5 hours")
>>> sms.validity = timedelta(hours=5)
>>> pdu = sms.to_pdu()[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.10-py2.7.egg/messaging/sms/submit.py", line 83, in to_pdu
    sms_msg_pdu = self._get_msg_pdu()
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.10-py2.7.egg/messaging/sms/submit.py", line 235, in _get_msg_pdu
    msgvp_pdu = encode_str(chr(msgvp))
TypeError: integer argument expected, got float
>>> 

Thanks for the report, we will look at it asap. I'm on holidays at the moment.

Hi amilkh,
Thanks for the bug report. I just pushed a little fix for this to the git repo. Please let me know if it fixes it for you?

Regards,

Andrew

Thanks for the quick responses!
I installed the latest code by doing:

  1. sudo apt-get remove python-messaging
  2. (from /usr/local/src) sudo git clone https://github.com/pmarti/python-messaging.git
  3. cd python-messaging/
  4. sudo python setup.py build
  5. sudo python setup.py install

However, I got the same error:

amil@amil-ubuntu:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import timedelta
>>> from messaging.sms import SmsSubmit
>>> 
>>> sms = SmsSubmit("+44123231231", "this SMS will auto-destroy in 5 hours")
>>> sms.validity = timedelta(hours=5)
>>> pdu = sms.to_pdu()[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.12-py2.7.egg/messaging/sms/submit.py", line 83, in to_pdu
    sms_msg_pdu = self._get_msg_pdu()
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.12-py2.7.egg/messaging/sms/submit.py", line 235, in _get_msg_pdu
    msgvp_pdu = encode_str(chr(msgvp))
TypeError: integer argument expected, got float
>>> 
>>> print pdu.length, pdu.pdu

Any ideas?
Also, how do I uninstall old version of python-messaging if I installed it using setup.py?

PS: I am using the 64-bit version of Ubuntu 12.04 LTS.

Hi,
Well stackoverflow has this thread http://stackoverflow.com/questions/1550226/python-setup-py-uninstall , but I can't say I've tried any of them as I normally use packages. It's odd that the setup doesn't just overwrite the files that changed. Do you see the latest commit if you do 'git log'? If not, do 'git checkout -f master ; git fetch --all ; git pull'

Andrew

I do think that it updated correctly because I have version 0.5.12 as the
log I postes shows.

I'll let you know what git log says when I get on my computer.

Sorry, I had actually not gotten the latest commit. I re-cloned the repository to a new directory and built it.
It works now!
Thank you very much for the quick help and for writing this library.

amil@amil-ubuntu:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import timedelta
>>> from messaging.sms import SmsSubmit
>>> 
>>> sms = SmsSubmit("+44123231231", "this SMS will auto-destroy in 5 hours")
>>> sms.validity = timedelta(hours=5)
>>> pdu = sms.to_pdu()[0]
>>> 
>>> print pdu.length, pdu.pdu
47 0011000B914421231332F100003B2574747A0E9A36A7A07B9ACD0685EBF4778B5C9ED3E5EF3C28ED06D540E8775D3E07
>>>