AppleScript has a number of limitations when run remotely, via the command line. For example, I logged into my home machine and tried the sleep command and here's what I got:
Ripley:~ andrew$ osascript -e 'tell app "Finder" to sleep'
kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only
INIT_Processeses(), could not establish the default connection to the WindowServer.Abort trap
If i try to run it as root, as the error message suggests, I get:
21:26: execution error: Finder got an error: Application isn't running. (-600)
I get the same errors when running your python version.
There is a small app called SleepNow (see http://sleepnow.darwinports.com/) that will work under those conditions.