View previous topic :: View next topic |
Author |
Message |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Fri Jan 23, 2015 6:59 pm Post subject: Testing python I saw some strange behaviour about filenames |
|
|
Hello,
I'm newbie here. Thanks to who's ported python on OpenVMS!
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 |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Sat Jan 24, 2015 11:50 am Post subject: |
|
|
> I'm newbie here.
On Python? On OpenVMS? Or both?
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 |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 625
|
Posted: Sat Jan 24, 2015 5:00 pm Post subject: Re: Testing python I saw some strange behaviour about filena |
|
|
antoniov wrote: | Hello,
I'm newbie here. Thanks to who's ported python on OpenVMS!
Now I'm testing python on OpenVMS V8.3H1 and V8.4 on Itanium server.
|
Welcome in the python on OpenVMS world
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 |
|
 |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Tue Jan 27, 2015 10:05 am Post subject: |
|
|
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 |
|
 |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Tue Jan 27, 2015 10:14 am Post subject: |
|
|
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 |
|
 |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Tue Jan 27, 2015 10:17 am Post subject: |
|
|
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 |
|
 |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Tue Jan 27, 2015 10:20 am Post subject: |
|
|
Very important:
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
 |
|
Back to top |
|
 |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Tue Jan 27, 2015 3:29 pm Post subject: |
|
|
Hello,
I looked at source code and I think could give my own contribute.
Module 'os.py' imports local OS structure.
I have already written most part of code for OpenVMS, so 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 |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Wed Jan 28, 2015 1:02 am Post subject: |
|
|
I'm sure that all contributions to the support of Python on OpenVMS is of high value!
Just a small thing...
> 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 |
|
 |
antoniov
Joined: 23 Jan 2015 Posts: 7
|
Posted: Wed Jan 28, 2015 8:58 am Post subject: |
|
|
Hi Jescab,
I'm happy you are using python on production site. It's more stable I believed
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 |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 625
|
Posted: Wed Jan 28, 2015 11:12 am Post subject: |
|
|
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 .
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 |
|
 |
|