Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: all commands return exit code 1 #18

Closed
stardust85 opened this issue May 5, 2016 · 5 comments
Closed

regression: all commands return exit code 1 #18

stardust85 opened this issue May 5, 2016 · 5 comments
Milestone

Comments

@stardust85
Copy link
Member

stardust85 commented May 5, 2016

caused by #17

How to reproduce (unix):
echo foo > foo
artifact upload foo test com.example
echo $?

expected result:
upload succeeds
return code 0

current result:
upload succeeds
return code 1

@tantale
Copy link

tantale commented May 8, 2016

If fact, exit code is not handled: the return value of artifact.ArtifactCLI().run() is not used except in tests (or may be in client code – if any exist). So you need to add an explicit sys.exit(0).

Why it returns always 1? Because of the definition of the entry point (see bin/artifact in your virtualenv):

__requires__ = 'repositorytools'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('repositorytools', 'console_scripts', 'artifact')()
    )

The script calls artifact.ArtifactCLI().run() and use the return value as an exit code.

If it returns an integer, you'll get this exit code (module 128 and a sign).

$ python -c "import sys; sys.exit(0);"
$ echo $?
0

$ python -c "import sys; sys.exit(12);"
$ echo $?
12

But if the return value is not an integer you'll always get 1 (and a message is displayed).

$ python -c "import sys; sys.exit('bye.');"
bye.
$ echo $?
1

To make the entry points works, you need to return 0 in the repositorytools.cli.common.CLI.__call__ method:

    def __call__(self, *args):
        self.run(*args)
        return 0  # exit code

The documentation: https://docs.python.org/3/library/sys.html?highlight=sys.exit#sys.exit

@stardust85
Copy link
Member Author

Amazing investigation. Can you please prepare a pull request? Nothing else than tests uses return codes from the run() method AFAIK. Don't forget to put yourself to AUTHORS file in root directory (and please add me there as well :) I'd like to release a bugfix version by end of this week.

@tantale
Copy link

tantale commented May 9, 2016

To list all the contributors:

git log --format='%aN <%aE>' | awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d\  -f2-

Source: http://www.commandlinefu.com/commands/view/4519/list-all-authors-of-a-particular-git-project

@tantale
Copy link

tantale commented May 9, 2016

What do you think of this kind of AUTHORS.rst file:

=======
Credits
=======

Development Lead
----------------

* Michel SAMIA <stardust1985@gmail.com>

Contributors
------------

* Laurent LAPORTE <tantale.solutions@gmail.com>

@stardust85
Copy link
Member Author

Perfect, exactly what I was thinking of. Maybe that file isn't necessary (git log works well), but I wanted to use it to motivate people for contributions :)

@stardust85 stardust85 added this to the 4.2.1 milestone May 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants