Repository: rucio/rucio

Issue:
list-rse-attributes crashes cli for staging endpoints
Motivation
----------
Since the merge of #1842 `rucio list-rse-attributes` crashes for staging endpoints:
```
[15:45][twegner@lxplus113 ~]$ rucio --version
rucio 1.19.0.post2
[15:45][twegner@lxplus113 ~]$ rucio -v list-rse-attributes TAIWAN-LCG2_TAPE-STAGING
2019-02-26 15:45:25,391	DEBUG	Traceback (most recent call last):
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/rucio-clients/1.19.0.post2/bin/rucio", line 159, in new_funct
    return function(*args, **kwargs)
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/rucio-clients/1.19.0.post2/bin/rucio", line 1479, in list_rse_attributes
    print(tabulate.tabulate(table, tablefmt='plain'))
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/rucio-clients/1.19.0.post2/lib/python2.7/site-packages/tabulate.py", line 1301, in tabulate
    for c, ct, fl_fmt, miss_v in zip(cols, coltypes, float_formats, missing_vals)]
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/rucio-clients/1.19.0.post2/lib/python2.7/site-packages/tabulate.py", line 768, in _format
    return format(float(val), floatfmt)
ValueError: invalid literal for float(): True

2019-02-26 15:45:25,391	ERROR	invalid literal for float(): True
2019-02-26 15:45:25,392	ERROR	Strange error: No section: 'policy'
```


Modification
------------





Discussion:

The problem is with the value '1.0' that is not handled properly by `tabulate` :
 ```
>>> table = [(u'TAIWAN-LCG2_TAPE-STAGING:', 'True'), (u'is_stagingarea:', 'True'), (u'stresstestweight:', '1.0')]
>>> print(tabulate.tabulate(table, tablefmt='plain'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/rucio-clients/1.19.5/lib/python2.7/site-packages/tabulate.py", line 1301, in tabulate
    for c, ct, fl_fmt, miss_v in zip(cols, coltypes, float_formats, missing_vals)]
  File "/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/rucio-clients/1.19.5/lib/python2.7/site-packages/tabulate.py", line 768, in _format
    return format(float(val), floatfmt)
ValueError: could not convert string to float: True
```
vs :
```
>>> table = [(u'TAIWAN-LCG2_TAPE-STAGING:', 'True'), (u'is_stagingarea:', 'True'), (u'stresstestweight:', '1')]
>>> print(tabulate.tabulate(table, tablefmt='plain'))
TAIWAN-LCG2_TAPE-STAGING:  True
is_stagingarea:            True
stresstestweight:             1
```

or :
```
>>> table = [(u'TAIWAN-LCG2_TAPE-STAGING:', 'True'), (u'is_stagingarea:', 'True'), (u'stresstestweight:', '1,0')]
>>> print(tabulate.tabulate(table, tablefmt='plain'))
TAIWAN-LCG2_TAPE-STAGING:  True
is_stagingarea:            True
stresstestweight:          1,0
```

 
Sorry forgot to mention that I've debugged it already to this point. But I won't have time to look further into it ( @bari12 )
@nikmagini @TomasJavurek can you please have a look on this issue. (See @cserf comment)
BTW, the `Strange error: No section: 'policy'` will be fixed here :
https://github.com/rucio/rucio/issues/2514

Resolving patch:
diff --git a/lib/rucio/common/dumper/data_models.py b/lib/rucio/common/dumper/data_models.py
--- a/lib/rucio/common/dumper/data_models.py
+++ b/lib/rucio/common/dumper/data_models.py
@@ -21,7 +21,7 @@
 import operator
 import os
 import re
-import tabulate
+from tabulate import tabulate
 
 from rucio.common.dumper import DUMPS_CACHE_DIR
 from rucio.common.dumper import HTTPDownloadFailed
@@ -121,7 +121,7 @@ def csv(self, fields=None):
 
     @classmethod
     def tabulate_from(cls, iter, format='simple', fields=None):
-        return tabulate.tabulate(
+        return tabulate(
             (row.formated_fields(fields) for row in iter),
             (t[0] for t in cls.SCHEMA),
             format,


Test patch: