dbrgn / pyxtra

A small commandline utility written in Python to access the (now dead) Swisscom Xtrazone SMS service
https://pypi.python.org/pypi/pyxtra
GNU General Public License v3.0
11 stars 2 forks source link

Error: string indices must be integers #7

Closed dbrgn closed 13 years ago

dbrgn commented 13 years ago

Sometimes, when sending an SMS the following Error is shown:

Error: string indices must be integers

My guess: after some hours (don't know how many) xtrazone "kills" the connection and at some place pyxtra fails.

Steps to fix: Disable the clean errors and wait for a stacktrace :)

dbrgn commented 13 years ago
Traceback (most recent call last):
  File "./pyxtra.py", line 471, in 
    main()
  File "./pyxtra.py", line 425, in main
    send_sms(browser, contacts, logging)
  File "./pyxtra.py", line 360, in send_sms
    if (resp['content']['headline'] != 'Verarbeitung erfolgreich' or
luxflux commented 13 years ago

got this error as well and thought the same... started now to log out after sending an sms. also tried to call "show contacts" from time to time, but didnt help. looks like its cached ;)

maybe you want to call sth periodically? so they dont close the connection?

dbrgn commented 13 years ago

they don't close the connection, it has to be something different. i'll try to fix it this week.

petermanser commented 13 years ago

@gwrtheyrn: the session seems to be expired. :)

here is the traceback:

> n!
Receiver(s): Danilo Bargen
Message: in your face.
{u'isException': False, u'mimeType': u'text/html', u'content': u'\n        <script type="text/javascript">\n        $(document).ready(function(){\n            Dialog.createLoginLayer("/index.php/20,53,ajax,,,283/?route=%2Fmessaging%2Foutbox%2Fsendmobilemsg");\n        });\n    </script>\n            \n    <div class="main-content-bg profile private">\n        <h2>Fehler</h2>       \n        <div id="privateProfile" class="main-content-wrapper">     \n            <p>Auf diese Inhalte kannst Du nicht zugreifen.</p>\n        </div>\n        <div class="main-content-footer"></div>\n    </div>\n\n', u'isOperationResponse': False, u'httpCode': 200}
Traceback (most recent call last):
  File "pyxtra.py", line 480, in <module>
    main()
  File "pyxtra.py", line 432, in main
    send_sms(browser, contacts, logging)
  File "pyxtra.py", line 367, in send_sms
    raise XtrazoneError('Unknown error sending SMS.')
__main__.XtrazoneError: Unknown error sending SMS.

hth.

dbrgn commented 13 years ago

Hopefully closed by 92fa47d5438d22f3ef18f05ab763ce69eb09e084 (Error: string indices must be integers)

dbrgn commented 13 years ago

I think I fixed the bug. The problem was an expired session indeed.

Please test the current devel version, and try to reproduce a reconnect after an expired session. The SMS about to be sent should be sent automatically after the reconnect (you will have to re-enter the CAPTCHA).

If someone can confirm this, I'll bump the version to 1.1 and upload a package.

petermanser commented 13 years ago

Reproduced. (Connected from other IP via VPN).

(xtra-sms)macbook-superpro:pyxtra peter$ python pyxtra.py 
Please enter CAPTCHA: knapp
Retrieving contacts...
Hi Peter Manser. You have 371 SMS remaining.
Use 'h' or 'help' to show available commands.
> n!
Receiver(s): Danilo Bargen
Message: foobar test1
SMS sent successfully.
370 SMS remaining.
Receiver(s): Danilo Bargen
Message: foobar2
Session has expired. Reconnecting.
Please enter CAPTCHA: ehemalige
SMS sent successfully.
369 SMS remaining.

Worked like a charm. Bump it! :)