Rotate UV map in Python

So I have the following piece of code

original_area = bpy.context.area.type

ob = bpy.context.scene.objects.active
bpy.ops.object.mode_set(mode=‘EDIT’, toggle=False)

bpy.ops.uv.cube_project(cube_size=1.0, correct_aspect=True, clip_to_bounds=False, scale_to_bounds=False)
bpy.ops.uv.select_all(action=‘SELECT’)

bpy.context.area.type = (‘IMAGE_EDITOR’)

bpy.ops.transform.rotate(value= radians(90.0), axis=(0.0, 0.0, 1.0))

bpy.context.area.type = original_area
bpy.ops.object.mode_set(mode=‘OBJECT’, toggle=False)

It seems to crash right after I change the area to image editor. If I delete all lines before that one, then the code runs fine, but I am unable to paste another line of code into the console. Pressing enter merely returns me to the image editor, and putting even a single line after will cause Blender to crash. So what other way is there to rotate UV’s with Python?