|
Hi Bryan,
Thanks for your post.
Well, that is certainly a difference between the two:
Python 3.4.6 (default, Mar 21 2017, 20:59:04)
[GCC 4.8.2] on aix6
platform.architecture(), sys.maxsize
(('32bit', ''), 2147483647)
==================================
Python 3.6.6 (default, Aug 3 2018, 19:02:01)
[GCC 6.3.0] on aix6
platform.architecture(), sys.maxsize
(('64bit', 'COFF'), 9223372036854775807)
I guess Kevin's comment of July this year is still applicable:
*"ibCall does not work when run 64-bit. For the time being you will needto
use a different transport."*
Although I have no clue what other transports are available.
I'd even say I don't really know what a transport is - I'd guess it's some
kind of linkage between python and the IBMi OS.
thanks for the info.
best regards,
Craig
On Tue, 2 Oct 2018 at 12:37, Bryan Dietz <bdietz400@xxxxxxxxx> wrote:
I recall reading this:
https://archive.midrange.com/opensource/201807/msg00030.html
I do not know if it applies, but wanted to re-pass along
Bryan
Craig Richards wrote on 10/2/2018 6:56 AM:
Hi Kevin,to
Thanks for taking the time to reply.
I don't know if you had a particular command line program in mind for
setting the CCSID but it seems to me that the easiest way to achieve it
might be to use the CHGATR command.
It's certainly simpler from a 'user' perspective than coding up a call
qp0lSetAttr()from
Seeking about for information on how to call AS400 Commands / Programs
Python lead me to a post which I noticed you had contributed to:https://stackoverflow.com/questions/50576341/how-to-call-an-rpg-program-from-python
and I
And so that lead me to try a test of:
from itoolkit import *
from itoolkit.lib.ilibcall import *
itransport = iLibCall()
itool = iToolKit()
itool.add(iCmd('sndmsg', 'SNDMSG "WIBBLE" RICHARC'))
itool.call(itransport)
output = itool.dict_out('sndmsg')
print(output)
This works from Python 3.4.6 and prints:
{'success': '+++ success SNDMSG "WIBBLE" RICHARC'}
However if I run it from Python 3.6.6 ( /QopenSys/pkgs/bin/python3 ) it
fails and prints:
{'error': {'error': '*NODATA', 'sndmsg': {...}}}
If my memory serves me correctly, 3.4.6 is what came with the system
installed 3.6.6 via IBMi ACS Open Source Package Management.itoolkit
I'm not sure what the problem is with this, forgive my ignorance.
Another thing which also puzzled me is that the documentation for
which you kindly linked in your post:work
https://python-itoolkit.readthedocs.io/en/latest/examples.html
is different to the code you supplied in the original post and doesn't
for me with either version of python.IFS
For example the code for DSPSYSSTS:
import config
from itoolkit import *
itool = iToolKit()
itool.add(iCmd5250('dspsyssts', dspsyssts'))
itool.call(config.itransport)
...
This codes fails from both versions of python with:
AttributeError: 'module' object has no attribute 'itransport'
So that leaves me with the following questions:
1. Is CHGATR from python a reasonable way to set the "tag" of the
file. I guess there might be something I can run more directly fromQSH via
subprocess() that might let me set the CCSID.little
2. Is itoolkit a reasonable way to make the call to CHGATR. I'm a
confused about it being called an XMLSERVICE collector but is thatjust the
way it is communicating with the OS?looked
3. Why doesn't my example work with Python 3.6.6 - is it running a
different version of itoolkit? using help() for iCmd, the syntax
unchanged.change
4. Are the code examples for itoolkit wrong or is it to do with
code versions or assumed imports or something?codecs.
Sorry for my ignorance and the many questions.
What can I say, I'm a curious man...
thanks and best regards,
Craig
On Mon, 1 Oct 2018 at 17:29, Kevin Adler <kadler@xxxxxxxxxx> wrote:
Python has its own built-in codecs and does not use the system
https://docs.python.org/3/library/codecs.html#standard-encodingsYou
can see the list (which does not include cp285) here:
[1]
the
As Python runs in PASE it will open the file tagged with whatever
thePASE
ccsid is (which defaults to 819 except in rare cases). There is
currently
no mechanism in Python to match the CCSID tag with the encoding of
usingdata, though there are various command line programs you could call
manually from within Python to do so.
----- Original message -----
From: Craig Richards <craig@xxxxxxxxxxxxxxxx>
Sent by: "OpenSource" <opensource-bounces@xxxxxxxxxxxx>
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxx>
Cc:
Subject: [IBMiOSS] Creating Stream Files with Python
Date: Mon, Oct 1, 2018 11:13 AM
Hi All,
I can create streamfiles with different encodings in the IFS
alwayspython
using the encoding parameter and this works fine e.g:
f = open('asci.txt', 'w', encoding='cp819')
This is good. And fine too. Some might say dandy.
However if I look at the attributes of the stream file it is
encodingCCSID
819 if I am creating a new file.
This means that using DSPF to look at the data on the IBMi will
display
the
data incorrectly if that data is not actually written with
CCSID819.
I can modify the file manually using EDTF to change the file's
theand
then it will be displayed correctly ( within the limitations of
additional5250
Client ) however I assume there is a way to set this attribute
correctly
for new files using python?
I understand that the IBMi is fairly unique in that it has
using theattributes on stream files that store information such as the
(intended)
ccsid but I know it is possible to set these correctly when
285, Iunix
open API to create stream files ( for example )
Additionally I'm using an IBMi in the UK and QCCSID is set to
it isget
an
error in the above code if I specify encoding='cp285' although
I wasquite
happy to use encoding='cp037'.
Not that I have a requirement to encoding in the IFS in 285 but
givena
little surprised that 37 was supported but not 285 - especially
method tothat
it is a UK not US box.
However my main question is - should I be using a different
( thecreate my streamfiles if I want the endcoding of the streamfile
thefile
header, not the actual data ) to be other than 819?
I've tried using the codecs.open method but that seems to work
issame
-
it creates the data correctly but the CCSID for the file itself
https://docs.python.org/3/library/codecs.html#standard-encodingsalways
819 for NEW files.
Thanks kindly,
Craig
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: [2]https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at [3]https://archive.midrange.com/opensource.
References
Visible links
1.
--2. https://lists.midrange.com/mailman/listinfo/opensource
3. https://archive.midrange.com/opensource
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/opensource.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.