Python in IBM I - Getting Started
Python in IBM I - Getting Started
Agenda
• Introduction
• Install Python on i
• Use modern tools
• Explore what you get
• Install community packages
• Hello, world!
• Let's go to the web!
• https://www.python.org/about/success/
Install Python on i
Installing Python on i
1. Install XMLSERVICE
http://yips.idevcloud.com/wiki/index.php/XMLService/XMLSERVICEInstall
Modern terminal
Modern terminal
• Use SSH!
• A good way from Windows (not the only way):
1. Install cygwin (make sure that SSH is part of install)
2. Programs Cygwin Cygwin64 Terminal
3. ssh -Y <userid>@<hostname>
(optional) 'exec bash' for a more friendly shell (in Jesse's opinion)
Modern terminal
Many options
• Can map a drive, use Windows editor of choice (for example)
• Or, use nedit with X11 forwarding (topic for another day
python3 / python3.4
This is the main Python executable.
pip3 / pip3.4
Preferred package installer.
2to3 / 2to3-3.4
Transforms Python 2.x code to Python 3.x
pydoc3 / pydoc3.4
Documentation generator
pyvenv / pyvenv-3.4
Provides support for lightweight virtual environments.
easy_install3 / easy_install-3.4
Lets you build, install, and manage Python packages. This command is
used for installing shipped add-ons.
Built in DB2 Services – Use SQL to get info from the system!
PTF Services
Storage Services
QSYS2.PTF_INFO
QSYS2.USER_STORAGE
QSYS2.GROUP_PTF_INFO
QSYS2.SYSDISKSTAT
Security Services
QSYS2.USER_INFO QSYS2.SYSTMPSTG
QSYS2.OBJECT_STATISTICS()
QSYS2.FUNCTION_USAGE
QSYS2.GROUP_PROFILE_ENTRIES
System Health Services
QSYS2.SQL_CHECK_AUTHORITY()
QSYS2.SYSLIMTBL
QSYS2.SET_COLUMN_ATTRIBUTE()
QSYS2.SYSLIMITS
Work Management Services
QSYS2.GET_JOB_INFO() QSYS2.DISPLAY_JOURNAL()
SYSIBMADM.ENV_SYS_INFO
QSYS2.QCMDEXC()
QSYS2.TCPIP_INFO
SELECT
ASP_NUMBER,UNITNBR,PERCENT_USED
FROM QSYS2.SYSDISKSTAT
http://youngiprofessionals.com/wiki/index.php/XMLSERVICE/Python
FastCGI gateway
• We ship a fastCGI gateway, built from the flipflop open source project
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.
help Show help for commands.
General 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/.pip/pip.log.
--log <path> Path to a verbose appending log. This log is inactive by default.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--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 bundle.
Installing xlsxwriter
xlsxwriter example
xlsxwriter example
Hello, world!
Python interactive
• Interactive:
• Script:
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/
wiki/IBM%20i%20Technology%20Updates/page/Sample%20web%20app
lication%20with%20Python
bottle.py
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/
wiki/IBM%20i%20Technology%20Updates/page/Sample%20web%20app
lication%20with%20Python
http://lightbird.net/dbe2/questionnaire.html#questionnaire-model