May-22-2024, 12:58 AM
(This post was last modified: May-22-2024, 02:40 AM by deanhystad.)
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:
And if I try myproject -h several options are missing:
I have saved the project several times.
What is causing these options not to be picked up?
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
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() |
Output:$ myproject -h
usage: myproject [-h] [-f INFILE] [-o OUTFILE] [-m MAX_SAMPLES] [-c CHUNK_SIZE] [-s
SAMPLE_RATE] [--center-freq CENTER_FREQ] [-g GAIN] [--bias-tee] [--carrier CARRIER]
options:
-h, --help show this help message and exit
-f INFILE, --from-file INFILE
Read samples from the given filename and process them
-o OUTFILE, --outfile OUTFILE
Read samples from the device and save to the given filename
-m MAX_SAMPLES, --max-samples MAX_SAMPLES
Number of samples to read when "-o/--outfile" is specified
Sampling:
-c CHUNK_SIZE, --chunk-size CHUNK_SIZE
Chunk size for sdr.read_samples (default: 65536)
-s SAMPLE_RATE, --sample-rate SAMPLE_RATE
SDR sample rate (default: 1024000.0)
--center-freq CENTER_FREQ
SDR center frequency (default: 160270968)
-g GAIN, --gain GAIN SDR gain (default: 7.7)
--bias-tee Enable bias tee
Processing:
--carrier CARRIER Carrier frequency to process (default: 160270968)
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?
deanhystad write May-22-2024, 02:40 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.