Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 7d16d7c2e43f0d5fd3d01bda91ddedbe52f0bdef
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Tue Apr 29 15:04:32 2014 +0200
[cli] exit code 4 for failed build and man pages updated
---------------------------------------------------------------
cli/copr_cli/copr_exceptions.py | 9 ++++++++-
cli/copr_cli/main.py | 3 +++
cli/copr_cli/subcommands.py | 2 +-
cli/man/copr-cli.1.asciidoc | 11 +++++++++++
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/cli/copr_cli/copr_exceptions.py b/cli/copr_cli/copr_exceptions.py
index 4be2f06..1e10678 100644
--- a/cli/copr_cli/copr_exceptions.py
+++ b/cli/copr_cli/copr_exceptions.py
@@ -26,12 +26,19 @@ class CoprCliConfigException(CoprCliException):
class CoprCliRequestException(Exception):
- """ Exception thrown when server says no. For example,
+ """ Exception thrown when the request is bad. For example,
the user provided wrong project name or build ID.
"""
pass
+class CoprCliBuildException(Exception):
+ """ Exception thrown when one or more builds fail and Cli is waiting
+ for the result.
+ """
+ pass
+
+
class CoprCliUnknownResponseException(Exception):
""" Exception thrown when the response is unknown to cli.
It usualy means that something is broken.
diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py
index 477ac0e..597b57a 100644
--- a/cli/copr_cli/main.py
+++ b/cli/copr_cli/main.py
@@ -172,6 +172,9 @@ def main(argv=sys.argv[1:]):
except ConfigParser.ParsingError, e:
sys.stderr.write("\nError: {0}\n".format(e))
sys.stderr.write("Lines in INI file should not be indented.\n")
+ sys.exit(3)
+ except copr_exceptions.CoprCliBuildException, e:
+ sys.stderr.write("\nBuild error: {0}\n".format(e))
sys.exit(4)
except copr_exceptions.CoprCliUnknownResponseException, e:
sys.stderr.write("\nError: {0}\n".format(e))
diff --git a/cli/copr_cli/subcommands.py b/cli/copr_cli/subcommands.py
index 113a8bd..7f2215b 100644
--- a/cli/copr_cli/subcommands.py
+++ b/cli/copr_cli/subcommands.py
@@ -295,7 +295,7 @@ def build(copr, pkgs, memory, timeout, wait=True, result=None,
chroots=None):
time.sleep(60)
if failed_ids:
- raise copr_exceptions.CoprCliRequestException(
+ raise copr_exceptions.CoprCliBuildException(
"Build(s) {0} failed.".format(
", ".join(str(x) for x in failed_ids)))
diff --git a/cli/man/copr-cli.1.asciidoc b/cli/man/copr-cli.1.asciidoc
index ef9ada9..b748ab9 100644
--- a/cli/man/copr-cli.1.asciidoc
+++ b/cli/man/copr-cli.1.asciidoc
@@ -101,6 +101,17 @@ pkg_url::
URL of the package to build. The package must be placed on a public web or
ftp server.
+EXIT STATUS
+-----------
+Normally, the exit code is 0 when everything goes well. But if not, we could get:
+1 - Bad request like wrong project name, insufficient rights etc.
+ Also might happen when user interrupts the operation when they shouldn't.
+2 - Wrong arguments given.
+3 - Bad or no configuration.
+4 - Build fails when Cli is waiting for the result.
+5 - Communication error between Cli and server.
+ This issue probably means bug and should be reported.
+
API KEY
-------