fix exception handling in setup_file_sftp_userdir
This commit is contained in:
parent
1ad42ca4fd
commit
b2acae7dda
1 changed files with 5 additions and 7 deletions
|
@ -44,8 +44,7 @@ def setup_file_sftp_userdir(username):
|
||||||
The task is rejected if the directory creation fails.
|
The task is rejected if the directory creation fails.
|
||||||
|
|
||||||
:param str username: the user name
|
:param str username: the user name
|
||||||
:raises celery.exceptions.Reject: if the SFTP directory of the user cannot
|
:raises Exception: if the SFTP directory of the user cannot be created
|
||||||
be created
|
|
||||||
:return: the created directory name
|
:return: the created directory name
|
||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
|
@ -58,12 +57,11 @@ def setup_file_sftp_userdir(username):
|
||||||
subprocess.check_output([
|
subprocess.check_output([
|
||||||
'sudo' 'setfacl', '-r', '-m', 'www-data:--x', sftp_directory],
|
'sudo' 'setfacl', '-r', '-m', 'www-data:--x', sftp_directory],
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError as exc:
|
except subprocess.CalledProcessError:
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
'could not create SFTP directory for user %s: %s',
|
'could not create SFTP directory for user %s', username)
|
||||||
username, exc.output
|
raise Exception(
|
||||||
)
|
"could not create SFTP directory for user %s" % username)
|
||||||
raise Reject(exc, requeue=False)
|
|
||||||
return sftp_directory
|
return sftp_directory
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue