Repository: rucio/rucio

Issue:
setup.py and setup_rucio.py should be the same file
Modification
------------
setup.py and setup_rucio.py should be the same file
Protocol mismatch error in the conveyor
Motivation
----------
Sometimes transfers end-up in protocol mismatch error despite there are matching schemes

Modification
------------
Fix it


Discussion:

Resolving patch:
diff --git a/setup_rucio.py b/setup_rucio.py
--- a/setup_rucio.py
+++ b/setup_rucio.py
@@ -1,13 +1,27 @@
-# Copyright European Organization for Nuclear Research (CERN)
+# Copyright 2012-2018 CERN for the benefit of the ATLAS collaboration.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
-# You may not use this file except in compliance with the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 #
 # Authors:
-# - Vincent Garonne, <vincent.garonne@cern.ch>, 2011-2017
-# - Mario Lassnig, <mario.lassnig@cern.ch>, 2012-2013
-# - Martin Barisits, <martin.barisits@cern.ch>, 2016-2017
+# - Mario Lassnig <mario.lassnig@cern.ch>, 2012-2014
+# - Vincent Garonne <vgaronne@gmail.com>, 2012-2018
+# - Martin Barisits <martin.barisits@cern.ch>, 2012-2017
+# - Wen Guan <wguan.icedew@gmail.com>, 2014
+# - Thomas Beermann <thomas.beermann@cern.ch>, 2014
+
+'''
+Setup.py which moves kerberos modules in extra dependencies to be buildthedocs compliant.
+'''
 
 import glob
 import os
@@ -27,7 +41,6 @@
 
 try:
     from setuptools import setup, find_packages
-#    from setuptools.command.sdist import sdist
 except ImportError:
     from ez_setup import use_setuptools
     use_setuptools()
@@ -48,15 +61,51 @@
 
 scripts = glob.glob('bin/rucio*')
 
-# Arguments to the setup script to build stable release
 copy_args = sys.argv[1:]
 if '--release' in copy_args:
     IsRelease = True
     copy_args.remove('--release')
 
-# If Sphinx is installed on the box running setup.py,
-# enable setup.py to build the documentation, otherwise,
-# just ignore it
+# Flags to know if the installation is done through pip and against git
+using_pip = os.path.basename(os.path.dirname(__file__)).startswith('pip-')
+using_git = os.path.isdir('.git')
+
+
+def run_git_command(cmd):
+    """
+    Run a git command in path and return output"
+
+    :param cmd: the git command.
+    :return: Output of the git command.
+    """
+    output = subprocess.Popen(["/bin/sh", "-c", cmd], stdout=subprocess.PIPE)
+    return output.communicate()[0].strip()
+
+
+if using_pip and using_git:
+    git_version_cmd = '''git describe --dirty=-dev`date +%s`'''
+    pkg_version = run_git_command(git_version_cmd)
+    branch_nick_cmd = 'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "'
+    branch_nick = run_git_command(branch_nick_cmd)
+    revid_cmd = "git rev-parse HEAD"
+    revid = run_git_command(revid_cmd)
+    revno_cmd = "git --no-pager log --oneline | wc -l"
+    revno = run_git_command(revno_cmd)
+    version_file = open("lib/rucio/vcsversion.py", 'w')
+    version_file.write("""'''\n"""
+                       """This file is automatically generated by setup.py, So don't edit it. :)\n"""
+                       """'''\n"""
+                       """VERSION_INFO = {\n"""
+                       """    'final': False,\n"""
+                       """    'version': '%s',\n"""
+                       """    'branch_nick': '%s',\n"""
+                       """    'revision_id': '%s',\n"""
+                       """    'revno': %s\n"""
+                       """}""" % (pkg_version, branch_nick, revid, revno))
+    version_file.close()
+else:
+    pkg_version = version.version_string()
+
 cmdclass = {}
 
 try:
@@ -83,7 +132,9 @@ def parse_requirements(requirements_files):
     requirements = []
     for requirements_file in requirements_files:
         for line in get_reqs_from_file(requirements_file):
-            if re.match(r'\s*-e\s+', line):
+            if 'kerberos' in line:
+                pass
+            elif re.match(r'\s*-e\s+', line):
                 requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line))
             elif re.match(r'\s*-f\s+', line):
                 pass
@@ -116,12 +167,12 @@ def write_requirements():
 oracle_extras = ['cx_oracle>=5.1']
 postgresql_extras = ['psycopg2>=2.4.2']
 mysql_extras = ['PyMySQL']
-
+kerberos_extras = ['kerberos>=1.2.5', 'pykerberos>=1.1.14', 'requests-kerberos>=0.11.0']
 requires = parse_requirements(requirements_files=requirements_files)
 extras_require = dict(oracle=oracle_extras,
                       postgresql=postgresql_extras,
-                      mysql=mysql_extras)
-requires = parse_requirements(requirements_files=requirements_files)
+                      mysql=mysql_extras,
+                      kerberos=kerberos_extras)
 depend_links = parse_dependency_links(requirements_files=requirements_files)
 
 
