Use Python 3 features
Thanks for supplying the script!
The goal of this MR is to improve the readability and to use current Python (3) features. It makes use of f-strings to create strings, uses appropriate repr where applyable and represents states as an enum.
As I am testing on Windows the signal functions have been guarded in order to be able to run the script. Unfortunately this means the timeout handling will not work on Windows.