Skip to content

Commit

Permalink
image builder: Accept ~ and ~user on command line
Browse files Browse the repository at this point in the history
When using the following command syntax:

    rfnoc_image_builder --fpga-dir=~/path/to/uhd/fpga \
                        --yaml-config=~/path/to/image_core.yml

The shell won't expand the ~ (shorthand for $HOME) and the image builder
needs to expand the path itself, which is fixed in this commit (for
--fpga-dir, --yaml-config, and --grc-config).

Note that this is not a problem when skipping the "=", i.e., the
following work without this fix, assuming a shell that auto-expands the
tilde symbol (e.g., bash, zsh):

    rfnoc_image_builder --fpga-dir ~/path/to/uhd/fpga \
                        --yaml-config ~/path/to/image_core.yml

or

    rfnoc_image_builder -F ~/path/to/uhd/fpga \
                        -y ~/path/to/image_core.yml
  • Loading branch information
mbr0wn authored and joergho committed Nov 7, 2024
1 parent cc354e7 commit d30fde9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions host/utils/rfnoc_image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def get_fpga_path(args):
"""
# If a valid path is given, use that
if args.fpga_dir:
if os.path.isdir(args.fpga_dir):
fpga_path = os.path.abspath(args.fpga_dir)
fpga_path = os.path.normpath(os.path.abspath(os.path.expanduser(args.fpga_dir)))
if os.path.isdir(fpga_path):
logging.info("Using FPGA directory %s", fpga_path)
return fpga_path
else:
Expand Down Expand Up @@ -262,7 +262,8 @@ def main():
args = setup_parser().parse_args()
rfnoc_log.init_logging(args.color, args.log_level)

source = args.yaml_config if args.yaml_config else args.grc_config
source_arg = args.yaml_config if args.yaml_config else args.grc_config
source = os.path.normpath(os.path.abspath(os.path.expanduser(source_arg)))
source_type = "yaml" if args.yaml_config else "grc"
if not os.path.isfile(source):
logging.error("Source file %s does not exist", source)
Expand Down

0 comments on commit d30fde9

Please sign in to comment.