Check if a mesh has an UV Channel in Python
This will do the trick:

import bpy

# Check if active object has any UV layers
if not len( bpy.context.object.data.uv_layers ):
    bpy.ops.uv.smart_project() # Perform smart UV projection