@@ -145,7 +196,7 @@ def get_file_list(self):
 
 setup(
     name=name,
-    version=version.version_string(),
+    version=pkg_version,
     packages=packages,
     package_dir={'': 'lib'},
     data_files=data_files,


Test patch:
diff --git a/lib/rucio/tests/rsemgr_api_test.py b/lib/rucio/tests/rsemgr_api_test.py
--- a/lib/rucio/tests/rsemgr_api_test.py
+++ b/lib/rucio/tests/rsemgr_api_test.py
@@ -8,6 +8,9 @@
 # Authors:
 # - Ralph Vigne, <ralph.vigne@cern.ch>, 2012-2014
 # - Wen Guan, <wguan@cern.ch>, 2014
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 import json
 import os
@@ -36,7 +39,7 @@ def __init__(self, tmpdir, rse_tag, user, static_file):
                 data = json.load(f)
             self.rse_settings['credentials'] = data[rse_tag]
         except KeyError:
-            print 'No credentials found for this RSE.'
+            print('No credentials found for this RSE.')
             pass
         self.tmpdir = tmpdir
         self.gettmpdir = tempfile.mkdtemp()
diff --git a/lib/rucio/tests/test_alembic.py b/lib/rucio/tests/test_alembic.py
--- a/lib/rucio/tests/test_alembic.py
+++ b/lib/rucio/tests/test_alembic.py
@@ -7,6 +7,9 @@
 #
 # Authors:
 # - Vincent Garonne, <vincent.garonne@cern.ch>, 2014
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 from nose.tools import assert_equal
 
@@ -20,15 +23,15 @@ def test_downgrade_and_upgrade(self):
 
         cmd = 'alembic upgrade head'
         exitcode, out, err = execute(cmd)
-        print cmd
-        print exitcode, out, err
+        print(cmd)
+        print(exitcode, out, err)
         assert_equal(exitcode, 0)
 
         cmd = 'alembic downgrade  -1'
         while exitcode is 0:
             exitcode, out, err = execute(cmd)
-            print cmd
-            print exitcode, out, err
+            print(cmd)
+            print(exitcode, out, err)
             if "Relative revision -1 didn't produce 1 migrations" not in out:
                 assert_equal(exitcode, 0)
             else:
@@ -36,6 +39,6 @@ def test_downgrade_and_upgrade(self):
 
         cmd = 'alembic upgrade head'
         exitcode, out, err = execute(cmd)
-        print cmd
-        print exitcode, out, err
+        print(cmd)
+        print(exitcode, out, err)
         assert_equal(exitcode, 0)
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
@@ -10,13 +10,15 @@
   - Mario Lassnig, <mario.lassnig@cern.ch>, 2012-2013, 2016
   - Angelos Molfetas, <angelos.molfetas@cern.ch>, 2012
   - Thomas Beermann, <thomas.beermann@cern.ch>, 2012
-  - Joaquin Bogado, <joaquin.bogado@cern.ch>, 2014-2015
+  - Joaquin Bogado, <joaquin.bogado@cern.ch>, 2014-2018
   - Cheng-Hsi Chao, <cheng-hsi.chao@cern.ch>, 2014
   - Martin Barisits, <martin.barisits@cern.ch>, 2015
   - Cedric Serfon, <cedric.serfon@cern.ch>, 2015
   - Frank Berghaus, <frank.berghaus@cern.ch>, 2018
 '''
 
+from __future__ import print_function
+
 from os import remove, unlink, listdir, rmdir, stat
 
 import nose.tools
@@ -60,24 +62,24 @@ def test_rucio_version(self):
     def test_rucio_ping(self):
         """CLIENT(USER): Rucio ping"""
         cmd = 'rucio --host %s ping' % self.host
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
 
     def test_add_account(self):
         """CLIENT(ADMIN): Add account"""
         tmp_val = account_name_generator()
         cmd = 'rucio-admin account add %s' % tmp_val
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_equal('Added new account: %s\n' % tmp_val, out)
 
     def test_whoami(self):
         """CLIENT(USER): Rucio whoami"""
         cmd = 'rucio whoami'
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_regexp_matches(out, re.compile('.*account.*'))
 
     def test_add_identity(self):
@@ -87,9 +89,9 @@ def test_add_identity(self):
         exitcode, out, err = execute(cmd)
         nose.tools.assert_equal('Added new account: %s\n' % tmp_val, out)
         cmd = 'rucio-admin identity add --account %s --type GSS --id jdoe@CERN.CH --email jdoe@CERN.CH' % tmp_val
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_equal('Added new identity to account: jdoe@CERN.CH-%s\n' % tmp_val, out)
 
     def test_del_identity(self):
@@ -104,16 +106,16 @@ def test_del_identity(self):
         exitcode, out, err = execute(cmd)
         # delete identity from account
         cmd = 'rucio-admin identity delete --account %s --type GSS --id jdoe@CERN.CH' % tmp_acc
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal('Deleted identity: jdoe@CERN.CH\n', out)
         # list identities for account
         cmd = 'rucio-admin account list-identities %s' % (tmp_acc)
-        print self.marker + cmd
-        print cmd
+        print(self.marker + cmd)
+        print(cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal('', out)
 
     def test_attributes(self):
@@ -126,20 +128,20 @@ def test_attributes(self):
         # add attribute to the account
         cmd = 'rucio-admin account add-attribute {0} --key test_attribute_key --value true'.format(tmp_acc)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_equal(0, exitcode)
         # list attributes
         cmd = 'rucio-admin account list-attributes {0}'.format(tmp_acc)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_equal(0, exitcode)
         # delete attribute to the account
         cmd = 'rucio-admin account delete-attribute {0} --key test_attribute_key'.format(tmp_acc)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_equal(0, exitcode)
 
     def test_add_scope(self):
@@ -149,18 +151,18 @@ def test_add_scope(self):
         cmd = 'rucio-admin account add %s' % tmp_acc
         exitcode, out, err = execute(cmd)
         cmd = 'rucio-admin scope add --account %s --scope %s' % (tmp_acc, tmp_scp)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal('Added new scope to account: %s-%s\n' % (tmp_scp, tmp_acc), out)
 
     def test_add_rse(self):
         """CLIENT(ADMIN): Add RSE"""
         tmp_val = rse_name_generator()
         cmd = 'rucio-admin rse add %s' % tmp_val
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_equal('Added new RSE: %s\n' % tmp_val, out)
 
     def test_list_rses(self):
@@ -169,9 +171,9 @@ def test_list_rses(self):
         cmd = 'rucio-admin rse add %s' % tmp_val
         exitcode, out, err = execute(cmd)
         cmd = 'rucio-admin rse list'
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_regexp_matches(out, re.compile('.*%s.*' % tmp_val))
 
     def test_upload(self):
@@ -180,16 +182,16 @@ def test_upload(self):
         cmd = 'rucio-admin rse add %s' % tmp_val
         exitcode, out, err = execute(cmd)
         cmd = 'rucio upload'
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
 
     def test_download(self):
         """CLIENT(USER): Download"""
         cmd = 'rucio download'
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
 
     def test_upload_file(self):
         """CLIENT(USER): Rucio upload files"""
@@ -197,10 +199,10 @@ def test_upload_file(self):
         tmp_file2 = file_generator()
         tmp_file3 = file_generator()
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4}'.format(self.def_rse, self.user, tmp_file1, tmp_file2, tmp_file3)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
@@ -211,10 +213,10 @@ def test_upload_file_guid(self):
         tmp_file1 = file_generator()
         tmp_guid = generate_uuid()
         cmd = 'rucio upload --rse {0} --guid {1} --scope {2} {3}'.format(self.def_rse, tmp_guid, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         nose.tools.assert_not_equal(re.search("File {0}:{1} successfully uploaded on the storage".format(self.user, tmp_file1[5:]), out), None)
 
@@ -225,31 +227,31 @@ def test_upload_repeated_file(self):
         tmp_file2 = file_generator()
         tmp_file3 = file_generator()
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # get the rule for the file
         cmd = "rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         rule = out
         # delete the file from the catalog
         cmd = "rucio delete-rule {0}".format(rule)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # delete the fisical file
         cmd = "find /tmp/rucio_rse/ -name {0} |xargs rm".format(tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4}'.format(self.def_rse, self.user, tmp_file1, tmp_file2, tmp_file3)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
@@ -264,25 +266,25 @@ def test_upload_repeated_file_dataset(self):
         tmp_dsn = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3}'.format(self.def_rse, self.user, tmp_file1, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # upload the files to the dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4} {5}'.format(self.def_rse, self.user, tmp_file1, tmp_file2, tmp_file3, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
         # searching for the file in the new dataset
         cmd = 'rucio list-files {0}'.format(tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # tmp_file1 must be in the dataset
         nose.tools.assert_not_equal(re.search("{0}:{1}".format(self.user, tmp_file1[5:]), out), None)
         # tmp_file3 must be in the dataset
@@ -296,19 +298,19 @@ def test_upload_file_dataset(self):
         tmp_dsn = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4} {5}'.format(self.def_rse, self.user, tmp_file1, tmp_file2, tmp_file3, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
         # searching for the file in the new dataset
         cmd = 'rucio list-files {0}'.format(tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_not_equal(re.search("{0}:{1}".format(self.user, tmp_file1[5:]), out), None)
 
     def test_upload_adds_md5digest(self):
@@ -318,10 +320,10 @@ def test_upload_adds_md5digest(self):
         file_md5 = md5(filename)
         # user uploads file
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, filename)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # When inspecting the metadata of the new file the user finds the md5 checksum
         meta = self.did_client.get_metadata(scope=self.user, name=filename[5:])
         nose.tools.assert_in('md5', meta)
@@ -332,9 +334,9 @@ def test_create_dataset(self):
         """CLIENT(USER): Rucio add dataset"""
         tmp_name = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         cmd = 'rucio add-dataset ' + tmp_name
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_not_equal(re.search('Added ' + tmp_name, out), None)
 
     def test_add_files_to_dataset(self):
@@ -344,24 +346,24 @@ def test_add_files_to_dataset(self):
         tmp_dataset = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # add files
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3}'.format(self.def_rse, self.user, tmp_file1, tmp_file2)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # create dataset
         cmd = 'rucio add-dataset ' + tmp_dataset
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add files to dataset
         cmd = 'rucio attach {0} {3}:{1} {3}:{2}'.format(tmp_dataset, tmp_file1[5:], tmp_file2[5:], self.user)  # triming '/tmp/' from filename
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # find the added files
         cmd = 'rucio list-files ' + tmp_dataset
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_not_equal(re.search(tmp_file1[5:], out), None)
 
     def test_download_file(self):
@@ -369,19 +371,19 @@ def test_download_file(self):
         tmp_file1 = file_generator()
         # add files
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # download files
         cmd = 'rucio download --dir /tmp {0}:{1}'.format(self.user, tmp_file1[5:])  # triming '/tmp/' from filename
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # search for the files with ls
         cmd = 'ls /tmp/'    # search in /tmp/
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_not_equal(re.search(tmp_file1[5:], out), None)
         try:
             for i in listdir('data13_hip'):
@@ -408,14 +410,14 @@ def test_download_succeeds_md5only(self):
         remove(filename)
         # download files
         cmd = 'rucio download --dir /tmp {0}:{1}'.format(self.user, filename[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # search for the files with ls
         cmd = 'ls /tmp/{0}'.format(self.user)    # search in /tmp/
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_not_equal(re.search(filename[5:], out), None)
         try:
             for i in listdir('data13_hip'):
@@ -443,20 +445,20 @@ def test_download_fails_badmd5(self):
 
         # download file
         cmd = 'rucio download --dir /tmp {0}:{1}'.format(self.user, filename[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
 
         # a failure message 'Checksum mismatch : local _____ vs storage _____' appears
         report = 'Checksum\ mismatch\ \:\ local\ {0}\ vs\ recorded\ 0123456789abcdef0123456789abcdef'.format(file_md5)
-        print 'searching', report, 'in', err
+        print('searching', report, 'in', err)
         nose.tools.assert_not_equal(re.search(report, err), None)
 
         # The file should not exist
         cmd = 'ls /tmp/'    # search in /tmp/
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal(re.search(filename[5:], out), None)
 
         try:
@@ -472,24 +474,24 @@ def test_download_dataset(self):
         tmp_dataset = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # add files
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # create dataset
         cmd = 'rucio add-dataset ' + tmp_dataset
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add files to dataset
         cmd = 'rucio attach {0} {1}:{2}'.format(tmp_dataset, self.user, tmp_file1[5:])  # triming '/tmp/' from filename
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # download dataset
         cmd = 'rucio download --dir /tmp {0}'.format(tmp_dataset)  # triming '/tmp/' from filename
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         search = '{0} successfully downloaded'.format(tmp_file1[5:])  # triming '/tmp/' from filename
         nose.tools.assert_not_equal(re.search(search, err), None)
 
@@ -498,59 +500,59 @@ def test_create_rule(self):
         tmp_file1 = file_generator()
         # add files
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add rse
         tmp_rse = rse_name_generator()
         cmd = 'rucio-admin rse add {0}'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
         # add quota
         set_account_limit('root', get_rse_id(tmp_rse), -1)
         # add rse atributes
         cmd = 'rucio-admin rse set-attribute --rse {0} --key spacetoken --value ATLASSCRATCHDISK'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add rse
         tmp_rse = rse_name_generator()
         cmd = 'rucio-admin rse add {0}'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add quota
         set_account_limit('root', get_rse_id(tmp_rse), -1)
         # add rse atributes
         cmd = 'rucio-admin rse set-attribute --rse {0} --key spacetoken --value ATLASSCRATCHDISK'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add rse
         tmp_rse = rse_name_generator()
         cmd = 'rucio-admin rse add {0}'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add quota
         set_account_limit('root', get_rse_id(tmp_rse), -1)
         # add rse atributes
         cmd = 'rucio-admin rse set-attribute --rse {0} --key spacetoken --value ATLASSCRATCHDISK'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add rules
         cmd = "rucio add-rule {0}:{1} 3 'spacetoken=ATLASSCRATCHDISK'".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
         rule = out[:-1]  # triming new line character
         # check if rule exist for the file
         cmd = "rucio list-rules {0}:{1}".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_not_equal(re.search(rule, out), None)
 
     def test_delete_rule(self):
@@ -559,49 +561,49 @@ def test_delete_rule(self):
         tmp_file1 = file_generator()
         # add files
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add rse
         tmp_rse = rse_name_generator()
         cmd = 'rucio-admin rse add {0}'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
 
         set_account_limit('root', get_rse_id(tmp_rse), -1)
 
         # add rse atributes
         cmd = 'rucio-admin rse set-attribute --rse {0} --key spacetoken --value ATLASSCRATCHDISK'.format(tmp_rse)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add rules
         cmd = "rucio add-rule {0}:{1} 1 'spacetoken=ATLASSCRATCHDISK'".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print err
-        print out
+        print(err)
+        print(out)
         # get the rules for the file
         cmd = "rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         (rule1, rule2) = out.split()
         # delete the rules for the file
         cmd = "rucio delete-rule {0}".format(rule1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         cmd = "rucio delete-rule {0}".format(rule2)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # search for the file
         cmd = "rucio list-dids {0}:{1}".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal(5, len(out.splitlines()))
 
     def test_add_file_twice(self):
@@ -609,10 +611,10 @@ def test_add_file_twice(self):
         tmp_file1 = file_generator()
         # add file twice
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
         nose.tools.assert_equal(re.search("File {0}:{1} successfully uploaded on the storage".format(self.user, tmp_file1[5:]), out), None)
 
@@ -621,35 +623,35 @@ def test_add_delete_add_file(self):
         tmp_file1 = file_generator()
         # add file
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # get the rule for the file
         cmd = "rucio list-rules {0}:{1} | grep {0}:{1} | cut -f1 -d\ ".format(self.user, tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         rule = out
         # delete the file from the catalog
         cmd = "rucio delete-rule {0}".format(rule)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # delete the fisical file
         cmd = "find /tmp/rucio_rse/ -name {0} |xargs rm".format(tmp_file1[5:])
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # modify the file to avoid same checksum
         cmd = "echo 'delta' >> {0}".format(tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         # add the same file
         cmd = 'rucio upload --rse {0} --scope {1} {2}'.format(self.def_rse, self.user, tmp_file1)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal(re.search("File {0}:{1} successfully uploaded on the storage".format(self.user, tmp_file1[5:]), out), None)
 
     def test_attach_files_dataset(self):
@@ -661,31 +663,31 @@ def test_attach_files_dataset(self):
         tmp_dsn = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3}'.format(self.def_rse, self.user, tmp_file1, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # upload the files
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3}'.format(self.def_rse, self.user, tmp_file2, tmp_file3)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
         # attach the files to the dataset
         cmd = 'rucio attach {0} {1}:{2} {1}:{3}'.format(tmp_dsn, self.user, tmp_file2[5:], tmp_file3[5:])  # triming '/tmp/' from filenames
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # searching for the file in the new dataset
         cmd = 'rucio list-files {0}'.format(tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # tmp_file2 must be in the dataset
         nose.tools.assert_not_equal(re.search("{0}:{1}".format(self.user, tmp_file2[5:]), out), None)
         # tmp_file3 must be in the dataset
@@ -700,25 +702,25 @@ def test_detach_files_dataset(self):
         tmp_dsn = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4} {5}'.format(self.def_rse, self.user, tmp_file1, tmp_file2, tmp_file3, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
         # detach the files to the dataset
         cmd = 'rucio detach {0} {1}:{2} {1}:{3}'.format(tmp_dsn, self.user, tmp_file2[5:], tmp_file3[5:])  # triming '/tmp/' from filenames
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # searching for the file in the new dataset
         cmd = 'rucio list-files {0}'.format(tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # tmp_file1 must be in the dataset
         nose.tools.assert_not_equal(re.search("{0}:{1}".format(self.user, tmp_file1[5:]), out), None)
         # tmp_file3 must be in the dataset
@@ -731,17 +733,17 @@ def test_attach_file_twice(self):
         tmp_dsn = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3}'.format(self.def_rse, self.user, tmp_file1, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         # attach the files to the dataset
         cmd = 'rucio attach {0} {1}:{2}'.format(tmp_dsn, self.user, tmp_file1[5:])  # triming '/tmp/' from filenames
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_not_equal(re.search("The file already exists", err), None)
 
     def test_detach_non_existing_file(self):
@@ -750,15 +752,15 @@ def test_detach_non_existing_file(self):
         tmp_dsn = self.user + ':DSet' + rse_name_generator()  # something like mock:DSetMOCK_S0M37HING
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3}'.format(self.def_rse, self.user, tmp_file1, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         # attach the files to the dataset
         cmd = 'rucio detach {0} {1}:{2}'.format(tmp_dsn, self.user, 'file_ghost')  # triming '/tmp/' from filenames
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_not_equal(re.search("Data identifier not found.", err), None)
diff --git a/lib/rucio/tests/test_clients.py b/lib/rucio/tests/test_clients.py
--- a/lib/rucio/tests/test_clients.py
+++ b/lib/rucio/tests/test_clients.py
@@ -10,8 +10,11 @@
  - Thomas Beermann, <thomas.beermann@cern.ch>, 2012
  - Mario Lassnig, <mario.lassnig@cern.ch>, 2014
  - Cedric Serfon, <cedric.serfon@cern.ch>, 2017
+ - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
 '''
 
+from __future__ import print_function
+
 from os import remove
 
 from nose.tools import raises
@@ -89,4 +92,4 @@ def test_ping(self):
 
         client = Client(account='root', ca_cert=self.cacert, auth_type='userpass', creds=creds)
 
-        print client.ping()
+        print(client.ping())
diff --git a/lib/rucio/tests/test_curl.py b/lib/rucio/tests/test_curl.py
--- a/lib/rucio/tests/test_curl.py
+++ b/lib/rucio/tests/test_curl.py
@@ -8,11 +8,14 @@
   Authors:
   - Vincent Garonne, <vincent.garonne@cern.ch>, 2012-2017
   - Mario Lassnig, <mario.lassnig@cern.ch>, 2012, 2014
+  - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
 
   How to generate test outputs/Test the API via CURL:
     nosetests --verbose --with-outputsave --save-directory=doc/source/example_outputs/ lib/rucio/tests/test_curl.py
 '''
 
+from __future__ import print_function
+
 import json
 import os
 import nose.tools
@@ -39,9 +42,9 @@ def setup(self):
     def test_ping(self):
         """PING (CURL): Get Version"""
         cmd = 'curl --cacert %s -s -X GET %s/ping' % (self.cacert, self.host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         ret = json.loads(out)
         nose.tools.assert_true('version' in ret)
         nose.tools.assert_is_instance(ret, dict)
@@ -49,17 +52,17 @@ def test_ping(self):
     def test_get_auth_userpass(self):
         """AUTH (CURL): Test auth token retrieval with via username and password"""
         cmd = 'curl -s -i --cacert %s -X GET -H "X-Rucio-Account: root" -H "X-Rucio-Username: ddmlab" -H "X-Rucio-Password: secret" %s/auth/userpass' % (self.cacert, self.auth_host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
 
     def test_get_auth_x509(self):
         """AUTH (CURL): Test auth token retrieval with via x509"""
         cmd = 'curl -s -i --cacert %s -H "X-Rucio-Account: root" -E %s -X GET %s/auth/x509' % (self.cacert, self.usercert, self.auth_host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
 
     def test_get_auth_GSS(self):
@@ -69,9 +72,9 @@ def test_get_auth_GSS(self):
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
         os.environ['RUCIO_TOKEN'] = out[len('X-Rucio-Auth-Token: '):].rstrip()
         cmd = 'curl -s -i --cacert %s -H "X-Rucio-Account: root" --negotiate -u: -X GET %s/auth/gss' % (self.cacert, self.auth_host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         # nose.tools.assert_in('X-Rucio-Auth-Token', out)
 
     def test_get_auth_x509_proxy(self):
@@ -81,9 +84,9 @@ def test_get_auth_x509_proxy(self):
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
         os.environ['RUCIO_TOKEN'] = out[len('X-Rucio-Auth-Token: '):].rstrip()
         cmd = 'curl -s -i --cacert %s -H "X-Rucio-Account: vgaronne" --cert $X509_USER_PROXY --key $X509_USER_PROXY -X GET %s/auth/x509_proxy' % (self.cacert, self.auth_host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out,
+        print(out, )
         # nose.tools.assert_in('X-Rucio-Auth-Token', out)
 
     def test_get_auth_validate(self):
@@ -93,9 +96,9 @@ def test_get_auth_validate(self):
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
         os.environ['RUCIO_TOKEN'] = out[len('X-Rucio-Auth-Token: '):].rstrip()
         cmd = 'curl -s -i --cacert %s  -H "X-Rucio-Auth-Token: $RUCIO_TOKEN" -X GET %s/auth/validate' % (self.cacert, self.auth_host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
         nose.tools.assert_in('datetime.datetime', out)
 
     def test_post_account(self):
@@ -105,22 +108,22 @@ def test_post_account(self):
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
         os.environ['RUCIO_TOKEN'] = out[len('X-Rucio-Auth-Token: '):].rstrip()
         cmd = '''curl -s -i --cacert %s -H "X-Rucio-Auth-Token: $RUCIO_TOKEN" -H "Rucio-Type: user" -d '{"type": "USER", "email": "rucio@email.com"}' -X POST %s/accounts/%s''' % (self.cacert, self.host, account_name_generator())
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
         nose.tools.assert_in('201 Created', out)
 
     def test_get_accounts_whoami(self):
         """ACCOUNT (CURL): Test whoami method"""
         cmd = 'curl -s -i --cacert %s -H "X-Rucio-Account: root" -E %s -X GET %s/auth/x509 | tr -d \'\r\' | grep X-Rucio-Auth-Token:' % (self.cacert, self.usercert, self.auth_host)
-        print cmd
+        print(cmd)
         exitcode, out, err = execute(cmd)
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
         os.environ['RUCIO_TOKEN'] = out[len('X-Rucio-Auth-Token: '):].rstrip()
         cmd = '''curl -s -i -L --cacert %s -H "X-Rucio-Auth-Token: $RUCIO_TOKEN" -X GET %s/accounts/whoami''' % (self.cacert, self.host)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
         nose.tools.assert_in('303 See Other', out)
 
     def test_post_rse(self):
@@ -130,7 +133,7 @@ def test_post_rse(self):
         nose.tools.assert_in('X-Rucio-Auth-Token', out)
         os.environ['RUCIO_TOKEN'] = out[len('X-Rucio-Auth-Token: '):].rstrip()
         cmd = '''curl -s -i --cacert %s -H "X-Rucio-Auth-Token: $RUCIO_TOKEN" -X POST %s/rses/%s''' % (self.cacert, self.host, rse_name_generator())
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
+        print(out)
         nose.tools.assert_in('201 Created', out)
diff --git a/lib/rucio/tests/test_did.py b/lib/rucio/tests/test_did.py
--- a/lib/rucio/tests/test_did.py
+++ b/lib/rucio/tests/test_did.py
@@ -12,6 +12,9 @@
 # - Yun-Pin Sun, <yun-pin.sun@cern.ch>, 2013
 # - Martin Barisits, <martin.barisits@cern.ch>, 2013-2015
 # - Cedric Serfon, <cedric.serfon@cern.ch>, 2013-2015
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 from datetime import datetime, timedelta
 
@@ -45,7 +48,7 @@ class TestDIDCore:
     def test_list_dids(self):
         """ DATA IDENTIFIERS (CORE): List dids """
         for d in list_dids(scope='data13_hip', filters={'name': '*'}, type='collection'):
-            print d
+            print(d)
 
     def test_delete_dids(self):
         """ DATA IDENTIFIERS (CORE): Delete dids """
diff --git a/lib/rucio/tests/test_replica.py b/lib/rucio/tests/test_replica.py
--- a/lib/rucio/tests/test_replica.py
+++ b/lib/rucio/tests/test_replica.py
@@ -10,6 +10,9 @@
 # - Mario Lassnig, <mario.lassnig@cern.ch>, 2013-2014, 2016-2018
 # - Cedric Serfon, <cedric.serfon@cern.ch>, 2014-2016
 # - Thomas Beermann, <thomas.beermann@cern.ch>, 2014
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 import xmltodict
 
@@ -151,7 +154,7 @@ def test_delete_replicas(self):
 
         for file in files1:
             with assert_raises(DataIdentifierNotFound):
-                print get_did(scope=file['scope'], name=file['name'])
+                print(get_did(scope=file['scope'], name=file['name']))
 
         for file in files2:
             get_did(scope=file['scope'], name=file['name'])
@@ -383,9 +386,9 @@ def test_add_list_bad_replicas(self):
         for replica in self.replica_client.list_replicas(dids=[{'scope': f['scope'], 'name': f['name']} for f in files], schemes=['srm'], unavailable=True):
             replicas.extend(replica['rses']['MOCK2'])
             list_rep.append(replica)
-        print replicas, list_rep
+        print(replicas, list_rep)
         r = self.replica_client.declare_bad_file_replicas(replicas, 'This is a good reason')
-        print r
+        print(r)
         assert_equal(r, {})
         bad_replicas = list_bad_replicas()
         nbbadrep = 0
diff --git a/lib/rucio/tests/test_rse.py b/lib/rucio/tests/test_rse.py
--- a/lib/rucio/tests/test_rse.py
+++ b/lib/rucio/tests/test_rse.py
@@ -15,8 +15,11 @@
  - Cedric Serfon, <cedric.serfon@cern.ch>, 2014-2015
  - Ralph Vigne, <ralph.vigne@cern.ch>, 2013-2015
  - Wen Guan, <wen.guan@cern.ch>, 2015
+ - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
 '''
 
+from __future__ import print_function
+
 from json import dumps
 from nose.tools import raises, assert_equal, assert_true, assert_in, assert_raises
 from paste.fixture import TestApp
@@ -302,7 +305,7 @@ def test_add_protocol(self):
                ((p['port'] == 20) and (p['domains']['lan']['read'] != 2)) or \
                ((p['port'] == 18) and (p['domains']['lan']['read'] != 1)) or \
                ((p['port'] == 17) and (p['domains']['lan']['read'] != 4)):
-                print resp
+                print(resp)
                 assert False
 
         self.client.delete_protocols(protocol_rse, scheme='MOCK')
@@ -746,8 +749,8 @@ def test_get_protocols_defaults(self):
         for op in ['delete', 'read', 'write']:
             # resp = self.client.get_protocols(protocol_rse, operation=op, default=True, protocol_domain='lan')
             p = mgr.select_protocol(rse_attr, op, domain='lan')
-            print p['scheme']
-            print op
+            print(p['scheme'])
+            print(op)
             if op not in p['scheme'].lower():
                 for p in protocols:
                     self.client.delete_protocols(protocol_rse, p['scheme'])
@@ -1054,13 +1057,13 @@ def test_swap_protocol(self):
         for p in prots:
             if p['scheme'] == 'MOCKA':
                 if p['domains']['lan']['read'] != 3:
-                    print 'MOCKA with unexpected priority'
-                    print prots
+                    print('MOCKA with unexpected priority')
+                    print(prots)
                     assert(False)
             if p['scheme'] == 'MOCKC':
                 if p['domains']['lan']['read'] != 1:
-                    print 'MOCKC with unexpected priority'
-                    print prots
+                    print('MOCKC with unexpected priority')
+                    print(prots)
                     assert(False)
         assert(True)
 
@@ -1248,5 +1251,5 @@ def test_add_distance(self):
                                     parameters={'distance': 0})
 
         for distance in self.client.get_distance(source=source, destination=destination):
