Python 2.8 - updating code sample from v. 2.63 (image rendering and saving) In 2.8, I am having difficulty adapting a code sample written for Blender/Python 2.63.  The intent is to save images of a scene using python.  The code was sourced from this post.  

In 2.8, the code throws an error on the following line.  The error message is 'AttributeError: 'SpaceView3D' object has no attribute 'viewport_shade''

area.spaces[0].viewport_shade = 'RENDERED'


The full code snippet is here:

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        area.spaces[0].viewport_shade = 'RENDERED'

bpy.context.scene.render.image_settings.file_format='JPEG'
bpy.context.scene.render.filepath = ".pic%0.2d.jpg"%i
bpy.ops.render.render(use_viewport = True, write_still=True)
The line to set the viewport shading needs to change from

area.spaces[0].viewport_shade = 'RENDERED'


to

area.spaces[0].shading.type = 'RENDERED'


since Blender 2.8's API has replaced viewport_shade. Here you can find the documentation of the Area, AreaSpaces, SpaceView3D (if the space is of type 'VIEW_3D') and View3DShading.

Although I'm wondering why you'd want to set the viewport shading if you intend to actually render the scene. In case this really is what you want I'd suggest getting the active space, which will be the one currently displayed.

for area in bpy.context.screen.areas: 
    if area.type == 'VIEW_3D':
        space = area.spaces.active
        space.shading.type = 'RENDERED'