Print

Print


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 on EOS at CERN:

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

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 of this call in filesystem.py:

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

First of all, self.__fs.copy returns a dictionary with strings as keys. Because it does not have integer 0 as a key, I'm getting a KeyError. Looking further, here is the dictionary:

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

I think that instead of accessing the value of key 0, the code should first check whether ok is True.
If not, it should probably do something else.

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:

[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  #stuck here ... 

Could you please help?

Thanks,
Colin


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/xrootd/xrootd","title":"xrootd/xrootd","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/xrootd/xrootd"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Copy not working in python api? (#434)"}],"action":{"name":"View Issue","url":"https://github.com/xrootd/xrootd/issues/434"}}}

Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1