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

Fix leapp prints nothing when running with no args on python3.6+ #731

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

MichalHe
Copy link
Member

@MichalHe MichalHe commented Sep 2, 2021

A change introduced in the stdlib argparse module accidentally caused
all subparsers to become optional instead of required as in python 2.7.
This change therefore causes leapp to print nothing and exit with error
code 0 when being executed without any arguments.

This commit marks the subparser action as required, so that the
python3.6 module recognizes this situation and prints the usage message.

To provide a meaningful message on python3.6 the subparser action was
edited to use 'command' metavar and the 'title' option was dropped.

Tasks to be done:

  • verify that the usage message when using python2.7 did not become somehow unreadable due to the metavar/title changes performed.

@centos-ci
Copy link

Can one of the admins verify this patch?

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

Thank you for contributing to the Leapp project!

Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergable.
If you want to re-run tests or request review, you can use following commands as a comment:

  • leapp-ci build to run copr build and e2e tests in OAMG CI
  • review please to notify leapp developers of review request

Please open ticket in case you experience technical problem with the CI. (RH internal only)

Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please consider rerunning the CI by commenting leapp-ci build (might require several comments). If the problem persists, contact leapp-infra.

A change introduced in the stdlib argparse module accidentally caused
all subparsers to become optional instead of required as in python 2.7.
This change therefore causes leapp to print nothing and exit with error
code 0 when being executed without any arguments.

This commit marks the subparser action as required, so that the
python3.6 module recognizes this situation and prints the usage message.

To provide a meaningful message on python3.6 the subparser action was
edited to use 'command' metavar and the 'title' option was dropped.
@MichalHe MichalHe force-pushed the fix_argparse_optional_subparser branch from 35de37b to dbfc496 Compare September 2, 2021 14:42
@leapp-bot
Copy link
Collaborator

This PR has been linked in issue tracker (#OAMG-5488).

@MichalHe
Copy link
Member Author

MichalHe commented Sep 2, 2021

The usage message running python2.7 without any arguments is changed by this PR to (notice the added metavar command):

usage: leapp [-h] [--version] command ...

Optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit

Required arguments:
  command
    answer    Manage answerfile generation: register persistent user choices
              for specific dialog sections
    upgrade   Upgrade the current system to the next available major version.
    list-runs
              List previous Leapp upgrade executions
    preupgrade
              Generate preupgrade report
    rerun     Re-runs the upgrade from the given phase and using the
              information and progress from the last invocation of leapp
              upgrade.
error: too few arguments

Running leapp with no arguments on python3.6 outputs (with exit code 2):

usage: leapp [-h] [--version] command ...

Optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit

Required arguments:
  command
    answer    Manage answerfile generation: register persistent user choices
              for specific dialog sections
    list-runs
              List previous Leapp upgrade executions
    preupgrade
              Generate preupgrade report
    rerun     Re-runs the upgrade from the given phase and using the
              information and progress from the last invocation of leapp
              upgrade.
    upgrade   Upgrade the current system to the next available major version.
error: the following arguments are required: command

@MichalHe MichalHe changed the title [WIP] Fix leapp prints nothing when running with no args on python3.6. Fix leapp prints nothing when running with no args on python3.6. Sep 3, 2021
@MichalHe MichalHe marked this pull request as ready for review September 3, 2021 08:29
@pirat89 pirat89 changed the title Fix leapp prints nothing when running with no args on python3.6. Fix leapp prints nothing when running with no args on python3.6+ Sep 3, 2021
Copy link
Member

@pirat89 pirat89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works as expected.

@pirat89 pirat89 merged commit c835dba into oamg:master Sep 3, 2021
pirat89 added a commit to pirat89/leapp that referenced this pull request Oct 19, 2021
## Packaging
- Drop the dependency on leapp-repository for Fedora and RHEL 8+ (oamg#717)
- Provide builds for RHEL 7+ and Fedora (oamg#717)
- Drop automatically generated Python dependences on RHEL 8+ and Fedora systems (oamg#717, oamg#716)
- Bump the provided leapp-framework capability to 2.0 (oamg#700)

## Framework
### Fixes
- models: Do not make references to private symbols (oamg#718)

### Enhancements
- Introduce the LEAPP_DEVEL_DATABASE_SYNC_OFF envar to enable speed up writes into the leapp database by disabling synchronisation - only for development / testing purposes (oamg#732)

## Leapp
### Fixes
- Fix print of the leapp help msg for Python 3.6+ (oamg#731)

### Enhancements
- The leapp commands are now defined/provided by leapp-repositories; leapp discovers the specified commands automatically (oamg#700)
- Add CLI support for `choices` and `default` for options of leapp commands (oamg#734)

## Modifications
- Makefile: Added the `fast_lint` target to apply linters just on files different from master (oamg#733)
@pirat89 pirat89 mentioned this pull request Oct 19, 2021
pirat89 added a commit to pirat89/leapp that referenced this pull request Oct 19, 2021
## Packaging
- Drop the dependency on leapp-repository for Fedora and RHEL 8+ (oamg#717)
- Provide builds for RHEL 7+ and Fedora (oamg#717)
- Drop automatically generated Python dependences on RHEL 8+ and Fedora systems (oamg#717, oamg#716)
- Bump the provided leapp-framework capability to 2.0 (oamg#700)

## Framework
### Fixes
- models: Do not make references to private symbols (oamg#718)

### Enhancements
- Introduce the LEAPP_DEVEL_DATABASE_SYNC_OFF envar to enable speed up writes into the leapp database by disabling synchronisation - only for development / testing purposes (oamg#732)

## Leapp
### Fixes
- Fix print of the leapp help msg for Python 3.6+ (oamg#731)

### Enhancements
- The leapp commands are now defined/provided by leapp-repositories; leapp discovers the specified commands automatically (oamg#700)
- Add CLI support for `choices` and `default` for options of leapp commands (oamg#734)

## Modifications
- Makefile: Added the `fast_lint` target to apply linters just on files different from master (oamg#733)
pirat89 added a commit that referenced this pull request Oct 19, 2021
## Packaging
- Drop the dependency on leapp-repository for Fedora and RHEL 8+ (#717)
- Provide builds for RHEL 7+ and Fedora (#717)
- Drop automatically generated Python dependences on RHEL 8+ and Fedora systems (#717, #716)
- Bump the provided leapp-framework capability to 2.0 (#700)

## Framework
### Fixes
- models: Do not make references to private symbols (#718)

### Enhancements
- Introduce the LEAPP_DEVEL_DATABASE_SYNC_OFF envar to enable speed up writes into the leapp database by disabling synchronisation - only for development / testing purposes (#732)

## Leapp
### Fixes
- Fix print of the leapp help msg for Python 3.6+ (#731)

### Enhancements
- The leapp commands are now defined/provided by leapp-repositories; leapp discovers the specified commands automatically (#700)
- Add CLI support for `choices` and `default` for options of leapp commands (#734)

## Modifications
- Makefile: Added the `fast_lint` target to apply linters just on files different from master (#733)
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

Successfully merging this pull request may close these issues.

4 participants