Skip to content
Snippets Groups Projects
Commit 1990b155 authored by Cedric Serfon's avatar Cedric Serfon
Browse files

[RUCIO-1598] Fix leading slash for PFN to path + pylint fixes

Change-Id: I57ba894305aec7bef451a369e7828dea5147b93b
parent df71b90f
No related branches found
No related tags found
No related merge requests found
......@@ -94,7 +94,7 @@ class BaseClient(object):
self.user_agent = "%s/%s" % (user_agent, version.version_string()) # e.g. "rucio-clients/0.2.13"
sys.argv[0] = sys.argv[0].split('/')[-1]
self.script_id = '::'.join(sys.argv[0:2])
if (self.script_id == ''): # Python interpreter used
if self.script_id == '': # Python interpreter used
self.script_id = 'python'
try:
if self.host is None:
......@@ -144,10 +144,10 @@ class BaseClient(object):
rucio_scheme = urlparse(self.host).scheme
auth_scheme = urlparse(self.auth_host).scheme
if (rucio_scheme != 'http' and rucio_scheme != 'https'):
if rucio_scheme != 'http' and rucio_scheme != 'https':
raise ClientProtocolNotSupported('\'%s\' not supported' % rucio_scheme)
if (auth_scheme != 'http' and auth_scheme != 'https'):
if auth_scheme != 'http' and auth_scheme != 'https':
raise ClientProtocolNotSupported('\'%s\' not supported' % auth_scheme)
if (rucio_scheme == 'https' or auth_scheme == 'https') and ca_cert is None:
......@@ -333,6 +333,7 @@ class BaseClient(object):
LOG.error('given client key (%s) doesn\'t exist' % client_key)
retry = 0
result = None
if client_key is None:
cert = client_cert
......@@ -358,7 +359,7 @@ class BaseClient(object):
LOG.error('cannot get auth_token')
return False
if result.status_code != codes.ok: # pylint: disable-msg=E1101
if result and result.status_code != codes.ok: # pylint: disable-msg=E1101
exc_cls, exc_msg = self._get_exception(headers=result.headers,
status_code=result.status_code)
raise exc_cls(exc_msg)
......
......@@ -235,8 +235,11 @@ def __declare_bad_file_replicas(pfns, rse, reason, issuer, status=BadFilesStatus
parsed_pfn = proto.parse_pfns(pfns=pfns)
for pfn in parsed_pfn:
path = parsed_pfn[pfn]['path']
if path.startswith('user') or path.startswith('group'):
scope = '%s.%s' % (path.split('/')[0], path.split('/')[1])
if path.startswith('/user') or path.startswith('/group'):
scope = '%s.%s' % (path.split('/')[1], path.split('/')[2])
name = parsed_pfn[pfn]['name']
elif path.startswith('/'):
scope = path.split('/')[1]
name = parsed_pfn[pfn]['name']
else:
scope = path.split('/')[0]
......@@ -433,8 +436,11 @@ def get_did_from_pfns(pfns, rse=None, session=None):
parsed_pfn = proto.parse_pfns(pfns=pfns)
for pfn in parsed_pfn:
path = parsed_pfn[pfn]['path']
if path.startswith('user') or path.startswith('group'):
scope = '%s.%s' % (path.split('/')[0], path.split('/')[1])
if path.startswith('/user') or path.startswith('/group'):
scope = '%s.%s' % (path.split('/')[1], path.split('/')[2])
name = parsed_pfn[pfn]['name']
elif path.startswith('/'):
scope = path.split('/')[1]
name = parsed_pfn[pfn]['name']
else:
scope = path.split('/')[0]
......
......@@ -116,9 +116,7 @@ class Default(protocol.RSEProtocol):
prefix = self.attributes['prefix']
path = path.partition(self.attributes['prefix'])[2]
name = path.split('/')[-1]
# TODO
# path = '/' + path.partition(name)[0] if not self.rse['staging_area'] else None
path = path.partition(name)[0] if not self.rse['staging_area'] else None
path = '/' + path.partition(name)[0] if not self.rse['staging_area'] else None
ret[pfn] = {'scheme': scheme, 'port': port, 'hostname': hostname,
'path': path, 'name': name, 'prefix': prefix,
'web_service_path': service_path}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment