![]() |
argparser not showing all options - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: argparser not showing all options (/thread-42165.html) |
argparser not showing all options - bigal - May-22-2024 I have a python project with several command line (argparser) options which have been working. I went to modify the --scan arg to accept a integer and now several of the options are not being accepted with the error: error: unrecognized arguments: --radio airspy --scan They are also not shown when I run myproject -h - despite being present in the code as arg options. This started when I created a issue on GitHub for myproject and then a new branch based on the issue. I checked this branch out on VSCode to add a integer option to the argparser for --scan. In a further effort to isolate the cause I then tried to check out the previously working branch and it too now gets unrecognised arguments error. I am trying the command myproject --radio airspy --center-freq 160500000 --carrier 160380123 --scan My full arg parser code is here: p = argparse.ArgumentParser() p.add_argument( "-f", "--from-file", dest="infile", help="Read samples from the given filename and process them", ) p.add_argument( "-db", "--database", dest="db", default=None, help="SQLite database where to store processed results. Defaults to `main.db`. Environment variable KIWITRACKER_DB has priority.", ) p.add_argument( "-d", "--delete-database", dest="deletedb", action="store_true", help="If SQLite database file exists upon start, it is deleted.", ) p.add_argument( "-o", "--outfile", dest="outfile", help="Read samples from the device and save to the given filename", ) p.add_argument( "-m", "--max-samples", dest="max_samples", type=int, help='Number of samples to read when "-o/--outfile" is specified', ) p.add_argument( "--scan", dest="scan", action="store_true", help="Scan for frequencies in first 3sec", ) p.add_argument( "--no-use-gps", dest="no_use_gps", action="store_true", help="Set this flag to not use GPS module", ) p.add_argument( "--radio", default="rtl", const="rtl", nargs="?", choices=["rtl", "airspy", "dummy"], help="type of radio to be used (default: %(default)s), ignored if reading samples from disk.", ) s_group = p.add_argument_group("Sampling") s_group.add_argument( "-c", "--chunk-size", dest="chunk_size", type=int, default=SampleConfig.read_size, help="Chunk size for sdr.read_samples (default: %(default)s)", ) s_group.add_argument( "-s", "--sample-rate", dest="sample_rate", type=float, default=SampleConfig.sample_rate, help="SDR sample rate (default: %(default)s)", ) s_group.add_argument( "--center-freq", dest="center_freq", type=float, default=SampleConfig.center_freq, help="SDR center frequency (default: %(default)s)", ) s_group.add_argument( "-g", "--gain", dest="gain", type=float, default=SampleConfig.gain, help="SDR gain (default: %(default)s)", ) s_group.add_argument( "--bias-tee", dest="bias_tee", action="store_true", help="Enable bias tee", ) s_group.add_argument( "-log", "--loglevel", default="warning", help="Provide logging level. Example --loglevel debug, default=warning" ) p_group = p.add_argument_group("Processing") p_group.add_argument( "--carrier", dest="carrier", type=float, nargs="?", const=ProcessConfig.carrier_freq, # default=ProcessConfig.carrier_freq, help="Carrier frequency to process (default: %(default)s)", ) args = p.parse_args()And if I try myproject -h several options are missing: It feels like a configuration option. The setup is VSCode 1.89 and I am running on Windows 10 but editing the code on a remote RaspPi over ssh shell from VS Code.I have saved the project several times. What is causing these options not to be picked up? RE: argparser not showing all options - deanhystad - May-22-2024 Please post the code that generates your error, not the code that works. |