Only show sudo hints when relevant
Error message suggesting use of sudo was showing for all exceptions when deleting an image. This change restricts this to only show the 'use sudo' hint when a permissions problem has actually occurred. Change-Id: Id976f04e24ce12be0f7b7b3cc9e00487b31efe30 Closes-Bug: 1859729
This commit is contained in:
parent
1ba4c660e6
commit
54494d2311
|
@ -15,6 +15,7 @@
|
|||
|
||||
import copy
|
||||
import datetime
|
||||
import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
@ -653,8 +654,9 @@ class TripleOContainerImagePush(command.Command):
|
|||
uploader.add_upload_task(task)
|
||||
uploader.run_tasks()
|
||||
except OSError as e:
|
||||
self.log.error("Unable to upload due to permissions. "
|
||||
"Please prefix command with sudo.")
|
||||
if e.errno == errno.EACCES:
|
||||
self.log.error("Unable to upload due to permissions. "
|
||||
"Please prefix command with sudo.")
|
||||
raise oscexc.CommandError(e)
|
||||
|
||||
|
||||
|
@ -720,8 +722,9 @@ class TripleOContainerImageDelete(command.Command):
|
|||
try:
|
||||
uploader.delete(parsed_args.image_to_delete, session=session)
|
||||
except OSError as e:
|
||||
self.log.error("Unable to remove due to permissions. "
|
||||
"Please prefix command with sudo.")
|
||||
if e.errno == errno.EACCES:
|
||||
self.log.error("Unable to remove due to permissions. "
|
||||
"Please prefix command with sudo.")
|
||||
raise oscexc.CommandError(e)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue