[PATCH] Fix return code when getting patch information fails

Ali Alnubani alialnu at mellanox.com
Tue Jan 8 23:38:45 AEDT 2019


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 at mellanox.com>
---
 pwclient/shell.py | 6 ++++++
 1 file changed, 6 insertions(+)

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))
-- 
2.11.0



More information about the Patchwork mailing list