0

I am new to python libnfs (NfsClient). I am trying to create a new file of a certain size on the server. Can someone please tell me how to?

If I try to open in write mode I get Invalid file error (file does not exist). I looked at there is a _create function which I dont know how to use.

This is the libnfs module that I am using, I can find documentation for it online anywhere, can you also please help me find documentation for it.

import libnfs
print libnfs.__file__
<somelocalpath>/python_libnfs-1.9.6-py2.6-linux-x86_64.egg/libnfs.pyc
CodeWithPride
  • 123
  • 3
  • 14
  • Check this link - http://rickhau.github.io/blog/2015/05/08/install-libnfs-python-library/ – Dinesh Pundkar Aug 31 '16 at 07:46
  • I did look at this, but the package is being used in other parts of code and I dont want to use two packages for same purpose and I dont have time to modify all the rest of the code. Thanks – CodeWithPride Aug 31 '16 at 15:27

3 Answers3

0

I assume you talk about the libnfs-python client.

You open a new NFS context with the NFS class, e.g.

 nfs = libnfs.NFS("nfs://myhost/mypointpoint")

Now, you use that context to open a file, e.g.

 f = nfs.open("/myfile", "w")

that file behaves like a normal python file-like object, e.g.

 f.write(mydata)
 f.flush()
 f = None
dmeister
  • 34,704
  • 19
  • 73
  • 95
0

Answer for Ubuntu

sudo apt-get update
sudo apt-get install libnfs-dev

after this try install by pip

pip install libnfs

After installing the module you will write your file like this:

import libnfs
nfs = libnfs.NFS("nfs://216.48.183.63/mnt/dev")
f = nfs.open("/hey.txt", "w")
f.write("hii")
f.flush()
f = None

for more details refer here

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 23 '22 at 05:33
-2

How did you install libnfs-python to linux? I'm trying to do this in RHEL...

As I understand it, the first step is to install this library -https://github.com/sahlberg/libnfs, but I couldn't find a step-by-step installation guide

The second step is to run setup.py Right? https://github.com/sahlberg/libnfs-python