-            print distance
+            print(distance)
             assert_equal(distance['distance'], 0)
diff --git a/lib/rucio/tests/test_rse_protocol_posix.py b/lib/rucio/tests/test_rse_protocol_posix.py
--- a/lib/rucio/tests/test_rse_protocol_posix.py
+++ b/lib/rucio/tests/test_rse_protocol_posix.py
@@ -7,6 +7,9 @@
 #
 # Authors:
 # - Ralph Vigne, <ralph.vigne@cern.ch>, 2012-2013
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 """
 Test the posix protocol
@@ -53,7 +56,7 @@ def setupClass(cls):
         try:
             os.mkdir(prefix)
         except Exception, e:
-            print e
+            print(e)
         os.system('dd if=/dev/urandom of=%s/data.raw bs=1024 count=1024' % prefix)
         cls.static_file = '%s/data.raw' % prefix
         for f in MgrTestCases.files_remote:
diff --git a/lib/rucio/tests/test_rse_protocol_s3boto.py b/lib/rucio/tests/test_rse_protocol_s3boto.py
--- a/lib/rucio/tests/test_rse_protocol_s3boto.py
+++ b/lib/rucio/tests/test_rse_protocol_s3boto.py
@@ -7,6 +7,9 @@
 #
 # Authors:
 # - Wen Guan, <wen.guan@cern.ch>, 2014
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 import json
 import os
@@ -72,7 +75,7 @@ def setupClass(cls):
                 data = json.load(f)
             rse_settings['credentials'] = data[rse_tag]
         except KeyError:
-            print 'No credentials found for this RSE.'
+            print('No credentials found for this RSE.')
             pass
 
         for protocol in rse_settings['protocols']:
@@ -111,7 +114,7 @@ def tearDownClass(cls):
                 data = json.load(f)
             rse_settings['credentials'] = data[rse_tag]
         except KeyError:
-            print 'No credentials found for this RSE.'
+            print('No credentials found for this RSE.')
             pass
 
         for protocol in rse_settings['protocols']:
diff --git a/lib/rucio/tests/test_rse_protocol_s3es.py b/lib/rucio/tests/test_rse_protocol_s3es.py
--- a/lib/rucio/tests/test_rse_protocol_s3es.py
+++ b/lib/rucio/tests/test_rse_protocol_s3es.py
@@ -7,6 +7,9 @@
 #
 # Authors:
 # - Wen Guan, <wen.guan@cern.ch>, 2016
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 import json
 import os
@@ -54,13 +57,13 @@ def setupClass(cls):
             try:
                 storage.put('%s/%s' % (cls.tmpdir, f), destfile)
             except FileReplicaAlreadyExists, e:
-                print e
+                print(e)
         f = 'data.raw'
         destfile = rsemanager.lfns2pfns(rse_settings, [{'name': f, 'scope': 'user.%s' % (cls.user)}, ], operation='write', scheme='s3+https').values()[0]
         try:
             storage.put('%s/%s' % (cls.tmpdir, f), destfile)
         except FileReplicaAlreadyExists, e:
-            print e
+            print(e)
 
     @classmethod
     def tearDownClass(cls):
@@ -81,11 +84,11 @@ def tearDownClass(cls):
         try:
             storage.delete('%s://%s:%s/%s/%s' % (scheme, hostname, port, prefix, 'user'))
         except Exception, e:
-            print e
+            print(e)
         try:
             storage.delete('%s://%s:%s/%s/%s' % (scheme, hostname, port, prefix, 'group'))
         except Exception, e:
-            print e
+            print(e)
 
     def setup(self):
         """S3ES (RSE/PROTOCOLS): Creating Mgr-instance """
diff --git a/lib/rucio/tests/test_rse_protocol_signeds3.py b/lib/rucio/tests/test_rse_protocol_signeds3.py
--- a/lib/rucio/tests/test_rse_protocol_signeds3.py
+++ b/lib/rucio/tests/test_rse_protocol_signeds3.py
@@ -9,7 +9,11 @@
  Authors:
  - Wen Guan, <wen.guan@cern.ch>, 2016
  - Vincent Garonne, <vincent.garonne@cern.ch>, 2013
+ - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
 '''
+
+from __future__ import print_function
+
 import json
 import os
 import tempfile
@@ -62,13 +66,13 @@ def setupClass(cls):
             try:
                 storage.put('%s/%s' % (cls.tmpdir, f), destfile)
             except FileReplicaAlreadyExists, e:
-                print e
+                print(e)
         f = 'data.raw'
         destfile = rsemanager.lfns2pfns(rse_settings, [{'name': f, 'scope': 'user.%s' % (cls.user)}, ], operation='write', scheme='s3+https').values()[0]
         try:
             storage.put('%s/%s' % (cls.tmpdir, f), destfile)
         except FileReplicaAlreadyExists, e:
-            print e
+            print(e)
 
     @classmethod
     def tearDownClass(cls):
@@ -85,11 +89,11 @@ def tearDownClass(cls):
         try:
             storage.delete('%s://%s:%s/%s/%s' % (scheme, hostname, port, prefix, 'user'))
         except Exception, e:
-            print e
+            print(e)
         try:
             storage.delete('%s://%s:%s/%s/%s' % (scheme, hostname, port, prefix, 'group'))
         except Exception, e:
-            print e
+            print(e)
 
     def setup(self):
         """SignedS3 (RSE/PROTOCOLS): Creating Mgr-instance """
diff --git a/lib/rucio/tests/test_rse_protocol_webdav.py b/lib/rucio/tests/test_rse_protocol_webdav.py
--- a/lib/rucio/tests/test_rse_protocol_webdav.py
+++ b/lib/rucio/tests/test_rse_protocol_webdav.py
@@ -8,6 +8,9 @@
 # Authors:
 # - Cedric Serfon, <cedric.serfon@cern.ch>, 2012
 # - Ralph Vigne, <ralph.vigne@cern.ch>, 2012
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 """
 Test the WebDAV protocol
