Sample Python script to demonstrate calling ChangeMan ZMF Plug-in for Zowe CLI

0 Likes

This sample Python script demonstrates how to call  the ChangeMan ZMF  plugin-in  for Zowe CLI.

import os
import sys
import json

def print_to_stdout(*a):
      print(*a, file = sys.stdout)

# get run time parms
folder = sys.argv[1]
comp = sys.argv[2]
type = sys.argv[3]
package = sys.argv[4]
zmf = sys.argv[5]

# Print Parameters
print('Running Python Script: ', __file__)
print_to_stdout(f"Parameters: Package({package}) Component({comp}) Library Type({type}) Output Folder({folder})")

# retrieve component using component-browse-package
print_to_stdout(f"Retrieving Component: Package({package}) Component({comp}) Library Type({type})")
command = f"zowe zmf browse pcomp -c {comp} -t {type} -p {package} --zmf-p {zmf} > {folder}/{comp}.{type}"
os.system(command)

# retrieve the list of copybooks using component-source-include-locate
command = f"zowe zmf get csil -p {package} -c {comp} -t {type} --zmf-p {zmf} > {folder}/list.json"
os.system(command)

with open(f"{folder}/list.json") as f:
       file = json.load(f)
array = file['result']

#retrieve each copybook using component-browse
for copybook in array:
     component = copybook['includedComponent']
     componentType = copybook['includedComponentType']
     print_to_stdout(f"Retrieving Component Dependency: Component({component}) Library Type({componentType})")
     command = f"zowe zmf browse comp -c {component} -t {componentType} -p {package} -b 3 --zmf-p {zmf} > {folder}/{component}.{componentType}"
     os.system(command)

# cleanup returned json
os.remove(f"{folder}/list.json")

Sr R&D Manager, Mainframe Products

Micro Focus

Labels:

New Release-Feature
Comment List
Anonymous
Related Discussions
Recommended