How to hook empties to points of a curve programmatically? Here is a sample code which creates a primitive bezier spline (location1 and 2 are the control points' location):

def createBezierCurve(location1, location2):
    dirVect = getNormalizedDirVector(convertDictCoordToTuple(tableCenterCoords), convertDictCoordToTuple(refTableCenterCoords))
    bpy.ops.curve.primitive_bezier_curve_add()
    obj = bpy.context.object
    obj.data.dimensions = '3D'
    obj.data.fill_mode = 'FULL'
    obj.data.bevel_depth = 0.02
    obj.data.bevel_resolution = 12

    obj.data.splines[0].bezier_points[0].co = location1
    obj.data.splines[0].bezier_points[0].handle_left = addVectors(location1, dirVect)
    obj.data.splines[0].bezier_points[0].handle_right = subtractVectors(location1, dirVect)
    obj.data.splines[0].bezier_points[0].handle_left_type = 'VECTOR'

    empty1 = bpy.data.objects.new("EmptyObject", None)
    empty1.location = location1
    bpy.context.scene.objects.link(empty1)
    hookmod1 = obj.data.splines[0].bezier_points[0].modifiers.new("Hook", type='HOOK')
    hookmod1.object = empty1

    obj.data.splines[0].bezier_points[1].co = location2
    obj.data.splines[0].bezier_points[1].handle_left = addVectors(location2, dirVect)
    obj.data.splines[0].bezier_points[1].handle_right = subtractVectors(location2, dirVect)
    obj.data.splines[0].bezier_points[1].handle_left_type = 'VECTOR'

    empty2 = bpy.data.objects.new("EmptyObject", None)
    empty2.location = location2
    bpy.context.scene.objects.link(empty2)
    hookmod2 = obj.data.splines[0].bezier_points[1].modifiers.new("Hook", type='HOOK')
    hookmod2.object = empty2


What I couldn't find is how to hook the points to these empties?
To add a hook modifier

Following code adds a hook modifier. named Hook1,  to the curve object CurveOB and sets the hook object to Empty1

hookmod = curveOB.modifiers.new("Hook1", type='HOOK')
hookmod.object = empty1