Autosmooth script fails in edit mode but works in object mode
bpy.ops.object.shade_smooth() is only accessible from Object Mode (poll). To use it, you would have to toggle into Object Mode first. To shade in Edit Mode (using ops) you would have to use bpy.ops.mesh.faces_shade_smooth(). This will only work on selected faces though.