can not set the camera viewpoint? I want to use python to set the camera viewpoint but failed to do so, here is my code to render the model through python

import sys 
import os
import bpy 
import math 
import datetime

if __name__=="__main__":

    configureBlender()
    setCameraPosition([0.49123,-2.22974,6.74501],[123.942,0.578,0.1])
    run(os.path.dirname(os.path.realpath(__file__))+'/test')

def configureBlender():
    # rendering constants
    RENDER_RES_X = 640
    RENDER_RES_Y = 480
    FRAME_NO = 1
    bpy.context.scene.frame_current = FRAME_NO
    bpy.context.scene.render.resolution_x = RENDER_RES_X
    bpy.context.scene.render.resolution_y = RENDER_RES_Y
    bpy.context.scene.render.use_border = False

def run(output_dir):        
    bpy.context.scene.render.filepath = output_dir
    nodes = bpy.context.scene.node_tree.nodes
    links = bpy.context.scene.node_tree.links
    nodes['File Output'].base_path = output_dir
    bpy.ops.render.render(write_still=True)

def setCameraPosition(location, rotation):
    bpy.data.objects['Camera'].location = location
    bpy.data.objects['Camera'].rotation_euler = [math.radians(rotation[0]), math.radians(rotation[1]), math.radians(rotation[2]) ]


I don't know what is wrong with code or maybe model(anywhere to upload the model, it is 5mb)

update

for obj in bpy.data.objects:
    print(obj.name)


it prints out only one Camera object, i guess if there is only one camera, this camera must be the active camera.

Another wield thing is i changed the camera position and saved the model but it is still rendering with the previous viewpoint. so I guess maybe the code is fine but something wrong with the model.

here is my model link
Is this the entire script?  It looks like you forgot to import required modules.  

import os  
import math  

Edit:  

Er, well, I think Blender automatically does import math as *
so you'd remove the preceding math. from radians.  

I believe you'd still need to import os, unless I'm mistaken about that point.  

Edit  You have to define functions before you can run them in Python.  Don't know exactly what you're trying to accomplish with node tree in your run function, so I chopped that out for now, but this script at least runs.  


import bpy, os
from math import *

# rendering constants
RENDER_RES_X = 640
RENDER_RES_Y = 480
FRAME_NO = 1

def configureBlender():
    bpy.context.scene.frame_current = FRAME_NO
    bpy.context.scene.render.resolution_x = RENDER_RES_X
    bpy.context.scene.render.resolution_y = RENDER_RES_Y
    bpy.context.scene.render.use_border = False

def run(output_dir):
    bpy.context.scene.render.filepath = output_dir
    bpy.ops.render.render(write_still=True)

def setCameraPosition(location, rotation):
    bpy.data.objects['Camera'].location = location
    bpy.data.objects['Camera'].rotation_euler = [radians(rotation[0]), radians(rotation[1]), radians(rotation[2]) ]

if __name__ == "__main__":
    configureBlender()
    setCameraPosition([0.49123,-2.22974,6.74501],[123.942,0.578,0.1])
    run(os.path.dirname(os.path.realpath(__file__))+'/test')