Posts Tagged python

paramiko: ssh scripting the ez way

The other day I wanted to jack around some goofy script and run it on a bunch of hosts, but… without keys, it was drag to do in a simple script… So… a buddy of mine had used paramiko to do some ssh action in python.

After reading Jesse‘s article, I used paramiko to copy a script around, run it and collect the output on the local filesystem

Here is some crap example:

import os
import paramiko
import socket
import sys

# yeh... my script really doesn't look like this...

host = ''
username = 'root'
password = 'passwords_are_for_cowards'

tmp  = '/tmp/'

# copy our cool_script over to the host in /tmp
transport = paramiko.Transport( ( host, 22 ) )
transport.connect( username = username, password = password )
sftp = paramiko.SFTPClient.from_transport( transport )
sftp.put( '', tmp )

# seems like ssh.connect sometimes fails due to some
# weird dns issue, so hack around it...
ip = socket.gethostbyname( host )

# chmod and run the script
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() )
ssh.connect( ip, username = username, password = password )
stdin, stdout, stderr = ssh.exec_command( 'chmod 755 ' + tmp + ';' + tmp )
data =

# save the output as json on the local filesystem
filename = host + '.json'
output = open( filename, 'w' )
output.write( data )


Leave a Comment

animatron: isometric sprite rendering script

Ok… I actually wrote this a while ago, but after seeing fambros’APC… I realized I needed to incorporate it into the blender UI.

Check it out:

Just drop into ${HOME}/.blender/scripts

Then you can open a “Script Window” and select it from Scripts -> Render -> Animatron.

Here are some sample from a project I’m working on now:

Of course this is just 1 direction, the point of the script is to provide 360 carved into a # of directions.

Anyhoo… my python is getting a little less ridiculous.

I think this should be true isometric now… based on stuff from wikipedia and stuff

Character Demo

Here is an initial demo. There are some minor cropping issues in a few actions / directions.

update 2010.09.18: another angle correction

As I started to use the script to render tiles, I realized something was not quite right. The tops aren’t squished properly! I compared the results to Tom Gersic’s efforts and the error is obvious:

So what was the dealio? It has to do with the nutty way spherical coordinates are defined: azimuth v/s inclination. Basically, I needed to subtract theta from 90 degrees. If you think about it, people using 45 degrees don’t have to deal with the issue, since 90 – 45 = 45, but since I used the kooky 35.264 (???) I was off quite a bit. Anyway… it is fixed now. But… I have to re-render all the character animations… šŸ˜¦

Leave a Comment

nltk wordnet comprehension madness

use nltk’s wordnet wrapper to pull all the lemma names for each hyponym of all the hyponums for each synonym set for the word “doctor” with the part of speech noun:

>>> [ ([ x.lemma_names for x in list_of_hyponyms if type(x.lemma_names) is type([""]) ]) for list_of_hyponyms in [ synset.hyponyms() for synset in wn.synsets( 'doctor', wn.NOUN ) ]  ]
[[['abortionist'], ['general_practitioner', 'GP'], ['intern', 'interne', 'houseman', 'medical_intern'], ['house_physician', 'resident', 'resident_physician'], ['hakim', 'hakeem'], ['specialist', 'medical_specialist'], ['allergist'], ['quack'], ['angiologist'], ['gastroenterologist'], ['extern', 'medical_extern'], ['veterinarian', 'veterinary', 'veterinary_surgeon', 'vet'], ['surgeon', 'operating_surgeon', 'sawbones']], [], [], []]

Leave a Comment