Python 2.8 - forcing the correct instance of the image/uv editor
You do not need to mess around with the UI or change the layout at all if all you want to do is update a piece of data within an object.

You can dig down into any variable's type interactively in the scripting console without even having to look up the documentation. Autocomplete via ctrl-space, or calling dir(obj) and type(foo) describes just about anything.

So all you need to do is dig down to find where the UV coordinates are stored, and multiply them directly.

Here's how that would look for your script.

import bpy

bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=0.2, depth=30, enter_editmode=False, location=(0,0,0))
TextureFolder = 'G:\\Blender\\Textures\\'
TextureFilename = 'wildtextures-zinc-galvanized-metal-sheet.jpg'


def obj_material_texture_UVscale(objname, filename, Xscale, Yscale, Zscale):
    path = TextureFolder+filename
    materials = bpy.data.materials
    material = materials.get('mat')
    if not material:
        material = materials.new('mat')
    material.use_nodes = True
    if material.node_tree:
        material.node_tree.links.clear()
        material.node_tree.nodes.clear()
    nodes = material.node_tree.nodes
    links = material.node_tree.links
    output = nodes.new(type = 'ShaderNodeOutputMaterial' )
    diffuse = nodes.new(type = 'ShaderNodeBsdfDiffuse' )
    imgTex = bpy.data.images.load(path)
    node_texture = nodes.new(type='ShaderNodeTexImage')
    node_texture.image = imgTex
    node_texture.location = 0,200    
    tex_coord = nodes.new(type = 'ShaderNodeTexCoord')#NEW 
    links = material.node_tree.links
    link = links.new(tex_coord.outputs["UV"], node_texture.inputs["Vector"]) #NEW
    link = links.new(node_texture.outputs[0], nodes.get('Diffuse BSDF').inputs[0])
    link = links.new( diffuse.outputs['BSDF'], output.inputs['Surface'] )
    obj = bpy.data.objects[objname]
    obj.active_material = material
    bpy.ops.object.select_all(action='DESELECT')
    bpy.data.objects[objname].select_set(True)
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.uv.smart_project()
    bpy.ops.object.mode_set(mode='OBJECT')

    # Just directly scale the UVs!
    cyluvs = obj.data.uv_layers[0].data
    for cuv in cyluvs: # each is a bpy.types.MeshUVLoop
        cuv.uv[0] *= Xscale
        cuv.uv[1] *= Yscale

# len(o.data.uv_layers['UVMap'].data) -&gt; 192
# Each of these is a bpy.types.MeshUVLoop
# which has .uv, .select, .select_edge, .pin_uv.
# item.uv is a Vector. We can just scale its Y 30 times!

obj_material_texture_UVscale('Cylinder',TextureFilename,1,30,1)