Example: bankruptcy

Getting started with Python on IBM i. - Gateway/400

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 #!/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 #!

• 5733-OPS has 15 options available NOW! • The options themselves are placeholders • Function will be delivered via PTF 5733-OPS: Install Open Source a bit unconventional?

Tags:

  Python, With, Getting, Started, Getting started with python on

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

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 #!/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 #!

2 /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. 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-*.

3 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-*.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! 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.

4 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) 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(*).

5 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)..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 System adapter *NONE Adapter *NONE Controller Resource ---------------------------------------- ---------------- Resource Family Line Resource.

6 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. 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. Create pybundles.

7 Help Show help for Options: -h, --help Show help. -v, --verbose Give more output. Option is additive, and can be used up to 3 times. -V, --version Show version and exit. -q, --quiet Give less output. --log-file <path> Path to a verbose non-appending log, that only logs failures. This log is active by default at /home/JGORZINS/. --log <path> Path to a verbose appending log. This log is inactive by default. --proxy <proxy> Specify a proxy in the form --timeout <sec> Set the socket timeout (default 15 seconds). --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup. --cert <path> Path to alternate CA the pip3 command (install from Internet) Installing xlsxwriter xlsxwriter example xlsxwriter example Most packages from the web are pure Python packages.

8 No compile needed!! Some packages require bits of C/C++ code pip3 will automatically download the source, compile and install. - By default, it will use the XL C compiler You will likely need to install the gcc compiler and configure according to these steps: #!/wiki/IBM%20i%20 Technology%20 Updates/page/Downloading%20packages%20us ing%20the%20pip3%20commandpip3 and native compiles Helpful hint!!!Set the environment variable MAX_CONCURRENCY=1 to help debug any possible compilation problems. pip3 and native compiles Hello, world! Interactive: Script: Python interactive Let's go to the web! fastCGI (already saw this) (included with Python ) #!/wiki/IBM%20i%20 Technology%20 Updates/page/Sample%20web%20application% 20with% (shipped add-on) Quick, easy-to-use, lightweight web framework! Lets you serve up static files, images, dynamically-generate code, and much #!/wiki/IBM%20i%20 Technology%20 Updates/page/Sample%20web%20application% 20with%20 Pythonbottle (shipped add-on) code for DB2 query function Code for CL command function "The web framework for perfectionists with deadlines" Very powerful.

9 Has MVC frameworks built-in. Requires a database connection for keeping relationship mappings, structural data, etc On IBM i, one can use MySQL via Zend #!/wiki/IBM%20i%20 Technology%20 Updates/page/First%20 Django%20web%20application Django #questionnaire-model Other versions of Python ( , )!Example ready made for OPS GCC ..Programmers want ..1) Ranger Python ) Bobby Python ) Lefty Python wants ..1) No new LPARs ..2) No affecting PASE ..3) Test RPG/DB2 shared ..RangerBobbyLeftyWhen a user profile with a "." (dot) in their home directory path connects using ssh, sftp, or scp path the "/" (root) directory for that connected session is set to be the portion of the directory path prior to the "."ssh, sftp, scp, with chroot 400 (admin *SECOFR)======> strTCPSVR SERVER(*SSHD)> mkdir -p /QOpenSys/ranger/home/ranger> CHGUSRPRF USRPRF(RANGER) LOCALE(*NONE) HOMEDIR(/QOpenSys/ranger/./home/ranger)O n laptop (user ranger)=========$ ssh ranger@myibmiSetup chroot for 'ranger' ( Python ).

10 (see )===============================Installa tion (admin *SECOFR)===============================C RTUSRPRF USRPRF(RANGER) PASSWORD() USRCLS(*PGMR) TEXT('Tony Cairns')CHGUSRPRF USRPRF(RANGER) LOCALE(*NONE) HOMEDIR('/QOpenSys/ranger/./home/ranger' )-- outside chroot --GCC scripts provided by PTF SI58604$ . /QOpenSys/ranger$ . /QOpenSys/ranger$ . /QOpenSys/ranger-- additional setup if another profile (careful must use chroot) --$ chroot /QOpenSys/ranger /bin/bsh$ cd /$ chown -R ranger .$ exit-- back outside chroot --Setup Python inside chroot .. (see )===============================Installa tion (user ranger)===============================-- inside chroot --$ ssh -X ranger@ut30p30ranger@ut30p30's password: -- if you see, use ksh --$ export PATH=/opt/freeware/bin:/usr/binPATH=/opt /freeware/bin:/usr/bin: is not an identifier-- if you see, use ksh --$ ksh $ export PATH=/opt/freeware/bin:/usr/bin$ export LIBPATH=/opt/freeware/lib:/usr/lib$ cd /QOpenSys/QIBM/ProdData/OPS/GCC$.


Related search queries