Integrating mouseLook into Python code without using Blender text editor

I have been working on building a game, (with tutorial), have even discovered how to add logic bricks via Python code, and I was wondering if there is a way to actually integrate the mouseLook.py file into the code . . . . that way I do not have to monkey with the Blender interface every time I run the code. What I have so far is this:


import bpy
bpy.ops.object.select_all(action='TOGGLE')
bpy.ops.object.select_pattern(pattern="Camera")
bpy.context.scene.objects.active = bpy.data.objects["Camera"]
bpy.context.scene.render.engine = 'BLENDER_GAME'

# Start building logic blocks.
obj = bpy.context.object
sensors = obj.game.sensors
controllers = obj.game.controllers
actuators = obj.game.actuators

# Add first set of logic bricks - Forward
bpy.ops.logic.sensor_add(type='MOUSE', name='mouse', object=obj.name)
bpy.ops.logic.controller_add(type='PYTHON', object=obj.name)
bpy.ops.logic.actuator_add(type='MOTION', name="UpDown", object=obj.name)

# Newly added logic blocks will be the last ones:
sensor = sensors[-1]
controller = controllers[-1]
actuator = actuators[-1]

sensor.link(controller)
actuator.link(controller)
sensor.use_pulse_true_level = True
sensor.mouse_event = 'MOVEMENT'
controller.text = bpy.data.texts["mouseLook.py"]

If you run this code, (providing the camera name is “Camera”, and you have the mouseLook script in the text editor), all of the logic bricks will be put in place, linked, and ready to go . . . . The last line of code takes the mouseLook.py file and adds it to the controller . . . . this is where I am hitting a dead end. What I would like to do is, instead of loading it from the text editor every time I run the code, is have something like:


mmstr = "cont = bge.logic.getCurrentController()
own = cont.owner
mouse = cont.sensors['mouse']
rotx = cont.actuators['rotx']
roty = cont.actuators['roty']  etc., (from mouseLook script)

Then load mmstr into the controller somehow. I know it is possible to load the file from a disk into the text editor, but I would rather have it so that if someone picks up the code off of my website, they can run it without even bothering to monkey with the script, nor would I need to mess with it each time I run the script! Maybe it is just asking to much, I don’t know . . . I think that it would be a lot faster to be able to just run the code and not worry about the mouseLook script.