@@ -70,7 +73,7 @@ def setupClass(cls):
             try:
                 storage.put('%s/%s' % (cls.tmpdir, f), destfile)
             except FileReplicaAlreadyExists, e:
-                print e
+                print(e)
         with open('%s/data.raw' % cls.tmpdir, 'rb') as f_file:
             session.put(cls.static_file, data=f_file.read(), verify=False, allow_redirects=True)
 
@@ -85,12 +88,12 @@ def tearDownClass(cls):
         hostname = data[cls.site]['protocols']['supported']['https']['hostname']
         port = data[cls.site]['protocols']['supported']['https']['port']
         storage = rsemanager.create_protocol(rse_settings, operation='write', scheme='https')
-        print rse_settings
+        print(rse_settings)
         storage.connect()
         status1 = storage.delete('%s://%s:%s%suser/%s' % (scheme, hostname, port, prefix, cls.user))
-        print status1
+        print(status1)
         status2 = storage.delete('%s://%s:%s%sgroup/%s' % (scheme, hostname, port, prefix, cls.user))
-        print status2
+        print(status2)
 
     def setup(self):
         """WebDAV (RSE/PROTOCOLS): Creating Mgr-instance """
diff --git a/lib/rucio/tests/test_rse_protocol_xrootd.py b/lib/rucio/tests/test_rse_protocol_xrootd.py
--- a/lib/rucio/tests/test_rse_protocol_xrootd.py
+++ b/lib/rucio/tests/test_rse_protocol_xrootd.py
@@ -8,6 +8,9 @@
 # Authors:
 # - WeiJen Chang, <wchang@cern.ch>, 2013
 # - Cheng-Hsi Chao, <cheng-hsi.chao@cern.ch>, 2014
+# - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
+
+from __future__ import print_function
 
 import json
 import os
@@ -53,7 +56,7 @@ def setupClass(cls):
         try:
             os.mkdir(prefix)
         except Exception, e:
-            print e
+            print(e)
 
         os.system('dd if=/dev/urandom of=%s/data.raw bs=1024 count=1024' % prefix)
         cls.static_file = 'xroot://%s:%d/%s/data.raw' % (hostname, port, prefix)
diff --git a/lib/rucio/tests/test_rucio_server.py b/lib/rucio/tests/test_rucio_server.py
--- a/lib/rucio/tests/test_rucio_server.py
+++ b/lib/rucio/tests/test_rucio_server.py
@@ -5,9 +5,11 @@
 # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 #
 # Authors:
-# - Joaquin Bogado, <joaquin.bogado@cern.ch>, 2014
+# - Joaquin Bogado, <joaquin.bogado@cern.ch>, 2014-2018
 # - Cedric Serfon, <cedric.serfon@cern.ch>, 2015
 
+from __future__ import print_function
+
 import nose.tools
 import subprocess
 from os import remove
@@ -50,16 +52,16 @@ def file_generator(size=2048, namelen=10):
 
 def delete_rules(did):
     # get the rules for the file
-    print 'Deleting rules'
+    print('Deleting rules')
     cmd = "rucio list-rules --did {0} | grep {0} | cut -f1 -d\ ".format(did)
