[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Set a command line parameter value from config fi
From: |
Michael Matthews |
Subject: |
Re: [Discuss-gnuradio] Set a command line parameter value from config file --OR-- override a "variable config" with a command line parameter |
Date: |
Tue, 21 Jun 2016 05:56:11 -0700 |
Thanks, Marcus. I tried embedding this logic in a custom "variable config" block, which exists only in XML, but saw no way to connect command-line options. So I tried a custom "parameter config" block based on parameter.xml but it seems that the GRC-to-Python converter recognizes only the ID "parameter" when it creates command options. So I just added it to the argument parser code post facto as follows. It's less preferred, but it works.
def argument_parser():
import ConfigParser
config = ConfigParser.ConfigParser()
config.read("config_file.conf")
parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
parser.add_option(
"-d", "--delay", dest="delay", type="eng_float", default=config.get("Parameters", "delay"),
help="Set Delay [default=%default]")