How to rotate a bone using python
I assume you are rotating the bone in pose mode, for this you can use the following lines:

import math
import bpy

ob = bpy.data.objects['Armature']
bpy.context.scene.objects.active = ob
bpy.ops.object.mode_set(mode='POSE')

pbone = ob.pose.bones[bname]
# Set rotation mode to Euler XYZ, easier to understand
# than default quaternions
pbone.rotation_mode = 'XYZ'
# select axis in ['X','Y','Z']  &lt;--bone local
axis = 'Z'
angle = 120
pbone.rotation_euler.rotate_axis(axis, math.radians(angle))
bpy.ops.object.mode_set(mode='OBJECT')
#insert a keyframe
pbone.keyframe_insert(data_path="rotation_euler" ,frame=1)


the code from this wiki page , it contains useful scripts for batch job