Discussion:
How to open and read Enscribe files in Python?
(too old to reply)
Mayank Lalwani
2020-11-03 15:51:11 UTC
Permalink
Hello,

Has anyone here been able to open,read or write Enscribe files using Python?

I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
red floyd
2020-11-04 17:37:14 UTC
Permalink
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
Python uses OSS I/O. It's not so much the filecode, but *structured
files* can't be opened with OSS I/O, just unstructured.
francisco lopez
2020-11-04 19:14:02 UTC
Permalink
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
Python uses OSS I/O. It's not so much the filecode, but *structured
files* can't be opened with OSS I/O, just unstructured.
Hi Red Floyd, according to your experience, is it also possible to open python threads over OSS?
Randall
2020-11-04 20:30:09 UTC
Permalink
Post by francisco lopez
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
Python uses OSS I/O. It's not so much the filecode, but *structured
files* can't be opened with OSS I/O, just unstructured.
Hi Red Floyd, according to your experience, is it also possible to open python threads over OSS?
Python threads should be available in Python 3. I don't think they are in Python 2 in NonStop - but I'm not 100% sure.
red floyd
2020-11-05 00:17:11 UTC
Permalink
Post by Randall
Post by francisco lopez
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
Python uses OSS I/O. It's not so much the filecode, but *structured
files* can't be opened with OSS I/O, just unstructured.
Hi Red Floyd, according to your experience, is it also possible to open python threads over OSS?
Python threads should be available in Python 3. I don't think they are in Python 2 in NonStop - but I'm not 100% sure.
Thanks, Randall. Mayank, I don't know. I'm not a python guy. But
since it's an OSS port, I'm assuming it uses OSS I/O. I have no idea
about python threading.

The main thing to remember is that OSS I/O only works on unstructured
and EDIT files. Structured files require Guardian I/O. see the man
page for open(2), description for error EINVAL. See also open(2), in
the "Opening Guardian Files" section.

You cannot use the open( ) function on any other type of Guardian
object. An attempt to open:
[elided]
— A structured file fails with errno set, usually to [EINVAL].
Keith Dick
2020-11-05 20:49:21 UTC
Permalink
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.

It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.

I should say I have never tried this, nor have I used python on OSS at all, so I'm just speculating, so take that into account.

I don't know whether there is a way to open an interprocess file to a Guardian server from python, but if someone knows how to do that, that would be a way to access Enscribe from python without requiring a process start/stop for each I/O. Of course, at some point, it probably would be less trouble to write the whole thing in C.
Keith Dick
2020-11-05 20:55:29 UTC
Permalink
Post by Keith Dick
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.
It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.
I should say I have never tried this, nor have I used python on OSS at all, so I'm just speculating, so take that into account.
I don't know whether there is a way to open an interprocess file to a Guardian server from python, but if someone knows how to do that, that would be a way to access Enscribe from python without requiring a process start/stop for each I/O. Of course, at some point, it probably would be less trouble to write the whole thing in C.
Oh, in my last paragraph, I forgot to say that python can use sockets, so I imagine the server could be an OSS process, instead of a Guardian process.
red floyd
2020-11-06 02:36:07 UTC
Permalink
Post by Keith Dick
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.
It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.
Yes, but they have to use the Guardian APIs. I don't know if there's
python bindings for <cextdecs.h>
Keith Dick
2020-11-06 04:26:25 UTC
Permalink
Post by red floyd
Post by Keith Dick
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.
It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.
Yes, but they have to use the Guardian APIs. I don't know if there's
python bindings for <cextdecs.h>
I believe you misunderstand what I tried to describe.

The Guardian calls to read and write the Enscribe files would be in the OSS C programs. The python code would just run those C programs, passing whatever parameters are needed for the Guardian call on the command line, and getting back results by reading the pipe that gets the stdout from the C programs (which must write whatever is appropriate to their stdout).

The python code itself would not be accessing the Enscribe files. It would only be running the C programs that do the accesses of the Enscribe files.

Do you see what I am suggesting now, or am I still not describing it clearly?
Randall
2020-11-06 16:24:14 UTC
Permalink
Post by Keith Dick
Post by Keith Dick
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.
It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.
Yes, but they have to use the Guardian APIs. I don't know if there's
python bindings for <cextdecs.h>
I believe you misunderstand what I tried to describe.
The Guardian calls to read and write the Enscribe files would be in the OSS C programs. The python code would just run those C programs, passing whatever parameters are needed for the Guardian call on the command line, and getting back results by reading the pipe that gets the stdout from the C programs (which must write whatever is appropriate to their stdout).
The python code itself would not be accessing the Enscribe files. It would only be running the C programs that do the accesses of the Enscribe files.
Do you see what I am suggesting now, or am I still not describing it clearly?
To put it a different way...

