-
Documentation
- To check your current pyIPCS version:
pip show pyipcsfrom pyipcs import Hex, IpcsSession, Subcmd
from pyipcs.util import *
# Create IpcsSession object
# Manages settings for your IPCS session
session = IpcsSession()
# Open IPCS Session
session.open()
# String dataset name of z/OS dump
dsname = ...
# Create Dump object `dump`
# Initializes z/OS dump and stores general info
dump = session.init_dump(dsname)
# Print the dump title
# "SAD", "SVCD", "TDMP", "SYSM", or "SLIP"
if "dump_type" in dump.header:
print(dump.header["dump_type"])
else:
print("Dump Type Not Found")
# Run IPCS subcommand against z/OS dump `dump` and store output
subcmd = Subcmd(session, "STATUS REGISTERS")
# Print portion of IPCS subcommand output
print(subcmd[10:20])
# Close IPCS Session
session.close()- In order to perform operations, pyIPCS creates temporary execs, DDIRs, and files while the IPCS Session is open.
- Please be aware of leftover datasets and files in the event of unintended cleanup failures.
-
High level qualifiers for pyIPCS temporary datasets
IpcsSession.hlqIpcsSession.hlq_full
-
Directories for pyIPCS temporary files
IpcsSession.directoryIpcsSession.directory_full
- Dependencies and Prerequisites
- pyIPCS Installation
-
Major Version (
1)- Indicates a significant update.
- Probable to include breaking changes that are not backward-compatible.
-
Minor Version (
2)- Adds new features or functionality.
- Mostly backward-compatible with previous versions within the same major version.
-
Patch Version (
3)- Fixes bugs or makes small improvements.
- Always backward-compatible.
- The Changelog file contains info on changes between each new version
- To report a bug or request a feature/update, please open a new issue.
- Once you open an issue, there are various templates
- Bug Report
- Feature Request
- Documentation Update
- Other requests you might have for pyIPCS
- Once you open an issue, there are various templates
- Follow the link above to get information on how to contribute to pyIPCS
- You can find practical usage examples and runnable scripts in the
/examplesdirectory
Bases: object
- Contains various methods and functionality to manage hex variables in an IPCS environment
- Accepts strings or integers as input
- value (str|int): Hex string or integer for hex value
- The
Hexobject supports a variety of arithmetic, logical, and bitwise operations - These operations include: + , - , * , / (integer division) , = , == , !=, < , <= , > , >= , % , | , &
from pyipcs import Hex
# Use int or str as input for hex value
x = Hex("A")
y = Hex(-10)
# Prints "A"
print(x)
# Prints "-A"
print(y)
# Arithmetic
a = Hex("8")
b = Hex(2)
c = a + b
d = a - b
e = a * b
f = a < b
g = a | b
# Prints "A"
print(c)
# Prints "6"
print(d)
# Prints "10"
print(e)
# Prints False
print(f)
# Prints "A" (b"1000" logical OR with b"0010")
print(g)- Get sign of hex value.
- str:
"-"or""depending on whether Hex is positive or negative
- Get unsigned hex value.
- pyipcs.Hex: Unsigned Hex
- Get 0 indexed nibble. Default 0 index is from left side of hex string.
- nibble (int): 0 indexed nibble position.
- from_right (bool, optional): If
Truewill make 0 index the right most nibble.Falseby Default.
- pyipcs.Hex: 0 indexed nibble at position
nibble
- Get 0 indexed byte. Default 0 index is from left side of hex string.
- byte (int): 0 indexed byte position.
- from_right (bool, optional): If
Truewill make 0 index the right most byte.Falseby Default.
- pyipcs.Hex: 0 indexed byte at position
byte
- Get 0 indexed half word. Default 0 index is from left side of hex string.
- half_word (int): 0 indexed half word position.
- from_right (bool, optional): If
Truewill make 0 index the right most half word.Falseby Default.
- pyipcs.Hex: 0 indexed half word at position
half_word
- Get 0 indexed word. Default 0 index is from left side of hex string.
- word (int): 0 indexed word position.
- from_right (bool, optional): If
Truewill make 0 index the right most word.Falseby Default.
- pyipcs.Hex: 0 indexed word at position
word
- Get 0 indexed doubleword. Default 0 index is from left side of hex string.
- doubleword (int): 0 indexed doubleword position.
- from_right (bool, optional): If
Truewill make 0 index the right most doubleword.Falseby Default.
- pyipcs.Hex: 0 indexed doubleword at position
doubleword
- Convert hex to an integer.
- int: Hex integer.
- Convert
Hexobject to a hex string.
- str: Hex string.
- Convert hex to character string.
- If there is an error reading the hex string to characters, will return empty string(
"").
- encoding (str, optional): Encoding to use to decode hex string. Default is
"ibm1047".
- str: Character string.
- Concatenate with other
HexObject.
- other (pyipcs.Hex|Iterable): other
Hexobject or Iterable ofHexobjects to concatenate to the end of the currentHexobject. Disregard sign of this variable in concatenation.
- pyipcs.Hex: Concatenated
HexObject.
- Convert hex string to new bit length.
- Will either pad hex string with 0s or truncate string at bit length.
- new_bit_length (int): New length of string in bits.
- pyipcs.Hex: Hex with new bit length.
- Determine bit length of hex string, not including leading 0s.
- int: Length in bits of hex string, not including leading 0s.
- Determine bit length of hex string, including leading 0s.
- int: Length in bits of hex string, including leading 0s.
- Turn on bit at 0 indexed bit position. Default 0 index is from left side of hex string.
- bit_position (int): 0 indexed bit position.
- from_right (bool, optional): If
Truewill make 0 index the right most bit.Falseby Default.
- pyipcs.Hex: Hex with bit at bit_position on
- Turn off bit at 0 indexed bit position. Default 0 index is from left side of hex string.
- bit_position (int): 0 indexed bit position.
- from_right (bool, optional): If
Truewill make 0 index the right most bit.Falseby Default
- pyipcs.Hex: Hex with bit at bit_position off.
- Check bit at 0 indexed bit position. Default 0 index is from left side of hex string.
- bit_position (int): 0 indexed bit position.
- from_right (bool, optional): If
Truewill make 0 index the right most bit.Falseby Default.
- bool:
Trueif bit is on,Falseif it is off.
class pyipcs.IpcsSession(hlq=None, directory=None, allocations={"IPCSPARM": ["SYS1.PARMLIB"], "SYSPROC": ["SYS1.SBLSCLI0"]})
Bases: object
- Manages TSO allocations, session EXECs and DDIRs, and controls settings for IPCS Session.
-
hlq (str|None, optional): High level qualifier where opened pyIPCS session is or will be under. pyIPCS session includes z/OS MVS datasets for pyIPCS EXECs and DDIRs. High level qualifier has a max length of 16 characters excluding
".". By default isNonewhich will set the high level qualifier as your userid. -
directory (str|None, optional): File system directory where IPCS session directories and files will be placed. By default is
Nonewhich will set the directory as the current working directory of executed file. -
allocations (dict[str,str|list[str]], optional): Dictionary of allocations where keys are DD names and values are string data set allocation requests or lists of cataloged datasets. The default allocations are dataset SYS1.PARMLIB for DD name IPCSPARM and dataset SYS1.SBLSCLI0 for DD name SYSPROC.
- userid (str): z/OS system userid for current user.
- hlq (str): High level qualifier where opened pyIPCS session is or will be under. pyIPCS session includes z/OS MVS datasets for pyIPCS EXECs and DDIRs.
- directory (str): File system directory where IPCS session directories and files will be placed. These include subcommand output files and other logs.
- active (bool):
Trueif IPCS session is active,Falseif not active. - aloc (pyipcs.IpcsAllocations): Manages TSO allocations for your IPCS session. IpcsAllocations Object.
- ddir (pyipcs.DumpDirectory): Manages dump directory(DDIR) functionality for your IPCS session. DumpDirectory Object.
- uid (str|None): Unique ID for open pyIPCS session.
Noneif pyIPCS session is not active. - hlq_full (str|None): Full high level qualifier for open pyIPCS session.
Noneif pyIPCS session is not active. - directory_full (str|None): Full directory where pyIPCS files for the open session will be placed.
Noneif pyIPCS session is not active.
- Opens IPCS/TSO Session.
- Create pyIPCS temporary datasets necessary for pyIPCS operations.
- None
- Closes IPCS/TSO Session.
- Deletes pyIPCS temporary EXECs and temporary DDIRs.
- None
- Initialize/Set dump
dsnameunder dump directoryddirand return Dump object. - Will set IPCS session DDIR to
ddir. - Will set IPCS default
DSNAMEtodsname
- dsname (str): Dump dataset name.
- ddir (str, optional): Dump directory. If an empty string, dump will be initialized under temporary DDIR.
- use_cur_ddir (bool, optional): Use current session DDIR. Will use the IpcsSession attribute
ddirto initialize the dump under. This will take precedence over this function'sddirparameter. Default isFalse.
- pyipcs.Dump
- Set IPCS session DDIR to Dump object DDIR.
- Set IPCS default
DSNAMEto Dump object dataset name.
- dump (pyipcs.Dump)
- None
- Read data from dump. Similar to EVALUATE subcommand in REXX.
- Make sure to set correct defaults
DSNAME,ASID, andDSPNAMEprior to calling this method. - EVALUATE Subcommand
- hex_address (pyipcs.Hex|str|int): Starting hex address to read from.
- dec_offset (int): Byte offset from the starting address in decimal.
- dec_length (int): Byte length of data to access in decimal.
- pyipcs.Hex: Hex object representing the data at the specified address.
Bases: object
- Manages TSO allocations for IPCS Session.
- Get TSO allocations for your IPCS session.
- dict[str,str|list[str]]: Returns dictionary of all allocations where keys are DD names and values are string data set allocation requests or lists of cataloged datasets.
- Set a single TSO allocation for your IPCS session.
- dd_name (str)
- specification (str|list[str]): String data set allocation request or list of cataloged datasets.
- extend (bool, optional): If
Trueand DD namedd_namealready exists, will add list of datasets fromspecificationtodd_name. Default isFalse.
- None
- Remove a specific TSO allocation from your IPCS session by DD name if it exists.
- dd_name (str)
- None
- Update multiple TSO allocations for your IPCS session.
- new_allocations (dict[str,str|list[str]]): Dictionary of allocations where keys are DD names and values are string data set allocation requests or lists of cataloged datasets.
- clear (bool, optional): If
Truewill clear all allocations before update. Default isTrue. - extend (bool, optional): If
True, andclearisFalse, and DD name already exists, will add list of datasets from specification to DD name. Default isFalse.
- None
- Clear all TSO allocations for your IPCS session.
- None
Bases: object
- Manages dump directory(DDIR) for IPCS Session
- dsname (str|None): Dataset name of dump directory for your IPCS session.
Noneif dump directory is not set.
- dsname (str): Dump directory that will be set as the session's DDIR.
- None
- Create dump directory.
- Uses
BLSCDDIRCLIST to create DDIR. - Adding additional keyword arguments will fully override pyIPCS DDIR presets.
- BLSCDDIR CLIST
- dsname (str)
- kwargs (dict, optional): Additional parameters (see other parameters)
- dataclas (str, optional)
- mgmtclas (str, optional)
- ndxcisz (int, optional)
- records (int, optional)
- storclas (str, optional)
- volume (str, optional)
- blscddir_params (str, optional): String of
BLSCDDIRparameters. Write parameters as you would in regular IPCS (ex:"NDXCISZ(4096)").
- None
- Create temporary dump directory. Will be deleted on IPCS session close.
- Uses
BLSCDDIRCLIST to create DDIR. - Adding additional keyword arguments will fully override pyIPCS DDIR presets.
- BLSCDDIR CLIST
- kwargs (dict, optional): Additional parameters (see other parameters)
- dataclas (str, optional)
- mgmtclas (str, optional)
- ndxcisz (int, optional)
- records (int, optional)
- storclas (str, optional)
- volume (str, optional)
- blscddir_params (str, optional): String of
BLSCDDIRparameters. Write parameters as you would in regular IPCS (ex:"NDXCISZ(4096)").
- None
- Presets for dump directory creation.
- Parameters that will be added to BLSCDDIR for pyIPCS dump directory creation.
- Input optional parameters to change presets.
- BLSCDDIR CLIST
- kwargs (dict, optional): Additional parameters (see other parameters)
- dataclas (str, optional): Specifies the data class for the new directory. If you omit this parameter, there is no data class specified for the new directory.
- mgmtclas (str, optional): Specifies the management class for the new directory. If you omit this parameter, there is no management class specified for the new directory.
- ndxcisz (int, optional): Specifies the control interval size for the index portion of the new directory. If you omit this parameter, the IBM-supplied default is 4096 bytes.
- records (int, optional): Specifies the number of records you want the directory to accommodate. If you omit this parameter, the IBM-supplied default is 5000; your installation's default might vary.
- storclas (str, optional): Specifies the storage class for the new directory. If you omit this parameter, there is no storage class specified for the new directory.
- volume (str, optional): Specifies the VSAM volume on which the directory should reside. If you omit DATACLAS, MGMTCLAS, STORCLAS, and VOLUME, the IBM-supplied default is VSAM01. Otherwise, there is no IBM-supplied default.
- blscddir_params (str, optional): String of
BLSCDDIRparameters. Write parameters as you would in regular IPCS (ex:"NDXCISZ(4096)").
- None
- Get dataset names of the sources described in the current dump directory of your IPCS session.
- Uses the
LISTDUMPIPCS subcommand. - LISTDUMP Subcommand
- list[str]: Returns list of dataset names of the sources described in current the dump directory of your IPCS session.
- Get/Set default values for certain parameters on IPCS subcommands for your IPCS session.
- Uses the
SETDEF LISTIPCS subcommand. - IPCS uses the new default value for both your current session and any subsequent sessions in which you use the same user dump directory, until you change the value.
- Note that pyIPCS only sets global defaults.
- SETDEF Subcommand
- kwargs (dict, optional): Additional parameters (see other parameters)
- confirm (bool, optional):
TrueforCONFIRMparameter.FalseforNOCONFIRMparameter. - dsname (str|None, optional): String dataset name to be used for
DSNAMEparameter.NoneforNODSNAMEparameter. - display (list[str], optional): List of sub parameters to be used for
DISPLAYparameter. Possible values in the list can include"MACHINE","REMARK","REQUEST","STORAGE","SYMBOL","ALIGN","NOMACHINE","NOREMARK","NOREQUEST","NOSTORAGE","NOSYMBOL","NOALIGN". - flag (str, optional): String severity to be used for
FLAGparameter. Possible string options includeERROR,INFORMATIONAL,SERIOUS|SEVERE,TERMINATING,WARNING. - length (pyipcs.Hex|str|int, optional): pyipcs.Hex object or string or int to be used for
LENGTHparameter. - pds (bool, optional):
TrueforPDSparameter.FalseforNOPDSparameter. - asid (pyipcs.Hex|str|int, optional): pyipcs.Hex object or string or int to be used for
ASIDparameter. - dspname (str, optional): String dataspace name to be used for
DSPNAMEparameter. - setdef_params (str, optional): String of
SETDEFparameters. Write parameters as you would in regular IPCS (ex:"ACTIVE LENGTH(4)").
- pyipcs.SetDef: Custom
SETDEFSubcmd Object. SetDef Custom Subcmd Object
Bases: pyipcs.Subcmd
- SetDef Custom Subcmd Object
- Runs
SETDEFwithLISTparameter and other parameters - SETDEF subcommand
- Address processing parameters
- Can generate SetDef object using
pyipcs.IpcsSession.ddir.defaults(..) - Only Global Defaults impact the pyIPCS session.
- data (dict): Global Defaults. Keys may not appear if information is unknown or unavailable.
- "confirm" (bool):
TrueforCONFIRM.FalseforNOCONFIRM. - "dsname" (str|None): String dataset name for parameter
DSNAME.NoneforNODSNAME. - "display" (list[str]|None): List of sub parameters for
DISPLAYparameter.NoneifDISPLAYis not in output. Possible values in the list can include"MACHINE","REMARK","REQUEST","STORAGE","SYMBOL","ALIGN","NOMACHINE","NOREMARK","NOREQUEST","NOSTORAGE","NOSYMBOL","NOALIGN". - "flag" (str|None): String severity for parameter
FLAG.NoneifFLAGis not in output. Possible string options include"ERROR","INFORMATIONAL","SERIOUS"|"SEVERE","TERMINATING","WARNING". - "length" (pyipcs.Hex|None): pyipcs.Hex object for parameter
LENGTH.NoneifLENGTHis not in output. - "pds" (bool):
TrueforPDS.FalseforNOPDS. - "asid" (pyipcs.Hex|None): pyipcs.Hex object for parameter
ASID.NoneifASIDis not in output. - "dspname" (str|None): String dataspace name for parameter
DSPNAME.NoneifDSPNAMEis not in output.
- "confirm" (bool):
Bases: dict
- Custom Dictionary with info about a dump from the dump header.
- Does not require dump initialization to instantiate object.
- Reference dump header either with
header = DumpHeader(YOUR.DUMP.DSNAME)or referencingpyipcs.Dump.header. Dump Object - Keys may not appear if information is unknown or unavailable.
- dsname (str): Dump Dataset Name.
- "dump_type" (str):
"SAD","SVCD","TDMP","SYSM", or"SLIP" - "sysname" (str)
- "date_local" (str)
- "time_local" (str)
- "title" (str)
- "original_dump_dsn" (str)
- "version" (int): For example z/OS version
3release1 - "release" (int): For example z/OS version
3release1 - "sdrsn" (str)
- "complete_dump" (bool)
- "home_jobname" (str)
- "primary" (pyipcs.Hex)
- "secondary" (pyipcs.Hex)
- "home" (pyipcs.Hex)
- "sdwa_asid" (pyipcs.Hex)
- "sdwa_address" (pyipcs.Hex)
- "blocks_allocated_decimal" (int)
- "remote_sysname" (str): Appears only if
remote_dump=True - "remote_dump" (bool)
- "processor_serial_number" (str)
- "processor_model_number" (str)
- The following keys are unknown or unavailable if
dump_type="SAD":- "home_jobname"
- "primary"
- "secondary"
- "home"
- "sdwa_asid"
- "sdwa_address"
- "blocks_allocated_decimal"
- "remote_sysname"
- "remote_dump"
Bases: object
- Initializes a z/OS dump and stores general information.
- Can create a Dump object using
pyipcs.IpcsSession.init_dump()
- dsname (str): Dump dataset name.
- ddir (str): Dump directory when dump was initialized.
- header (pyipcs.DumpHeader): Custom dictionary object containing information about the dump from the dump header. DumpHeader Object
- data (dict): Dictionary containing general information about the dump from various subcommands. Editable by user to store additional info about a dump. Keys may not appear if information is unknown or unavailable.
- "sliptrap" (str): Included in
datadictionary if the dump is a SLIP dump. Obtained fromLIST SLIPTRAPsubcommand. - "ipl_date_local" (str): Known if CSA is dumped.
Obtained from
IPLDATAsubcommand. - "ipl_time_local" (str): Known if CSA is dumped. Obtained from
IPLDATAsubcommand. - "asids_dumped" (list[pyipcs.Hex]): List of ASIDs that were dumped. Obtained from
CBF RTCTsubcommand. - "asids_all" (list[dict]): Info about all asids on the system at the time of the dump. List of dictionaries containing the hex asid, string jobname, and ASCB address. Obtained from
SELECT ALLsubcommand.- "asid" (pyipcs.Hex)
- "jobname" (str)
- "ascb_addr" (pyipcs.Hex)
- "storage_areas" (list[dict]): Info about dumped storage areas. Contains dataspace information. Obtained from
LISTDUMPsubcommand withDSNAMEandSELECTparameters.- "asid" (pyipcs.Hex)
- "total_bytes" (pyipcs.Hex|None): Total number of bytes dumped for ASID in hex.
Noneif total_bytes for ASID is not defined inLISTDUMP. - "sumdump" (pyipcs.Hex): Number of SUMMARY DUMP Data bytes dumped in hex.
- "dataspaces" (dict): Dictionary where the keys are the string dataspace names. Values are
Hexobjects containing the number of bytes dumped for dataspace.
- "sliptrap" (str): Included in
- Get Jobname from ASID.
- Obtained info from
SELECT ALLsubcommand.
- asid (pyipcs.Hex|str|int)
- str|None: Jobname associated with ASID or
Noneif ASID is not found.
- Get ASID from Jobname.
- Obtained info from
SELECT ALLsubcommand.
- jobname (str)
- list[pyipcs.Hex]: List of ASIDs associated with
jobname.
- Get ASCB address from ASID.
- Obtained info from
SELECT ALLsubcommand.
- asid (pyipcs.Hex|str|int)
- pyipcs.Hex|None: ASCB address associated with ASID or
Noneif ASID is not found.
Bases: object
- Runs IPCS subcommand and stores output in string or file.
- session (pyipcs.IpcsSession)
- subcmd (str): IPCS subcommand to run.
- outfile (bool, optional): If
True, will create and store output in directory[pyipcs.IpcsSession.directory_full]/subcmd_output/. File would then be specified inoutfileattribute of Subcmd object. IfFalse, stores output in string specified inoutputattribute of Subcmd object. Default isFalse. - keep_file (bool, optional): If
Truepreserves subcommand output file after program execution. IfFalsedeletes subcommand output file after program execution. Default isFalse. - auth (bool, optional): If
True, subcommand will be run from an authorized environment. Default isFalse.
- subcmd (str): IPCS subcommand that was ran.
- outfile (str|None): File containing subcommand output.
Noneifoutfileparameter in constructor was set toFalseor if file was deleted withpyipcs.Subcmd.delete_file()method. - output (str): Returns string containing the entire subcommand output.
- keep_file (bool): If
Truepreserves subcommand output file after program execution. IfFalsedeletes subcommand output file after program execution. Editable by user. - rc (int): Return code from running subcommand.
- data (dict): Editable by user to store additional info about a IPCS subcommand. Initially empty.
- There are a few methods of extracting data from subcommand output
-
Find Methods: Find the index of a particular string within subcommand output.
Subcmd.findSubcmd.rfind
-
Get Field Methods: Get a particular value within subcommand output based on a label that precedes the value.
Subcmd.get_fieldSubcmd.get_field2Subcmd.rget_fieldSubcmd.rget_field2
-
Direct Indexing
subcmd = Subcmd(session, "STATUS REGISTERS") # indexed_output = string of portion of subcommand output indexed_output = subcmd[10:20]
-
- Find the first occurrence of a substring. Returns
-1if the value is not found.
- substring (str): Substring to search for.
- start (int, optional): Index where to start the search. Default is
0. - end (int|None, optional): Index where to end the search. Default is
Nonefor the end of the output.
- int: Output index where substring was found.
-1if substring was not found.
- Find the last occurrence of a substring. Returns
-1if the value is not found.
- substring (str): Substring to search for.
- start (int, optional): Index where to end the reverse search. Default is
0. - end (int|None, optional): Index where to start the reverse search. Default is
Nonefor the end of the output.
- int: Output index where substring was found.
-1if substring was not found.
- Attempts to get the field value from the output based on a label, separator, and end string.
- label (str): The label of the field.
- end_string (str): End string that indicates the end of the value.
- separator (str, optional): The separator between the label and the value.
- start (int, optional): Index where to start the search. Default is
0. - end (int|None, optional): Index where to end the search. Default is
Nonefor the end of the output. - to_hex (bool, optional): Return value as pyipcs.Hex if
to_hexisTrue. Default isFalsefor returning a string.
- list: A list
[value (str|pyipcs.Hex), start (int), end (int)]wheresubcmd[start:end] == value.[None, -1, -1]if field is not found.
- Attempts to get the field value from the output based on a label, separator, and field length.
- label (str): The label of the field.
- length (int): Length of the value to get.
- separator (str, optional): The separator between the label and the value.
- start (int, optional): Index where to start the search. Default is
0. - end (int|None, optional): Index where to end the search. Default is
Nonefor the end of the output. - to_hex (bool, optional): Return value as pyipcs.Hex if
to_hexisTrue. Default isFalsefor returning a string.
- list: A list
[value (str|pyipcs.Hex), start (int), end (int)]wheresubcmd[start:end] == value.[None, -1, -1]if field is not found.
- Attempts to get the field value in a reverse search from the output based on a label, separator, and end string.
- label (str): The label of the field.
- end_string (str): End string that indicates the end of the value.
- separator (str, optional): The separator between the label and the value.
- start (int, optional): Index where to end the reverse search. Default is
0. - end (int|None, optional): Index where to start the reverse search. Default is
Nonefor the end of the output. - to_hex (bool, optional): Return value as pyipcs.Hex if
to_hexisTrue. Default isFalsefor returning a string.
- list: A list
[value (str|pyipcs.Hex), start (int), end (int)]wheresubcmd[start:end] == value.[None, -1, -1]if field is not found.
- Attempts to get the field value in a reverse search from the output based on a label, separator, and field length.
- label (str): The label of the field.
- length (int): Length of the value to get.
- separator (str, optional): The separator between the label and the value.
- start (int, optional): Index where to end the reverse search. Default is
0. - end (int|None, optional): Index where to start the reverse search. Default is
Nonefor the end of the output. - to_hex (bool,optional). Return value as pyipcs.Hex if
to_hexisTrue. Default isFalsefor returning a string.
- Method to preemptively delete file associated with subcommand. Will not be able to index into file output after completion.
- None
-
pyIPCS allows users to create custom
Subcmdobjects for specific subcommands and or specific issues. -
Users can use the
dataattribute of theSubcmdobjects to store additional info.
from pyipcs import IpcsSession, Subcmd
class YourSubcmd(Subcmd):
def __init__(self, session:IpcsSession) -> None:
# Call constructor from original Subcmd object
super().__init__(session, "YOUR SUBCMD")
# Store additional info in data dict attribute
self.data["data_key"] = "data_value"
session = IpcsSession()
session.open()
# String dataset name of z/OS dump
dsname = ...
dump = session.init_dump(dsname)
# Run 'YOUR SUBCMD' with custom Subcmd object
your_subcmd = YourSubcmd(session)
# Will print 'data_value'
print(your_subcmd.data["data_key"])
session.close()- Back to Top
- is_dump
- psw_scrunch
- psw_parse
- opcode
- addr_key
- addr_fetch_protected
- is_hex
- IpcsJsonEncoder
from pyipcs.util import *- Determine whether dataset is a z/OS dump
- Will recall dataset if it exists.
- dsname (str): z/OS dataset name
- bool
- Scrunch 128 bit PSW to 64 bits
- If 64 bit PSW is inputted as argument return PSW as is
- psw (pyipcs.Hex): 128 bit PSW or 64 bit PSW
- pyipcs.Hex: 64 bit PSW
- Obtain data from PSW.
- psw (pyipcs.Hex): 128 bit PSW or 64 bit PSW.
- dict: data from PSW
- "enabled" (bool|None):
Truefor Enabled for I/O and External Interrupts if bit 6 and 7 are on.Falsefor Disabled for I/O and External Interrupts if they are both off.Noneif one of either bit 6 or 7 is on and one is off. - "key" (int): PSW key.
- "privileged" (bool):
Truefor supervisor state(privileged).Falsefor problem program state(unprivileged) - "asc_mode" (str): One of either
"PRIMARY","AR","SECONDARY", or"HOME". - "cc" (int): Condition code.
- "amode" (int|None): Either
24,31,64, orNoneif invalid. - "instr_addr" (pyipcs.Hex): Instruction address.
- "enabled" (bool|None):
- Get mnemonic of instruction.
- Runs
OPCODEsubcommand.
- session (pyipcs.Session)
- instr (str|int|pyipcs.Hex): Instruction to get mnemonic from.
- str|None: Instruction mnemonic. Returns
NoneifOPCODEsubcommand returns with non-zero return code or mnemonic can't be found.
- Get storage key of storage address.
- Runs
LISTsubcommand with theDISPLAYparameter. - Make sure to set correct defaults
DSNAME,ASID, andDSPNAMEprior to calling this function.
- session (pyipcs.IpcsSession)
- storage_addr (str|int|pyipcs.Hex): Storage Address.
- int|None: Storage key. Returns
NoneifLISTsubcommand with theDISPLAYparameter subcommand returns with non-zero return code or key can't be determined.
- Return if storage address is fetch protected.
- Runs
LISTsubcommand with theDISPLAYparameter. - Make sure to set correct defaults
DSNAME,ASID, andDSPNAMEprior to calling this function.
- session (pyipcs.IpcsSession)
- storage_addr (str|int|pyipcs.Hex): Storage Address.
- bool:
Trueif storage_addr is fetch protected,Falseif not. ReturnsNoneifLISTsubcommand with theDISPLAYparameter subcommand returns with non-zero return code or fetch protected can't be determined.
- Check if string is hex
- hex_str (str)
- bool:
Trueif string is hex,Falseif not.
Bases: json.JSONEncoder
- Custom pyIPCS JSON Encoder.
- Can be specified in the
clsparameter ofjson.dumpandjson.dumpsfunctions to convertHex,Dump, andSubcmdobjects to JSON.
- pyIPCS objects can be converted to JSON using the IpcsJsonEncoder object from the
utillibrary.
- Examples:
import json
from pyipcs import Hex, IpcsSession, Subcmd
from pyipcs.util import IpcsJsonEncoder
# Setup
dsname = ...
session = IpcsSession()
dump = session.init_dump(dsname)
subcmd = Subcmd(session, "STATUS REGISTERS")
# Convert Hex, Dump, and Subcmd objects to JSON strings
hex_json = json.dumps( { "Key": Hex("1") }, cls=IpcsJsonEncoder)
dump_json = json.dumps(dump, cls=IpcsJsonEncoder)
subcmd_json = json.dumps(subcmd, cls=IpcsJsonEncoder)
# Write Subcmd JSON to file
with open("output.json", "w") as f:
json.dump(subcmd, f, cls=IpcsJsonEncoder)HexJSON
{
"__ipcs_type__": "Hex"
"value" (str)
}DumpJSON:
{
"__ipcs_type__": "Dump"
"dsname" (str)
"ddir" (str)
"header" (str)
"data" (dict)
}SubcmdJSON
{
"__ipcs_type__": "Subcmd"
"subcmd" (str)
"outfile" (str|None)
"output" (str),
"keep_file" (bool)
"rc" (int)
"data" (dict)
}