-    print cmd
+    print(cmd)
     exitcode, out, err = execute(cmd)
-    print out, err
+    print(out, err)
     rules = out.split()
     # delete the rules for the file
     for rule in rules:
         cmd = "rucio delete-rule {0}".format(rule)
-        print cmd
+        print(cmd)
         exitcode, out, err = execute(cmd)
 
 
@@ -79,17 +81,17 @@ def tearDown(self):
     def test_ping(self):
         """CLIENT (USER): rucio ping"""
         cmd = 'rucio ping'
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal(0, exitcode)
 
     def test_whoami(self):
         """CLIENT (USER): rucio whoami"""
         cmd = 'rucio whoami'
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out, err
+        print(out, err)
         nose.tools.assert_equal(0, exitcode)
 
     def test_upload_download(self):
@@ -101,10 +103,10 @@ def test_upload_download(self):
 
         # Adding files to a new dataset
         cmd = 'rucio upload --rse {0} --scope {1} {2} {3} {4} {1}:{5}'.format(self.rse, self.scope, tmp_file1, tmp_file2, tmp_file3, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         remove(tmp_file1)
         remove(tmp_file2)
         remove(tmp_file3)
@@ -112,32 +114,32 @@ def test_upload_download(self):
 
         # List the files
         cmd = 'rucio list-files {0}:{1}'.format(self.scope, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_equal(0, exitcode)
 
         # List the replicas
         cmd = 'rucio list-file-replicas {0}:{1}'.format(self.scope, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         nose.tools.assert_equal(0, exitcode)
 
         # Downloading dataset
         cmd = 'rucio download --dir /tmp/ {0}:{1}'.format(self.scope, tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print out
-        print err
+        print(out)
+        print(err)
         # The files should be there
         cmd = 'ls /tmp/{0}/rucio_testfile_*'.format(self.scope)
         cmd = 'ls /tmp/{0}/rucio_testfile_*'.format(tmp_dsn)
-        print self.marker + cmd
+        print(self.marker + cmd)
         exitcode, out, err = execute(cmd)
-        print err, out
+        print(err, out)
         nose.tools.assert_equal(0, exitcode)
         # cleaning
         remove('/tmp/{0}/'.format(tmp_dsn) + tmp_file1[5:])
diff --git a/lib/rucio/tests/test_subscription.py b/lib/rucio/tests/test_subscription.py
--- a/lib/rucio/tests/test_subscription.py
+++ b/lib/rucio/tests/test_subscription.py
@@ -10,8 +10,11 @@
  - Cedric Serfon, <cedric.serfon@cern.ch>, 2013-2015, 2017
  - Thomas Beermann, <thomas.beermann@cern.ch>, 2014
  - Martin Barisits, <martin.barisits@cern.ch>, 2015-2016
+ - Joaquin Bogado, <jbogado@linti.unlp.edu.ar>, 2018
 """
 
+from __future__ import print_function
+
 from json import dumps, loads
 
 from nose.tools import assert_equal, assert_true, raises, assert_raises
@@ -260,7 +263,7 @@ def test_list_rules_states(self):
         res2 = TestApp(subs_app.wsgifunc(*mw)).get('/%s/%s/Rules/States' % ('root', subscription_name), headers=headers2, expect_errors=True)
 
         for line in res2.body.split('\n'):
-            print line
+            print(line)
             rs = loads(line)
             if rs[1] == subscription_name:
                 break