CoEPP RC
 

This is an old revision of the document!


PyXrootd

This page includes some simple examples of how to use the pyxrootd File object to manipulate files on an xrootd server. More information can be found at http://xrootd.org/doc/python/xrootd-python-0.1.2/examples/file.html.

In order to use pyxrootd assuming it's installed you need to do the following

setupATLAS
localSetupROOT
localSetupXRootD

Reading a file

In a python session, one can script

from XRootD import client
from XRootD.client.flags import OpenFlags

with client.File() as f:
  output = f.open('root://xrdmelsr.mel.coepp.org.au//coepp/atlas/cloud/antonio/eggs')
  data = f.readlines()
  print data
  print data[0]

to produce the following output.

['green\n', 'eggs\n', 'and\n', 'ham\n', '\n']
green

Writing a file

Here's an example of how to write a file

>>> from XRootD import client
>>> with client.File() as f:
...      status = f.open('root://xrdmelsr.mel.coepp.org.au//coepp/atlas/cloud/antonio/josephine',OpenFlags.NEW)
...      status = f.write('green\neggs\nand\nham\n')
...      data = f.readlines()
...      print data
...      print data[0]
...
['green\n', 'eggs\n', 'and\n', 'ham\n']
green
tier3/faq/accessing_xrootd_storage_using_pyxrootd.1395633596.txt.gz · Last modified: 2014/03/24 14:59 by antonio
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki