gnetlist bom trips on missing attrib file

Bug #810202 reported by KaiMartin
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gEDA
Fix Released
Medium
Jared Casper

Bug Description

(as reported to geda-user by Girvin R. Herr)

If there is no attribs file around, the backends bom and bom2 crash with an irritating error message on the command line:

/---------------------------------------
$gnetlist -g bom xx.sch
    Loading schematic
    [/home/gherr/projects/vds160/original/hardware/dac/docs/xx.sch]
    Backtrace:
    In current input:
        1: 0* [bom "output.net"]
    In /usr/local/share/gEDA/scheme/gnet-bom.scm:
       37: 1 (let ((port #) (attriblist #)) (bom:printlist (cons #
    attriblist) port) ...)
       40: 2* [bom:parseconfig ...
       40: 3* [open-input-file "attribs"]
    In unknown file:
        ?: 4 [open-file "attribs" "r"]

    <unnamed port>: In procedure open-file in expression (open-file str
    OPEN_READ):
    <unnamed port>: No such file or directory: "attribs"
\-------------------------------

Suggestions:
1) Check for the existence of the attribs file.

2a) Issue a newbie friendly message, if not.

2b) produce a sensible default attribs file on the fly.

3) accept a file name on the command line, so you can have different attribs files for the same project

4) accept a string on the command line to replace the contents of the attribs file

---<)kaimartin(>---

Tags: gnetlist bom bom2
Revision history for this message
Jared Casper (jaredcasper) wrote :

Attached patch implements all of the suggestions except for 2b. 2b wouldn't be hard to implement but I think any "sensible default" would be debatable.

Comments/suggestions welcome.

Revision history for this message
Peter TB Brett (peter-b) wrote :

Hey Jared,

That's an awesome patch! I've got a few questions:

- Is it possible to specify an attribute containing a ',' in its name on the command line?
- What happens if backend-getopt raises an error (e.g. due to a missing argument to '-Oattribs')?
- What happens if an '-Oattribs' argument is specified, and an attribs file is also found or specified? My suspicion is that the "right thing" would be for the '-Oattribs' list to override rather than add to the list from the file...

Thanks for working on this!

Changed in geda:
assignee: nobody → Jared Casper (jaredcasper)
importance: Undecided → Medium
status: New → In Progress
tags: added: bom bom2 gnetlist
Revision history for this message
Jared Casper (jaredcasper) wrote :

1. No, I chose the comma as the delimiter for simplicity. I guess we could check for an escaped comma or something but it didn't seem worth it. I'm not familiar with Guile's string processing, but it's possible there is something smarter than string-split.

2. backend-getopt print out the error message, which includes a backtrace (I guess because of the use of scm-error?). Things exit out gracefully after that as far as I can tell. The backtrace makes the error message seem a little more intimidating, but last line should be reasonable (e.g. "Backend options 'attribs' requires an argument")

3. -Oattribs takes precedence and overrides anything in the file (either attribs or a specified file).

Revision history for this message
gpleda.org commit robot (gpleda-launchpad-robot) wrote :

Bug was fixed by a commit
git master commit 76bc345ee043764b919980c3de6d27f78546cf73
http://git.gpleda.org/?p=gaf.git;a=commit;h=76bc345ee043764b919980c3de6d27f78546cf73

commit 76bc345ee043764b919980c3de6d27f78546cf73
Author: Jared Casper <email address hidden>
Commit: Peter TB Brett <email address hidden>

    gnetlist: bom/bom2 backend attribute list improvements

    - Checks for the existence of the attribute file, gives a helpful error
      message if none is found (no default)

    - Adds an attrib_file command line option to the backend for
      specifying an alternate attribute file

    - Adds an attribs command line option for specifying the attributes
      directly from the command line

    Closes-bug: lp-810202

Changed in geda:
status: In Progress → Fix Committed
Revision history for this message
Peter TB Brett (peter-b) wrote :

Thanks again for the patch. We should probably eventually provide a way to give attribute names with commas in to the "-Oattribs" option, but I don't consider it urgent because putting commas in attribute names is disencouraged anyway (per recent discussions on the gEDA-user mailing list.

Very nice to see code using my backend-getopt module, by the way!

Changed in geda:
milestone: none → 1.7.2
Revision history for this message
Peter TB Brett (peter-b) wrote :

It turns out that this commit broke "make distcheck". I'm looking into it!

Revision history for this message
gpleda.org commit robot (gpleda-launchpad-robot) wrote :

A commit was made which affects this bug
git master commit fde0b77b96ef92d5e220dafeb31c92c03f7df0bf
http://git.gpleda.org/?p=gaf.git;a=commit;h=fde0b77b96ef92d5e220dafeb31c92c03f7df0bf

commit fde0b77b96ef92d5e220dafeb31c92c03f7df0bf
Author: Peter TB Brett <email address hidden>
Commit: Peter TB Brett <email address hidden>

    gnetlist: Regenerate `bom' and `bom2' test results.

    In commit 76bc345ee043, the `bom' and `bom2' backends were modified to
    be more informative about attribute list specifications. As a
    side-effect of this work, the backend options for these backends are
    now much more strictly validated. Tests which pass `-O include_mode'
    or `-O sort_mode' to gnetlist therefore now fail for the BOM backends,
    and this patch updates the golden files appropriately.

    Affects-bug: lp-810202
    Reported-by: Dan McMahill <email address hidden>

Peter TB Brett (peter-b)
Changed in geda:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.