Skip to content
Snippets Groups Projects

Use argparse only if name is main, call main with args dict

Merged Robert Rosca requested to merge refactor/adjust-webservice-cli into master

Description

Working on the tests, mildly annoyed by way the webservice uses argparse and how it's started so I changed it a bit:

  • Adjusted some of the command line argument names and variable names so that they match
  • Argparse setup is only done if webservice.py is called by python (if __name__ == "__main__")
  • Changed the main function to take in keyword arguments
  • Splat argparse args dict into main if called by python

NOTE: --logging has changed to --log-level

How Has This Been Tested?

Not at all

Called it manually with some print stuff:

❯ python3 ./webservice/webservice.py --log-level DEBUG
{'config_file': './webservice.yaml', 'mode': 'sim', 'log_file': './web.log', 'log_level': 'DEBUG'}
./webservice.yaml sim ./web.log DEBUG

Seems to work.

Relevant Documents (optional)

N/A

Types of changes

  • Style (formatting changes only, no code changes)
  • Refactor (refactoring code with no functionality changes)

Checklist:

  • My code follows the code style of this project.

Reviewers

@danilevc @schmidtp @kluyvert

Edited by Robert Rosca

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Robert Rosca added 2 commits

    added 2 commits

    Compare with previous version

  • Robert Rosca added 2 commits

    added 2 commits

    Compare with previous version

  • Robert Rosca added 1 commit

    added 1 commit

    Compare with previous version

  • Robert Rosca added 1 commit

    added 1 commit

    Compare with previous version

  • Robert Rosca added 1 commit

    added 1 commit

    Compare with previous version

  • Robert Rosca added 1 commit

    added 1 commit

    Compare with previous version

  • Robert Rosca resolved all discussions

    resolved all discussions

  • Robert Rosca enabled an automatic merge when the pipeline for e26bc835 succeeds

    enabled an automatic merge when the pipeline for e26bc835 succeeds

  • merged

  • Robert Rosca mentioned in commit 2f9b4860

    mentioned in commit 2f9b4860

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading