I am doing texture baking in headless mode and it works for me. Not sure what is the problem with your script but here is my script:
console_handler = logging.StreamHandler(sys.stdout)
log = logging.getLogger(__name__)
cuda_devices, opencl_devices = bpy.context.preferences.addons['cycles']...
It's because double newline char forces your class declaration terminated at line 5. So it complains the function draw is a bad indent.
The >>> in the snapshot indicates the problem. however I still don't know how to solve this copy paste class declaration in python console issue.
If you want to be able to launch it like any other application, the simplest way is to do this:
Launch Automator (it is in your Mac's Applications folder) and launch Terminal (it is in Applications/Utilities).
Create a new Application in Automator.
Type "run" in the variables search field, and drag Run Shell Script to the right part of the ...
Maybe it'll help you
**>>In the Timeline panel, display the layer property containing the keyframes you want to copy.
Select one or more keyframes.
Choose Edit > Copy.
In the Timeline panel containing the destination layer, move the current-time indicator to the point in time where you want the keyframes to appear.**