Python uses the standard C library to access files. Any files that can be accessed by standard C methods available on UNIX-like/POSIX systems can generally be accessed by Python. There are no methods available to read ENSCRIBE files in the standard C library, so Python will not be able to access the files. There is a low-level interface in CPython3, where you can write your own methods in C, but that is not the implementation on TNS/X, to my knowledge.
Keith Dick
2020-11-06 18:15:54 UTC
Permalink
Post by Randall
Post by Keith Dick
Post by Keith Dick
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.
It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.
Yes, but they have to use the Guardian APIs. I don't know if there's
python bindings for <cextdecs.h>
I believe you misunderstand what I tried to describe.
The Guardian calls to read and write the Enscribe files would be in the OSS C programs. The python code would just run those C programs, passing whatever parameters are needed for the Guardian call on the command line, and getting back results by reading the pipe that gets the stdout from the C programs (which must write whatever is appropriate to their stdout).
The python code itself would not be accessing the Enscribe files. It would only be running the C programs that do the accesses of the Enscribe files.
Do you see what I am suggesting now, or am I still not describing it clearly?
To put it a different way...
Python uses the standard C library to access files. Any files that can be accessed by standard C methods available on UNIX-like/POSIX systems can generally be accessed by Python. There are no methods available to read ENSCRIBE files in the standard C library, so Python will not be able to access the files. There is a low-level interface in CPython3, where you can write your own methods in C, but that is not the implementation on TNS/X, to my knowledge.
What you are saying probably is true (as I said earlier, I have not used python on OSS), but I do not believe that it is relevant to what I have been describing.

What I am describing is using the popen function of the os module to run an OSS program outside of python. The command to run that program would include as command line arguments whatever values need to be given to that external program to allow it to create the Enscribe call the programmer wants to do. That external program would write the appropriate results to its stdout, which the python program would read from the pipe that popen creates.

Do you agree that what I just described is possible to implement with the OSS version of python (and has no connection with what you mentioned in your recent comment)?

I don't claim that this approach is a great approach. It would not have good performance. It would require a new open for every operation, so locks could not be held between operations. For many situations, it might be more effort to implement than the benefit it would give. However, I imagine there are some circumstances in which it would be a useful technique to use. I don't know what the circumstances are that the person who posted the original question has, so I cannot say whether this technique would be suitable in that situation -- he will have to decide that.
Randall
2020-11-10 18:50:11 UTC
Permalink
Post by Keith Dick
Post by Randall
Post by Keith Dick
Post by Keith Dick
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
You might be able to use popen from the os module to develop at least a limited ability to work with Enscribe files from python.
It is possible for OSS programs to open and read or write Enscribe files. I imagine you could write simple C programs that takes the relevant arguments for each operation you want to perform on an Enscribe file, have the program write the result of the operation to stdout, then use those programs from your python code via popen. It would involve starting and stopping a process for each I/O, which would be kind of slow, but if you don't have to do much I/O, it might be workable.
Yes, but they have to use the Guardian APIs. I don't know if there's
python bindings for <cextdecs.h>
I believe you misunderstand what I tried to describe.
The Guardian calls to read and write the Enscribe files would be in the OSS C programs. The python code would just run those C programs, passing whatever parameters are needed for the Guardian call on the command line, and getting back results by reading the pipe that gets the stdout from the C programs (which must write whatever is appropriate to their stdout).
The python code itself would not be accessing the Enscribe files. It would only be running the C programs that do the accesses of the Enscribe files.
Do you see what I am suggesting now, or am I still not describing it clearly?
To put it a different way...
Python uses the standard C library to access files. Any files that can be accessed by standard C methods available on UNIX-like/POSIX systems can generally be accessed by Python. There are no methods available to read ENSCRIBE files in the standard C library, so Python will not be able to access the files. There is a low-level interface in CPython3, where you can write your own methods in C, but that is not the implementation on TNS/X, to my knowledge.
What you are saying probably is true (as I said earlier, I have not used python on OSS), but I do not believe that it is relevant to what I have been describing.
What I am describing is using the popen function of the os module to run an OSS program outside of python. The command to run that program would include as command line arguments whatever values need to be given to that external program to allow it to create the Enscribe call the programmer wants to do. That external program would write the appropriate results to its stdout, which the python program would read from the pipe that popen creates.
Do you agree that what I just described is possible to implement with the OSS version of python (and has no connection with what you mentioned in your recent comment)?
I don't claim that this approach is a great approach. It would not have good performance. It would require a new open for every operation, so locks could not be held between operations. For many situations, it might be more effort to implement than the benefit it would give. However, I imagine there are some circumstances in which it would be a useful technique to use. I don't know what the circumstances are that the person who posted the original question has, so I cannot say whether this technique would be suitable in that situation -- he will have to decide that.
Yes you can run OSS programs from within Python and pass back REST/JSON output into Python structures. This is what Ansible does, so it must work. The NSGit Ansible module, in fact, does that, and is happy to interact with ENSCRIBE via Ansible/Python so I know that is possible from personal experience.
gcav
2020-11-12 21:19:36 UTC
Permalink
Post by Mayank Lalwani
Hello,
Has anyone here been able to open,read or write Enscribe files using Python?
I have been able to read and write 101 coded files in Python but the 0 coded files throw error on open command which reads "OSError: [Errno 4022] Invalid function argument: '<file-name>' ".
Yes, you can... But,
You have to create your python loadable module that handles
SPT functions...

Look pages 421,422 of OSS programmers guide...
From the manual...
"Thread-aware Enscribe functions are supported on L-series, J‑series, H‑series, and G‑series RVUs. The following table provides thread aware wrappers for Enscribe procedure calls that enable an application to make use of Enscribe procedure calls without blocking the process."
Loading...