How to get Hpr from direction vector

I have been developing that an CG object in Panda3D space is controlled with an information from the external sensor.

This sensor measures 3-dimensional position and direction vector of the real object moving in 3D real space.
And I am trying that the CG object moves in the same way to the real object.

The sensor gives only the direction vector, not Hpr.
So I have to convert the direction vector to Hpr because the Panda3D requires Hpr not direction vector to define the direction of the object.

But, I can not find the method to conversion.
Anyone could tell me the method.

Try the following:

def get_hpr(vector):
    quat = Quat()
    look_at(quat, vector, Vec3.up())
    return quat.get_hpr()

Note that the look_at method in the code above is imported from panda3d.core; it is not NodePath.look_at().

Alternatively, you could add the direction vector to the current position of the CG object and make the CG object look_at the resulting point:

pos = cg_object.get_pos()
target_pos = pos + vector
cg_object.look_at(target_pos, Vec3.up())