Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except Exception as error:
raise RucioException('Failed to execute aria2c!', error)
# if port is in use aria should fail to start so give it some time
time.sleep(2)
# did it fail?
if rpcproc.poll() is not None:
(out, err) = rpcproc.communicate()
logger.debug('Failed to start aria2c with port: %d' % port)
logger.debug('aria2c output: %s' % out)
else:
break
if rpcproc.poll() is not None:
raise RucioException('Failed to start aria2c rpc server!')
try:
aria_rpc = RPCServerProxy('http://localhost:%d/rpc' % port)
except Exception as error:
rpcproc.kill()
raise RucioException('Failed to initialise rpc proxy!', error)
return (rpcproc, aria_rpc)
:param session: Database session to use.
"""
try:
for request_id in transfers:
rowcount = session.query(models.Request)\
.filter_by(id=request_id)\
.filter(models.Request.state == RequestState.SUBMITTING)\
.update({'state': transfers[request_id]['state'],
'external_id': transfers[request_id]['external_id'],
'external_host': transfers[request_id]['external_host'],
'source_rse_id': transfers[request_id]['src_rse_id'],
'submitted_at': submitted_at},
synchronize_session=False)
if rowcount == 0:
raise RucioException("Failed to set requests %s tansfer %s: request doesn't exist or is not in SUBMITTING state" % (request_id, transfers[request_id]))
request_type = transfers[request_id].get('request_type', None)
msg = {'request-id': request_id,
'request-type': str(request_type).lower() if request_type else request_type,
'scope': transfers[request_id]['scope'].external,
'name': transfers[request_id]['name'],
'src-rse-id': transfers[request_id]['metadata'].get('src_rse_id', None),
'src-rse': transfers[request_id]['metadata'].get('src_rse', None),
'dst-rse-id': transfers[request_id]['metadata'].get('dst_rse_id', None),
'dst-rse': transfers[request_id]['metadata'].get('dst_rse', None),
'state': str(transfers[request_id]['state']),
'activity': transfers[request_id]['metadata'].get('activity', None),
'file-size': transfers[request_id]['metadata'].get('filesize', None),
'bytes': transfers[request_id]['metadata'].get('filesize', None),
'checksum-md5': transfers[request_id]['metadata'].get('md5', None),
'checksum-adler': transfers[request_id]['metadata'].get('adler32', None),
:param request_id: Request-ID as a 32 character hex string.
:param session: Database session to use.
:returns: Request as a dictionary.
"""
try:
tmp = session.query(models.Request).filter_by(id=request_id).first()
if not tmp:
return
else:
tmp = dict(tmp)
tmp.pop('_sa_instance_state')
return tmp
except IntegrityError as error:
raise RucioException(error.args)
if not self.renaming:
params.strict_copy = True
try:
if transfer_timeout:
watchdog.start()
ret = ctx.filecopy(params, str(src), str(dest))
if transfer_timeout:
watchdog.cancel()
return ret
except gfal2.GError as error: # pylint: disable=no-member
if transfer_timeout:
watchdog.cancel()
if error.code == errno.ENOENT or 'No such file' in str(error):
raise exception.SourceNotFound(error)
raise exception.RucioException(error)
client.store_registration_info(client_reg)
# setting public_key cache timeout to 'keytimeout' seconds
keybundles = client.keyjar.issuer_keys[client.issuer]
for keybundle in keybundles:
keybundle.cache_time = keytimeout
clients[issuer] = client
# doing the same to store a Rucio Admin client
# which has client credential flow allowed
client_secret = client_secrets[iss]["SCIM"]
client = Client(client_authn_method=CLIENT_AUTHN_METHOD)
client.provider_config(issuer)
client_reg = RegistrationResponse(**client_secret)
client.store_registration_info(client_reg)
admin_clients[issuer] = client
except Exception as error:
raise RucioException(error.args)
return (clients, admin_clients)
if not existing_content or (scope, name, file['scope'], file['name']) not in existing_content:
contents.append(existing_files[did_tag])
# insert into archive_contents
try:
new_files and session.bulk_insert_mappings(models.DataIdentifier, new_files)
if existing_files_condition:
for chunk in chunks(existing_files_condition, 20):
session.query(models.DataIdentifier).\
with_hint(models.DataIdentifier, "INDEX(DIDS DIDS_PK)", 'oracle').\
filter(models.DataIdentifier.did_type == DIDType.FILE).\
filter(or_(*chunk)).update({'constituent': True})
contents and session.bulk_insert_mappings(models.ConstituentAssociation, contents)
session.flush()
except IntegrityError as error:
raise exception.RucioException(error.args)
"""
space_token = ''
if self.attributes['extended_attributes'] is not None and 'space_token' in list(self.attributes['extended_attributes'].keys()):
space_token = '--dst %s' % self.attributes['extended_attributes']['space_token']
try:
cmd = 'lcg-cp $LCGVO -v -b --srm-timeout 3600 -D srmv2 %s %s %s' % (space_token, path, new_path)
status, out, err = execute(cmd)
if status:
raise exception.RucioException(err)
cmd = 'lcg-del $LCGVO -v -b -l --srm-timeout 600 -D srmv2 %s' % (path)
status, out, err = execute(cmd)
if status:
raise exception.RucioException(err)
except Exception as error:
raise exception.ServiceUnavailable(error)
'bytes': transfers[request_id]['metadata'].get('filesize', None),
'checksum-md5': transfers[request_id]['metadata'].get('md5', None),
'checksum-adler': transfers[request_id]['metadata'].get('adler32', None),
'external-id': transfers[request_id]['external_id'],
'external-host': transfers[request_id]['external_host'],
'queued_at': str(submitted_at)}
if msg['request-type']:
transfer_status = '%s-%s' % (msg['request-type'], msg['state'])
else:
transfer_status = 'transfer-%s' % msg['state']
transfer_status = transfer_status.lower()
message_core.add_message(transfer_status, msg, session=session)
except IntegrityError as error:
raise RucioException(error.args)
if not os.path.exists(source_url):
raise exception.SourceNotFound()
space_token = ''
if self.attributes['extended_attributes'] is not None and 'space_token' in list(self.attributes['extended_attributes'].keys()):
space_token = '--dst %s' % self.attributes['extended_attributes']['space_token']
timeout_option = ''
if transfer_timeout:
timeout_option = '--sendreceive-timeout %s' % transfer_timeout
try:
cmd = 'lcg-cp $LCGVO -v -b --srm-timeout 3600 %s -D srmv2 %s file:%s %s' % (timeout_option, space_token, source_url, target)
status, out, err = execute(cmd)
if status:
raise exception.RucioException(err)
except Exception as error:
raise exception.ServiceUnavailable(error)