PythonWin problems

So maybe its because I don’t understand python indentation system or I can blame it on pythonWin being HORRIBLE as an IDE. I am working with a telit device and can’t get the debug stuff to work. Just gives me errors and besides I need my serial port to talk to my device not my computer. I get most of my code to work fine but whenever I add another if statement or another big section of code it takes me 2 days of debuging before it runs right and I usually don’t change anything for instance.

              if (a != -1):
                MOD.watchdogEnable(75)
                firstdigit_pos = a + 12
                pos = res[firstdigit_pos:-2]
                SMSnumber = getSMSnumber(pos)
                SMSmessage = getSMSmessage(pos)
                SMSmessage = SMSmessage.lower()
                eb = SMSmessage.find('eb')
                sl = SMSmessage.find('sl')
                re = SMSmessage.find('re')
                nf = SMSmessage.find('nf')
                st = -1
                st = SMSmessage.find('st')
                del_all_SMS(pos)
                a = -1
                if (eb != -1):
                        b = -1
                        c = SMSmessage.find(' ')
                        pw = SMSmessage[0:c]
                        i = 0
                        while (b != 1):
                                b = ABR_login(pw)
                                i = i + 1
                                if (i > 4):
                                        e = 'Login Error'
                                        break
                                elif (b == 1):
                                        e = get_EB()
                        SER.send('BY\r')
                        sendSMS(SMSnumber, e)
                        eb = -1
                        b = -1
                        MOD.watchdogDisable()
                if (sl != -1):
                        b = -1
                        c = SMSmessage.rfind(' ')
                        pw = SMSmessage[0:c]
                        i = 0
                        while (b != 1):
                                b = ABR_login(pw)
                                i = i + 1
                                if (i > 4):
                                        e = 'Login Error'
                                        break
                                elif (b == 1):
                                        e = get_SL()
                        SER.send('BY\r')
                        sendSMS(SMSnumber, e)
                        sl = -1
                        b = -1
                        MOD.watchdogDisable()
                if (re != -1):
                        b = -1
                        c = SMSmessage.rfind(' ')
                        pw = SMSmessage[0:c]
                        i = 0
                        while (b != 1):
                                b = ABR_login(pw)
                                i = i + 1
                                if (i > 4):
                                        e = 'Login Error'
                                        break
                                elif (b == 1):
                                        e = ABR_soft_reset()
                        SER.send('BY\r')
                        sendSMS(SMSnumber, e)
                        re = -1
                        b = -1
                        MOD.watchdogDisable()
                if (nf != -1):
                        b = -1
                        c = SMSmessage.rfind(' ')
                        pw = SMSmessage[0:c]
                        i = 0
                        while (b != 1):
                                b = ABR_login(pw)
                                i = i + 1
                                if (i > 4):
                                        e = 'Login Error'
                                        break
                                elif (b == 1):
                                        e = get_NF()
                        SER.send('BY\r')
                        sendSMS(SMSnumber, e)
                        nf = -1
                        b = -1
                        MOD.watchdogDisable()
                if (st != 1):
                        b = -1
                        c = SMSmessage.rfind(' ')
                        pw = SMSmessage[0:c]
                        i = 0
                        while (b != 1):
                                b = ABR_login(pw)
                                i = i + 1
                                if ( i > 4):
                                        e = 'Login Error'
                                        break
                                elif ( b == 1):
                                        j = get_EB()
                                        k = get_SL()
                                        l = get_NF()
                                        e = j + '\r\n' + k + '\r\n' + l
                        SER.send('BY\r')
                        sendSMS(SMSnumber, e)
                        st = -1
                        b= -1
                        MOD.watchdogDisable()

Works great besides the last if statement I just added ALWAYS runs. Then I indented more then the rest and it never runs now. Am I missing something?

the a check works great. That indicates an sms message was received. Then the eb check is done if the command eb is issued same with the others. however all the others besides st return their set of data plus it runs through and sends the ST command as well. I’m totally lost

Jonathan,

In all of your other ‘if’ blocks you check to see if the value is not equal to -1. In the last ‘if’ block, you check to see if the value is not equal to positive 1. Could that be your problem?

Also, if you don’t like the PythonWin IDE, don’t use it. There are plenty of IDEs and Python aware text editors out there. Find one that you like. At least find one that you find less horrible.

-Michael

Thanks I think that might fix the problem. I knew it was something stupid I was missing.

I may need to switch editors because this one is killing me. I wanted to keep it because it works as a debugger as well but the stupid thing keeps spitting out massive errors in the IDE when it tries to do something and locks the program up and prevents me from opening the file again till I reboot. I guess I’ll just have to give up the dream of having a good debugger for this unit.