Repository: rucio/rucio

Issue:
readthedocs build fails due to pycurl
Motivation
----------
Currently the build process on readthedocs fails.

```
Collecting pycurl>=7.19 (from fts3-rest-API==3.7.1->-r requirements.readthedocs.txt (line 44))
  Using cached https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-jSh8ZH/pycurl/setup.py", line 913, in <module>
        ext = get_extension(sys.argv, split_extension_source=split_extension_source)
      File "/tmp/pip-build-jSh8ZH/pycurl/setup.py", line 582, in get_extension
        ext_config = ExtensionConfiguration(argv)
      File "/tmp/pip-build-jSh8ZH/pycurl/setup.py", line 99, in __init__
        self.configure()
      File "/tmp/pip-build-jSh8ZH/pycurl/setup.py", line 227, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-jSh8ZH/pycurl/
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
```



Discussion:
Still does not work: https://readthedocs.org/projects/rucio/builds/7547086/
So this probably needs to wait until pycurl is an extra in the fts3-rest-api package. For now, although only the requirements.readthedocs.txt should be used, it seems like rucio as a package is pulled in as well, which then requires pycurl via fts3-rest-api, crashing readthedocs build.
Needs a version > 3.7.1 https://pypi.org/project/fts3-rest-API/#history

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -17,9 +17,24 @@
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #
 import os
-# import sys
+import sys
 # sys.path.insert(0, os.path.abspath('.'))
 
+from mock import Mock as MagicMock
+
+
+class Mock(MagicMock):
+    @classmethod
+    def __getattr__(cls, name):
+        return Mock()
+
+    @classmethod
+    def __getitem__(cls, name):
+        return Mock()
+
+
+MOCK_MODULES = ['pycurl']
+sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
 
 # -- General configuration ------------------------------------------------
 
diff --git a/lib/rucio/client/downloadclient.py b/lib/rucio/client/downloadclient.py
--- a/lib/rucio/client/downloadclient.py
+++ b/lib/rucio/client/downloadclient.py
@@ -45,7 +45,7 @@
 
 class DownloadClient:
 
-    def __init__(self, client=None, logger=None):
+    def __init__(self, client=None, logger=None, check_admin=False):
         """
         Initialises the basic settings for an DownloadClient object
 
@@ -62,12 +62,13 @@ def __init__(self, client=None, logger=None):
 
         self.client_location = detect_client_location()
 
-        account_attributes = [acc for acc in self.client.list_account_attributes(self.client.account)]
         self.is_admin = False
-        for attr in account_attributes[0]:
-            if attr['key'] == 'admin':
-                self.is_admin = attr['value'] is True
-                break
+        if check_admin:
+            account_attributes = list(self.client.list_account_attributes(self.client.account))
+            for attr in account_attributes[0]:
+                if attr['key'] == 'admin':
+                    self.is_admin = attr['value'] is True
+                    break
         if self.is_admin:
             logger.debug('Admin mode enabled')
 


Test patch:
diff --git a/lib/rucio/tests/test_bin_rucio.py b/lib/rucio/tests/test_bin_rucio.py
--- a/lib/rucio/tests/test_bin_rucio.py
+++ b/lib/rucio/tests/test_bin_rucio.py
@@ -36,6 +36,7 @@
 from rucio.client.replicaclient import ReplicaClient
 from rucio.common.config import config_get
 from rucio.common.utils import generate_uuid, md5
+from rucio.core.rse import add_rse_attribute
 from rucio.tests.common import execute, account_name_generator, rse_name_generator, file_generator, scope_name_generator
 from rucio.rse import rsemanager as rsemgr
 
@@ -58,6 +59,8 @@ def setup(self):
         self.account_client = AccountLimitClient()
         self.account_client.set_account_limit('root', self.def_rse, -1)
 
+        add_rse_attribute(self.def_rse, 'istape', 'False')
+
         self.upload_success_str = 'Successfully uploaded file %s'
 
     def test_rucio_version(self):