Python

Python

Python

 View Only
Expand all | Collapse all

unable to set binary tag to file using os.set_tagging

  • 1.  unable to set binary tag to file using os.set_tagging

    Posted Wed January 03, 2024 09:58 AM
    Edited by Andres Parada Wed January 03, 2024 10:06 AM

    Hi, I'm trying to set binary tag using Python 3.12 and os.set_tagging , and looks like it's not working:

    $ ls -T /u/user/tmp/BINARY.txt
    - untagged    T=off /u/user/tmp/BINARY.txt

    $ python -c "import os; print(os.set_tagging('/u/user/tmp/BINARY.txt', 65535))"
    -1

    $ ls -T /u/user/tmp/BINARY.txt
    - untagged    T=off /u/user/tmp/BINARY.txt

    but it's ok for iso-8859-1 and ebcdic ccsid:

    $ python -c "import os; print(os.set_tagging('/u/user/tmp/BINARY.txt', 819))"
    0
    $ ls -T /u/user/tmp/BINARY.txt
    t ISO8859-1   T=on  /u/user/tmp/BINARY.txt
    $ python -c "import os; print(os.set_tagging('/u/user/tmp/BINARY.txt', 1047))"
    0

    $ ls -T /u/user/tmp/BINARY.txt
    t IBM-1047    T=on  /u/user/tmp/BINARY.txt

    Thanks,

    Alexander



    ------------------------------
    Alexander Klochkov
    ------------------------------



  • 2.  RE: unable to set binary tag to file using os.set_tagging

    Posted Wed January 03, 2024 02:40 PM

    Hi Alexander, thanks for reporting this, we'll be investigating it. As a workaround, I'd recommend you use the zos_util package. You can obtain it in two ways:

    1) Directly from the Python AI Toolkit for IBM z/OS
    2) Install it from PyPI - you'll need a C compiler installed in your environment to build this package, and you may also find the following blog useful for Installing Packages with C Components on Python 3.12.

    To use the package for your scenario, you can do the following:

    import zos_util
    zos_util.tag_binary('BINARY.TXT')

    And you can find the documentation for this package here



    ------------------------------
    Steven Pitman
    ------------------------------