zanac / pyHPSU

Python Script to read and send commands to a Rotex HPSU
29 stars 21 forks source link

pyHPSU.py - rendere retry configurabili #4

Open EmilianoMaina opened 7 years ago

EmilianoMaina commented 7 years ago

Estrarre dal codice e mettere in file di configurazione:

Grazie !

for c in hpsu.commands: i = 0 while i <= 3: rc = hpsu.sendCommand(c) if rc != "KO": i = 4 response = hpsu.parseCommand(cmd=c, response=rc, verbose=verbose) resp = hpsu.umConversion(cmd=c, response=response, verbose=verbose)

            arrResponse.append({"name":c["name"], "resp":resp, "timestamp":response["timestamp"]})
        else:
            i += 1
            **time.sleep(2.0)**
            hpsu.printd('warning', 'retry %s command %s' % (i, c["name"]))
            **if i == 4:**
                hpsu.printd('error', 'command %s failed' % (c["name"]))