Open-source Languages & Tools for z/OS

 View Only
Expand all | Collapse all

z/OS Python 3.6.1 File Access

  • 1.  z/OS Python 3.6.1 File Access

    Posted 12-02-2017 12:55

    Does anyone know how to open a MVS dataset in python 3.6.1? And how to refer to a DD name in JCL? I have tried using open("//‘xxx.xxx.xxx’) and it returned ‘FileNotFoundError’ but the file is definitely exist! I can access the file in USS without any problem.



  • 2.  RE: z/OS Python 3.6.1 File Access

    Posted 12-05-2017 12:14

    What you want to do, but for Python 2.7.6, can be found in this example.

    I don’t believe the build of Python 3.6.1 currently available for z/OS supports the “//” filename syntax. This will be supported in an upcoming release.



  • 3.  RE: z/OS Python 3.6.1 File Access

    Posted 12-05-2017 18:18

    Could I ask the tentative schedule of the upcoming release? It’s because Python 3 is the current trend.



  • 4.  RE: z/OS Python 3.6.1 File Access

    Posted 12-08-2017 18:14

    Unfortunately, this sort of enhancement has to be a “when we have time” for users that are not on a support contract. We do provide 24x7 support and priority service for enhancements for customers on support and support contracts are very reasonably priced. Sorry, but we must prioritize paying customers first.
    Best regards,
    -Peter



  • 5.  RE: z/OS Python 3.6.1 File Access

    Posted 12-09-2017 04:36

    For anyone who has interest, could you roughly tell us the price for this kind of support?



  • 6.  RE: z/OS Python 3.6.1 File Access

    Posted 12-11-2017 10:53

    Pricing for paid support is handled by Rocket sales (I am with engineering). Without knowing your region required to direct you to a specific sales person, you need to make an inquiry here: http://www.rocketsoftware.com/zos-open-source-tools-support
    Best,
    -Peter



  • 7.  RE: z/OS Python 3.6.1 File Access

    Posted 12-13-2017 11:07

    Possible work-arounds:

    1. For a not too big MVS dataset you could consider copying it to Unix before processing with Python.

    2. Python2.7.13 also does support processing MVS files with filename starting with 2 slashes

    3. With Python 3.6.1 you could use ftplib to localhost and access the ‘local’ MVS datasets:

    from ftplib import FTP
    ftp = FTP(‘localhost’)
    ftp.login(‘mm’,‘password’)
    ‘230 MM is logged on. Working directory is "/x/mm’

    ftp.cwd(’//mm.sys.’)
    ‘250 “MM.SYS.” is the working directory name prefix.’

    You even can get a nice listing of the MVS datasets

    >>> ftp.dir()     
    

    By the way, FTP also supports reading record structures (RDW option) …

    :grinning:



  • 8.  RE: z/OS Python 3.6.1 File Access

    Posted 12-14-2017 08:22

    First of all, thanks for the suggested work-arounds. However, as the MVS files I need to handle are very large which are not convenient to copy to USS.

    Secondly, where can I find the Python 2.7.12 beta as I can only find 2.7.13?

    Thirdly, is it possible to use Python 2 program to feed records to Python 3.6.1 program? If it is possible, what is the best way to do it?



  • 9.  RE: z/OS Python 3.6.1 File Access

    Posted 12-14-2017 09:47

    ad2) actually I meant Python 2.7.13 and not 2.7.12 beta which was a pre-release.

    I will correct this in the original post

    ad3) I have not experimented with this. Perhaps this would work with (module) pipes.



  • 10.  RE: z/OS Python 3.6.1 File Access

    Posted 12-19-2017 15:49

    I have installed both 2.7.13 and 3.6.1. According to the README, I can set both library in the .profile. But I don’t know how to set “both”. Could anyone advise me how to set it such that I can run both 2.7.13 python program and 3.6.1 program at the same time?

    Currently, my .profile is shown as below:
    export _BPXK_AUTOCVT=ON
    INSTALL=/usr/lpp/python
    export RELEASE_NAME=python-2017-04-12
    export RELEASE_TYPE=py36
    export RELEASE_DIR=$INSTALL/${RELEASE_NAME}-${RELEASE_TYPE}
    export PYTHON_ENV=python36
    export PYTHON_HOME=$RELEASE_DIR/$PYTHON_ENV
    export PATH=$PYTHON_HOME/bin:$PATH
    export LIBPATH=$PYTHON_HOME/lib:$LIBPATH
    export FFI_LIB=$PYTHON_HOME/lib/ffi
    export TERMINFO=$PYTHON_HOME/share/terminfo
    export PKG_CONFIG_PATH=$PYTHON_HOME/lib/pkgconfig:$PYTHON_HOME/share/pkgconfig
    export CURL_CA_BUNDLE=$PYTHON_HOME/etc/ssl/cacert.pem



  • 11.  RE: z/OS Python 3.6.1 File Access

    Posted 12-21-2017 05:21

    Hi Fran,

    Could you clarify (give an example) what you mean to run both version at the same time?



  • 12.  RE: z/OS Python 3.6.1 File Access

    Posted 12-21-2017 07:45

    Hi Tatyana,

    I would like to run a 3.6.1 program, in which I intend to use “subprocess” to call a 2.7.13 python program to open a MVS dataset and then feed records to the 3.6.1 program.

    Currently, I have installed both versions in different install directories. However, I am struggling to set the environment variables for both versions. According to the README, I interpret that it means both should be in the same directory. However, the tar file has set the destination directory and sub-directory. How can I make them both in the same directory? Even though I can copy them together, if they are of the same file names (e.g. python in bin directory), they would be overwritten by the other one. I don’t quite understand how to make it work! Please help!



  • 13.  RE: z/OS Python 3.6.1 File Access

    Posted 12-27-2017 08:54

    Hi Fran,
    Sorry for long reply. I would recommend you to use tne next settings:

    Then you can you use python2 to run python 2.7 and python3 to run python 3.6. As I understand you need this call:

    subprocess.call(“python2 script.py”, shell=True)



  • 14.  RE: z/OS Python 3.6.1 File Access

    Posted 12-29-2017 17:58

    Hi Tatyana,

    Thank you very much. I have tested it and it works perfectly for me.



  • 15.  RE: z/OS Python 3.6.1 File Access

    Posted 01-09-2018 05:18

    Fran,
    You are welcome!



  • 16.  RE: z/OS Python 3.6.1 File Access

    Posted 03-01-2019 02:29

    open MVS dataset in python 3.6
    f = open("//‘my.dataset’", ‘rb’)