xrootd / xrootd-python

Python bindings for XRootD are now part of the main repository.
https://github.com/xrootd/xrootd
6 stars 8 forks source link

copy not working? #16

Closed cbernet closed 7 years ago

cbernet commented 7 years ago

Hello,

I'm trying to use pyxrootd on mac os x sierra. I have installed xrootd 4.5.0 and I'm able to copy a file to a remote location:

 xrdcp foo.txt root://eospublic.cern.ch//eos/fcc/users/c/cbern/foo.txt

the source package xrootd-4.5.0.tar.gz comes with pyxrootd so at first I tried to use this version. It didn't work for the reasons explained below, and I then tried v0.3.0 of this repository.

Following the instructions given in the documentation, I wrote the following tests:

import unittest

from XRootD import client
from XRootD.client.flags import DirListFlags, OpenFlags, MkDirFlags, QueryCode

myclient = client.FileSystem('root://eospublic.cern.ch/:1094')

remote_dir = '/eos/fcc/users/c/cbern/Test/'
remote_file = remote_dir + '/foo'

class TestXROOTD(unittest.TestCase):

    def test_listdir(self):
        status, listing = myclient.dirlist(remote_dir, DirListFlags.STAT)
        self.assertTrue(status.ok)
        self.assertEqual(listing.parent, remote_dir)

    def test_1_copy_in(self):
        status = myclient.copy(remote_file, 'foo', force=True)
        self.assertTrue(status.ok)

if __name__ == '__main__':
    unittest.main()

The first test works and the second fails because, in filesystem.py, this call fails:

result = self.__fs.copy(source=source, target=target, force=force)[0]

First of all, self.__fs.copy returns a dictionary, and this dictionary has strings as keys. It does not have integer 0 as a key which leads to a KeyError in my case. Looking further, here is the dictionary:

{'status': 1, 'code': 9, 'ok': False, 'errno': 0, 'error': True, 'message': '[ERROR] Invalid arguments', 'fatal': False, 'shellcode': 50}

Why is the code trying to access element 0? What am I doing wrong? the message '[ERROR] Invalid arguments' is not enough for me to understand what's going on, and the debugger does not help. As far as I can see, I just copied the lines in the documentation, http://xrootd.org/doc/python/xrootd-python-0.1.0/examples/filesystem.html

Finally, I tried to run py.test, but it gets stuck here:

[xrootd-python]$ py.test 
============================== test session starts ==============================
platform darwin -- Python 2.7.11, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: /Users/cbernet/Software/xrootd-python, inifile: 
collected 48 items 

tests/test_copy.py  

Could you please help?

Thanks, Colin

cbernet commented 7 years ago

moving this issue to the xrootd github