Changeset 14093 in genesis for tools/gformat.py


Ignore:
Timestamp:
Mar 28, 2018, 2:30:13 PM (7 years ago)
Author:
rick
Message:

Fix parent generation fails if no tree is found.

Ignore parents if no path is found, parents dependencies at WL
if a difficult concept, since it is rather ... ehm .. dynamic :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r14055 r14093  
    19451945      stack = ['root']
    19461946      prev_depth = 0
    1947       for line in open('lvrouted.mytree').readlines():
    1948         depth = line.count('\t')
    1949         ip = line.strip().split()[0]
    1950      
    1951         if prev_depth < depth:
    1952           try:
    1953             parents[ip2host[ip]].append(ip2host[stack[-1]])
    1954           except KeyError as e:
    1955             print >> stderr, "# Unable to find %s in configuration files" % e.args[0]
    1956           stack.append(ip)
    1957         elif prev_depth > depth:
    1958           stack = stack[:(depth - prev_depth)]
    1959         elif prev_depth == depth:
    1960           try:
    1961             parents[ip2host[ip]].append(ip2host[stack[-1]])
    1962           except KeyError as e:
    1963             print >> stderr, "# Unable to find %s in configuration files" % e.args[0]
     1947      if os.path.isfile('lvrouted.mytree'):
     1948        for line in open('lvrouted.mytree').readlines():
     1949          depth = line.count('\t')
     1950          ip = line.strip().split()[0]
     1951       
     1952          if prev_depth < depth:
     1953            try:
     1954              parents[ip2host[ip]].append(ip2host[stack[-1]])
     1955            except KeyError as e:
     1956              print >> stderr, "# Unable to find %s in configuration files" % e.args[0]
     1957            stack.append(ip)
     1958          elif prev_depth > depth:
     1959            stack = stack[:(depth - prev_depth)]
     1960          elif prev_depth == depth:
     1961            try:
     1962              parents[ip2host[ip]].append(ip2host[stack[-1]])
     1963            except KeyError as e:
     1964              print >> stderr, "# Unable to find %s in configuration files" % e.args[0]
    19641965
    19651966
Note: See TracChangeset for help on using the changeset viewer.