Transcription of Getting started with Python on IBM i. - Gateway/400
1 Getting started with Python on IBM i. Install Open Source on i (LPO - 5733 OPS) 5733-OPS has 15 options available NOW! The options themselves are placeholders Function will be delivered via PTF5733-OPS: Install Open Source a bit unconventional? New license program optionOpen Source offerings on IBM I15 option place holders .. new function provided by PTF(s)5733 OPSP rogram Option Description 5733 OPS *BASE IBM i Open Source Solutions 5733 OPS 1 IBM i Open Source Solutions Option 1 ( )5733 OPS 2 IBM i Open Source Solutions Option 2 ( Python )5733 OPS 3 IBM i Open Source Solutions Option 3 (GCC scripts)5733 OPS 4 IBM i Open Source Solutions Option 45733 OPS 5 IBM i Open Source Solutions Option 55733 OPS 6 IBM i Open Source Solutions Option 6 #!
2 /wiki/IBM%20i%20 Technology%20 Updates/page/Open%20 Source%20 TechnologiesWiki page LPP 5733 OPS Install Python on i 5733 OPS *BASE (wiki main page) XMLSERVICE (wiki HTTP group PTFs) 5733 OPS Option 2 (wiki link Python ) latest SC1 PTF's (wiki SC1 PTFs) new-function PTF's (wiki Python PTFs) the install by running 'python3 --version' from a terminalSummary installing Python on #!/wiki/IBM%20i%20 Technology%20 Updates/page/Open%20 Source%20 Technologies> call qp2term(if green is your scene .. man) Wiki page obtain 5733 OPSWiki main page - left side navigationLatest HTTP PTF Group:PTF SF99368 - level 31 for i SF99713 - level 5 for i (QXMLSERV/XMLSERVICE IBM PTF lib)See wiki instructionsOptional HTTP PTF group include XMLSERVICE(XMLSERVICE/XMLSERVICE web test lib) Wiki main page 5733 OPSWiki - left side navigation python3 / This is the main Python / Preferred package installer.
3 2to3 / Transforms Python code to Python / Documentation generatorpyvenv / Provides support for lightweight virtual / Lets you build, install, and manage Python packages. This command is used for installing shipped Python runtimeWiki main page - left side navigation DB2 connector (SI57253): easy_install3 /QOpenSys/QIBM/ProdData/OPS/ Python -pkgs/ ibm_db/ibm_db-*.eggToolkit for IBM i (SI57254): easy_install3 /QOpenSys/QIBM/ProdData/OPS/ Python -pkgs/ itoolkit/itoolkit-* gateway support (SI57255): easy_install3 /QOpenSys/QIBM/ProdData/OPS/ Python -pkgs/ flipflop/flipflop-*.
4 Egglightweight web framework (SI57256): easy_install3 /QOpenSys/QIBM/ProdData/OPS/ Python -pkgs/ bottle/bottle-*.eggInstalling shipped add-ons (install Python PTFs first) Provided by the ibm_db open source project Incredibly robust. Can do many DB2 functions! Conforms to Python Database API Specification Complete documentation can be found here: DB2 connector QSQSRVR DB2 BCI .. task 1, then task 2 Simple select statement Creating HTML table from a select Built in DB2 Services Use SQL to get info from the system!
5 Built in DB2 Services ExamplesSELECT * FROM WHERE SIGN_ON_ATTEMPTS_NOT_VALID > 0 SELECT ASP_NUMBER,UNITNBR,PERCENT_USED FROM Three different ways to use it: Direct calls (like CLP) REST calls (local/remote) DB2 calls (local/remote)Toolkit for IBM Default: DG1 ships XMLSERVICE PTFs, QXMLSERV library (PTF SI57953 - LPP OPS PTF)Optional: XMSLERVICE library installed, see following link installation : 1) XMLSERVICE direct call (current job) from import * itransport = iLibCall() 2) XMLSERVICE db2 call (QSQSRVR job) from import * itransport = iDB2 Call( , ) -- or -- conn = (database, user, password) itransport = iDB2 Call(conn) 3) XMLSERVICE http/rest/web call (Apache job) from import * itransport = iRestCall(url, user, password)
6 Python egg toolkit Class listXMLSERVICE transport - iLibCall iDB2 Call iRestCallXMLSERVICE main - iToolKitXMLSERVICE call base - iBaseXMLSERVICE call *CMD or PASE - iCmd iSh iCmd5250 XMLSERVICE call *PGM or *SRVPGM - iPgm iSrvPgm iParm iRet iDS iDataXMLSERVICE call DB2 - iSqlQuery iSqlPrepare iSqlExecute iSqlFetch iSqlParm iSqlFreeXMLSERVICE generic - iXmlPython egg toolkit classes Toolkit example: rtvjoba Toolkit example: DB2 Toolkit example: DB2 Toolkit example: *PGM System API# Retrieve Hardware Resource List (QGYRHRL, QgyRtvHdwRscList) API# Service Program: QGYRHR# Default Public Authority: *USE# Threadsafe: No# Required Parameter Group:# Output Char(*).
7 Receiver variable (RHRL0100, RHRL0110)# Input Binary(4)..Length of receiver variable# Input Char(8)..Format name# Input Binary(4)..Resource category# I/O Char(*)..Error code# RHRL0100 Format# BINARY(4)..Bytes returned# BINARY(4)..Bytes available# BINARY(4)..Number of resources returned# BINARY(4)..Length of resource entry# CHAR(*)..Resource entries# These fields repeat for each resource.# BINARY(4)..Resource category# BINARY(4)..Family level# BINARY(4)..Line type# CHAR(10)..Resource name# CHAR(4).
8 Type number# CHAR(3)..Model number# CHAR(1)..Status# CHAR(8)..System to which adapter is connected# CHAR(12)..Adapter address# CHAR(50)..Description# CHAR(24)..Resource (liar, liar, pants on fire, binary) System API (input) System API (report) System API (run) $ Python +++ success QGYRHR QgyRtvHdwRscList Length of receiver Format Resource RHRL0100_t: Bytes Bytes Number of resources Length of resource ---------------------------------------- ---------------- Resource Family Line Resource Type Model System adapter *NONE Adapter *NONE Processor Resource ---------------------------------------- ---------------- Resource Family Line Resource Type Model
9 System adapter *NONE Adapter *NONE Controller Resource ---------------------------------------- ---------------- Resource Family Line Resource : .. so on .. We ship a fastCGI gateway, built from the flipflop open source projectFastCGI gateway We ship a slightly-modified version of the open-source Lots of reference at We'll see a small example laterLightweight web framework Install community packages Usage: pip3 <command> [options]Commands: install Install packages.
10 Uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. search Search PyPI for packages. wheel Build wheels from your requirements. zip DEPRECATED. Zip individual packages. unzip DEPRECATED. Unzip individual packages. bundle DEPRECATED.