Interact with an xrootd server to perform file-based operations such as reading, writing, vector reading, etc.
To provide an interface like the python built-in file object, the __iter__(), next(), readline() and readlines() methods have been implemented. These look for newlines in files, which may not always be appropriate, especially for binary data.
Additionally, these methods can’t be called asynchronously, and they don’t return an XRootDStatus object like the others. You only get the data that was read.
Open the file pointed to by the given URL.
Parameters: |
|
---|---|
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and None |
Close the file.
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and None |
---|
As of Python 2.5, you can avoid having to call this method explicitly if you use the with statement. For example, the following code will automatically close f when the with block is exited:
from __future__ import with_statement # This isn't required in Python 2.6
with client.File() as f:
f.open("root://someserver//somefile")
for line in f:
print line,
Obtain status information for this file.
Parameters: | force (boolean) – do not use the cached information, force re-stating |
---|---|
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and XRootD.client.responses.StatInfo object |
Read a data chunk from a given offset.
Parameters: |
|
---|---|
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and the data that was read |
Read a data chunk from a given offset, until the first newline or EOF encountered.
Parameters: |
|
---|---|
Returns: | data that was read, including the trailing newline |
Return type: | string |
Read lines from a given offset until EOF encountered. Return list of lines read.
Parameters: | offset (integer) – offset from the beginning of the file |
---|---|
Returns: | data that was read, including trailing newlines |
Return type: | list of strings |
Warning
This method will read the whole file into memory if you don’t specify an offset. Think twice about using it if your files are big.
Return an iterator object which will read data chunks from a given offset of the given chunksize until EOF.
Parameters: |
|
---|---|
Returns: | iterator object |
Write a data chunk at a given offset.
Parameters: |
|
---|---|
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and None |
Commit all pending disk writes.
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and None |
---|
Truncate the file to a particular size.
Parameters: | size (integer) – desired size of the file |
---|---|
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and None |
Read scattered data chunks in one operation.
Parameters: | chunks (list of 2-tuples of the form (offset, size)) – list of the chunks to be read. The default maximum chunk size is 2097136 bytes and the default maximum number of chunks per request is 1024. The server may be queried using XRootD.client.FileSystem.query() for the actual settings. |
---|---|
Returns: | tuple containing XRootD.client.responses.XRootDStatus object and XRootD.client.responses.VectorReadInfo object |
Check if the file is open.
Return type: | boolean |
---|
Enable/disable state recovery procedures while the file is open for reading.
Parameters: | enable (boolean) – is read recovery enabled |
---|
Enable/disable state recovery procedures while the file is open for writing or read/write.
Parameters: | enable (boolean) – is write recovery enabled |
---|
Get the data server the file is accessed at.
Returns: | the address of the data server |
---|---|
Return type: | string |