Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise ServerIncompatibleError(repr([url, status, response]))
etype = err.get('__type')
emessage = err.get('message', '').split(': ', 1)[-1]
if etype == 'Search Query Error':
# I refuse to eval(emessage), even if it would be more correct
raise SearchQueryError(emessage)
elif etype == 'Search Error':
# I refuse to eval(emessage), even if it would be more correct
raise SearchError(emessage)
elif etype == 'Search Index Error':
raise SearchIndexError(emessage)
elif etype == 'Validation Error':
raise ValidationError(err)
elif etype == 'Not Found Error':
raise NotFound(emessage)
elif etype == 'Authorization Error':
raise NotAuthorized(err)
# don't recognize the error
raise CKANAPIError(repr([url, status, response]))
_upload_resources(ckan,obj,arguments)
elif thing in ['groups','organizations'] and 'image_display_url' in obj: #load images for groups and organizations
if arguments['--upload-logo']:
users = obj['users']
_upload_logo(ckan,obj)
obj.pop('image_upload')
obj['users'] = users
ckan.call_action(thing_update, obj,
requests_kwargs=requests_kwargs)
except ValidationError as e:
reply(act, 'ValidationError', e.error_dict)
except SearchIndexError as e:
reply(act, 'SearchIndexError', unicode(e))
except NotAuthorized as e:
reply(act, 'NotAuthorized', unicode(e))
except NotFound:
reply(act, 'NotFound', obj)
else:
reply(act, None, r.get('name',r.get('id')))
for line in iter(stdin.readline, b''):
try:
name = json.loads(line.decode('utf-8'))
except UnicodeDecodeError as e:
reply('UnicodeDecodeError', unicode(e))
continue
try:
requests_kwargs = None
if arguments['--insecure']:
requests_kwargs = {'verify': False}
ckan.call_action(thing_delete, {'id': name},
requests_kwargs=requests_kwargs)
except NotAuthorized as e:
reply('NotAuthorized', unicode(e))
except NotFound:
reply('NotFound', name)
else:
reply(None, name)
for line in iter(stdin.readline, b''):
try:
name = json.loads(line.decode('utf-8'))
except UnicodeDecodeError as e:
reply('UnicodeDecodeError')
continue
try:
requests_kwargs = None
if arguments['--insecure']:
requests_kwargs = {'verify': False}
obj = ckan.call_action(thing_show, {'id': name,
'include_datasets': False,
'include_password_hash': True,
}, requests_kwargs=requests_kwargs)
except NotFound:
reply('NotFound')
except NotAuthorized:
reply('NotAuthorized')
else:
if thing == 'datasets' and arguments['--datastore-fields']:
for res in obj.get('resources', []):
populate_datastore_res_fields(ckan, res)
reply(None, obj)
action (Optional[str]): Replacement CKAN action url to use. Defaults to None.
**kwargs: Other fields to pass to CKAN.
Returns:
Tuple[bool, Union[Dict, str]]: (True/False, HDX object metadata/Error)
"""
if not fieldname:
raise HDXError('Empty %s field name!' % object_type)
if action is None:
action = self.actions()['show']
data = {fieldname: value}
data.update(kwargs)
try:
result = self.configuration.call_remoteckan(action, data)
return True, result
except NotFound:
return False, '%s=%s: not found!' % (fieldname, value)
except Exception as e:
raisefrom(HDXError, 'Failed when trying to read: %s=%s! (POST)' % (fieldname, value), e)