If you want to use the sys module then you have to import it just like you import other modules. Simply write import sys at the top. I'm having trouble making thp's script behave nicely because of the generator object from which he prints the alarms.
If you can settle for just the next alarm, here is my script added with a special character at the end of the line.