forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Testing python I saw some strange behaviour about filenames

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Fri Jan 23, 2015 6:59 pm    Post subject: Testing python I saw some strange behaviour about filenames Reply with quote

Hello,
I'm newbie here. Thanks to who's ported python on OpenVMS!
Very Happy
Now I'm testing python on OpenVMS V8.3H1 and V8.4 on Itanium server.

I saw some strange behaviour about filenames and process:
1.subprocess.call stucks if stdin and/or stdout are passed
2. os.path.dirname() and os.path.basename() with local OpenVMS filenames don't work
3.os.devnull report /dev/null while in OpenVMS is NL0: or NLA0:

Someboy may help me?

Thanks in advance

Antonio M. Vigliotti
Back to top
View user's profile Send private message
jescab



Joined: 28 Jan 2008
Posts: 252

PostPosted: Sat Jan 24, 2015 11:50 am    Post subject: Reply with quote

> I'm newbie here.

On Python? On OpenVMS? Or both? Smile

First, actual code examples including error output is expected in this kind of posts.

Second, yes, NLA0: (or NL: or NL0: for short) is the "null-device" in OpenVMS.
You probably already know that, right? What did you expect?
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 618

PostPosted: Sat Jan 24, 2015 5:00 pm    Post subject: Re: Testing python I saw some strange behaviour about filena Reply with quote

antoniov wrote:
Hello,
I'm newbie here. Thanks to who's ported python on OpenVMS!
Very Happy
Now I'm testing python on OpenVMS V8.3H1 and V8.4 on Itanium server.

Welcome in the python on OpenVMS world Smile

antoniov wrote:

I saw some strange behaviour about filenames and process:
1.subprocess.call stucks if stdin and/or stdout are passed

The port of the subprocess module is experimental, and probably not complete. if you have a small reproducer we can take a look.
antoniov wrote:

2. os.path.dirname() and os.path.basename() with local OpenVMS filenames don't work
3.os.devnull report /dev/null while in OpenVMS is NL0: or NLA0:

One of the goal of Python on OpenVMS is to allow to port easily Unix code, so it use Unix syntax filename.
But is also provide routine to convert filename from VMS to Unix and from Unix to VMS, see vms.crtl module.

Hope this help you.

Jean-François
Back to top
View user's profile Send private message Send e-mail Visit poster's website
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Tue Jan 27, 2015 10:05 am    Post subject: Reply with quote

Thank to all for your responses.

Yes, I understand python on OpenVMS is experimental so I posted to help this process.

I wrote code but I don't know how to load.

First trouble: subprocess.call
This is the code
Code:

import os
from subprocess import call

        stdout_fd = open("stdout.log" , "w")
        stdinp_fd = open("NL0:", "r")
        call(cmd, stdin=stdinp_fd, stdout=stdout_fd, shell=True)
        stdout_fd.close()
        stdinp_fd.close()

Above code stucks when executes call

I read carefully this forum and I found a little workaround

Code:

import os
from subprocess import call
from sys import platform as _platform

    if _platform == "OpenVMS":
        bgout_mb,bginp_mb,bgerr_mb = os.popen3(cmd)
        bgout_mb.write("logout")
        stdout_fd = open("stdout.log" , "w")
        s=bginp_mb.read()
        stdout_fd.write(s)
        stdout_fd.close()
Back to top
View user's profile Send private message
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Tue Jan 27, 2015 10:14 am    Post subject: Reply with quote

Second trouble: local filename.

I know, one of the goal of Python on OpenVMS is to allow to port easily Unix code. I use Linux/Unix syntax.
However python should be able to manage local filename.

This code work on Windows:
Code:

f = ""\\mydir\\myfile"
b = os.path.basename(f)
p = os.path.dirname(f)


So I expeceted this code should work on OpenVMS
Code:

f = ""[mydir]myfile"
b = os.path.basename(f)
p = os.path.dirname(f)


I look into source code, if possible I could help porting process.
Back to top
View user's profile Send private message
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Tue Jan 27, 2015 10:17 am    Post subject: Reply with quote

Last:
Code:

import os
    print os.devnull

This code reports "/dev/null" that's Unix/Linux null device.
It shoul reports "NL0:" or "NLA0:"
Windows version of python report "nul" that's null device in Windows.
Back to top
View user's profile Send private message
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Tue Jan 27, 2015 10:20 am    Post subject: Reply with quote

Very important: Exclamation Exclamation
I issued my post just for infomational notice.
I thank who ported python on OpenVMS, it's working for me.
If possible, I can contribute to this project.

Thanks, thanks, thanks

Smile
Back to top
View user's profile Send private message
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Tue Jan 27, 2015 3:29 pm    Post subject: Reply with quote

Hello,
I looked at source code and I think could give my own contribute. Cool

Module 'os.py' imports local OS structure.

I have already written most part of code for OpenVMS, so Idea I could write a 'vmspath.py' module with OpenVMS functions.

May be a simple module, useful for allbodies, I hope

Antonio Maria Vigliotti
Back to top
View user's profile Send private message
jescab



Joined: 28 Jan 2008
Posts: 252

PostPosted: Wed Jan 28, 2015 1:02 am    Post subject: Reply with quote

I'm sure that all contributions to the support of Python on OpenVMS is of high value!

Just a small thing... Smile

> Yes, I understand python on OpenVMS is experimental...

I would say that there are some parts of Python on OpenVMS that might be called "experimental".
But as a whole, I think it runs quite well. I use it in production use both in my own server
and at a custumer (a factory control system at a large company in Sweden).

Anyway, I hope your contributions can come to a use in the Python port.
Back to top
View user's profile Send private message
antoniov



Joined: 23 Jan 2015
Posts: 7

PostPosted: Wed Jan 28, 2015 8:58 am    Post subject: Reply with quote

Hi Jescab,
I'm happy you are using python on production site. It's more stable I believed Very Happy Very Happy Very Happy

I'm working on module ospath.py, now importing a new module vmsptah.py not posixpath.py

First testing are goods but I need some days to complete it and other day to document it.
Then I hop jfp would accept code.
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 618

PostPosted: Wed Jan 28, 2015 11:12 am    Post subject: Reply with quote

Hi Antoniov,

I know site which are using Python on production, in fact I, even, know one site which develop all their new code in Python including on OpenVMS.

Sure any contribution are welcome Exclamation .
You can create an account on https://repos.sysgroup.fr/ then you can fork/do pull requests, etc... on the cpython27 repository.

As Mercurial has been ported on OpenVMS, you can work directly on OpenVMS.

If you want to convert vms filename from/to unix remember routines in the vms.crtl already exists :
Code:
>>> print vms.crtl.from_vms.__doc__
from_vms(name) -> unix_name

Converts OpenVMS style file specifications to Unix file specifications.
>>> print vms.crtl.to_vms.__doc__
to_vms(name[,no_directory=0) -> vms_name

Converts UNIX style file specifications to OpenVMS file specifications.
>>>


Thanks for any help.

Be sure to use the latest LD images, some bug fix/enhancement has been done on the latest version including on the subprocess module.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group