diff mbox series

Fix return code when getting patch information fails

Message ID 20190108123834.2225-1-alialnu@mellanox.com
State Accepted
Headers show
Series Fix return code when getting patch information fails | expand

Commit Message

Ali Alnubani Jan. 8, 2019, 12:38 p.m. UTC
The `info` command always exits with success, even if
the patch didn't exist.
Modified to exit with a non-zero exit status and
print an error message in that case.

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
---
 pwclient/shell.py | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Stephen Finucane Feb. 25, 2019, 10:29 a.m. UTC | #1
On Tue, 2019-01-08 at 12:38 +0000, Ali Alnubani wrote:
> The `info` command always exits with success, even if
> the patch didn't exist.
> Modified to exit with a non-zero exit status and
> print an error message in that case.
> 
> Signed-off-by: Ali Alnubani <alialnu@mellanox.com>

Thanks, Ali, and sorry for the delayed response. This is applied now.

Keep up the good work :)
Stephen
diff mbox series

Patch

diff --git a/pwclient/shell.py b/pwclient/shell.py
index 2cff3a3..43c7a37 100644
--- a/pwclient/shell.py
+++ b/pwclient/shell.py
@@ -275,6 +275,12 @@  def action_states(rpc):
 
 def action_info(rpc, patch_id):
     patch = rpc.patch_get(patch_id)
+
+    if patch == {}:
+        sys.stderr.write("Error getting information on patch ID %d\n" %
+                         patch_id)
+        sys.exit(1)
+
     s = "Information for patch id %d" % (patch_id)
     print(s)
     print('-' * len(s))