ImperialViolet

Snippets (16 Dec 2003)

I like Artistic Licence a lot. Partly because they make some really cool stuff, but mostly because they sent me one of these for free.

(Yes, you too can get a positive mention on IV by sending me free hardware)

One of those, for people who don't know and can't understand the link, is an Art-Net to DMX converter. DMX is the serial protocol used for controling stage and event lighting and so I can now control this from a Python script.

So I'm frantically coding in whatever free time slots I can find so that I can use it to control a pair of MAC 600s on Friday.

Of course, like all good tasks, I don't get to test it until until the day of the event.

And on the frontpage of the manual, it reads:

This product is for professional use only. It is not for household use. This product presents risks of lethal or severe injury due to fire and heat, electric shock, ultraviolet radiation, lamp explosion and fall.

:)

While I'm thinking about it, a couple of Python snippets that I'm always looking for.

Dumping an exception is:

try:
    ...
except:
    traceback.print_exc ()

And running an interactive console looks like:

import threading
import rlcompleter
import readline

readline.parse_and_bind("tab: complete")

glock = threading.Lock ()
input_has_glock = 0
exit_event = threading.Event ()

def worker_thread ():
	# lock glock when running

if __name__ == "__main__":
        import __main__
        worker = threading.Thread (target = worker_thread)
        worker.start ()
        c = code.InteractiveConsole (locals=__main__.__dict__)
        c.raw_input = locking_raw_input
        c.interact ("Starting interactive control...")