Skip to content

Commit 317e49b

Browse files
Print OBJ plugin errors to stderr
1 parent fafe73e commit 317e49b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

linodecli/plugins/obj/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ def set_acl(get_client, args, **kwargs): # pylint: disable=unused-argument
173173

174174
try:
175175
set_acl_func(**set_acl_options)
176-
except ClientError:
176+
except ClientError as e:
177+
print(e, file=sys.stderr)
177178
sys.exit(ExitCodes.REQUEST_FAILED)
178179
print("ACL updated")
179180

@@ -203,14 +204,16 @@ def show_usage(get_client, args, **kwargs): # pylint: disable=unused-argument
203204
bucket_names = [
204205
b["Name"] for b in client.list_buckets().get("Buckets", [])
205206
]
206-
except ClientError:
207+
except ClientError as e:
208+
print(e, file=sys.stderr)
207209
sys.exit(ExitCodes.REQUEST_FAILED)
208210

209211
grand_total = 0
210212
for b in bucket_names:
211213
try:
212214
objects = client.list_objects_v2(Bucket=b).get("Contents", [])
213-
except ClientError:
215+
except ClientError as e:
216+
print(e, file=sys.stderr)
214217
sys.exit(ExitCodes.REQUEST_FAILED)
215218
total = 0
216219
obj_count = 0
@@ -358,7 +361,7 @@ def call(
358361
# we can't do anything - ask for an install
359362
print(
360363
"This plugin requires the 'boto3' module. Please install it by running "
361-
"'pip3 install boto3' or 'pip install boto3'"
364+
"'pip3 install boto3' or 'pip install boto3'", file=sys.stderr,
362365
)
363366

364367
sys.exit(

linodecli/plugins/obj/objects.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def upload_object(
8181
for f in files:
8282
file_path = Path(f).resolve()
8383
if not file_path.is_file():
84+
print(f"Error: '{file_path}' is not a valid file or does not exist.", file=sys.stderr)
8485
sys.exit(ExitCodes.FILE_ERROR)
8586

8687
to_upload.append(file_path)
@@ -112,7 +113,8 @@ def upload_object(
112113
)
113114
try:
114115
client.upload_file(**upload_options)
115-
except S3UploadFailedError:
116+
except S3UploadFailedError as e:
117+
print(e, file=sys.stderr)
116118
sys.exit(ExitCodes.REQUEST_FAILED)
117119

118120
print("Done.")
@@ -174,7 +176,7 @@ def get_object(
174176
# In the future we should allow the automatic creation of parent directories
175177
if not destination_parent.exists():
176178
print(
177-
f"ERROR: Output directory {destination_parent} does not exist locally."
179+
f"ERROR: Output directory {destination_parent} does not exist locally.", file=sys.stderr
178180
)
179181
sys.exit(ExitCodes.REQUEST_FAILED)
180182

0 commit comments

Comments
 (0)