haykeh / capirca

Automatically exported from code.google.com/p/capirca
Apache License 2.0
0 stars 0 forks source link

TypeError in warning for mismatched ports/protocols #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In revision r133 in file lib/policy.py the warning for mismatched 
ports/protocols was broken. There was a comma lost between the last two 
parameters to the % operator in line 120:

https://code.google.com/p/capirca/source/diff?spec=svn141&r=133&format=side&path
=/trunk/lib/policy.py&old_path=/trunk/lib/policy.py&old=132

Right now this piece of code crashes with:

Traceback (most recent call last):
  File "./aclgen.py", line 140, in ?
    main()
  File "./aclgen.py", line 127, in main
    count = render_filters(FLAGS.policy, policy.ParsePolicy(open(FLAGS.policy).read(), defs))
  File "/home/nms/devel/capirca/src/lib/policy.py", line 1480, in ParsePolicy
    return p.parse(preprocessed_data, lexer=lexer)
  File "/home/nms/devel/capirca/capirca/third_party/ply/yacc.py", line 265, in parse
  File "/home/nms/devel/capirca/capirca/third_party/ply/yacc.py", line 971, in parseopt_notrack
  File "/home/nms/devel/capirca/src/lib/policy.py", line 1101, in p_target
    p[0] = Policy(p[2], p[3])
  File "/home/nms/devel/capirca/src/lib/policy.py", line 147, in __init__
    self.AddFilter(header, terms)
  File "/home/nms/devel/capirca/src/lib/policy.py", line 152, in AddFilter
    self._TranslateTerms(terms)
  File "/home/nms/devel/capirca/src/lib/policy.py", line 178, in _TranslateTerms
    term.protocol, term.name)
  File "/home/nms/devel/capirca/src/lib/policy.py", line 117, in TranslatePorts
    logging.warn('%s %s %s %s %s %s %s%s' % (
TypeError: not enough arguments for format string

Also, the string template should be changed to:
'%s %s %s %s %s %s%s %s'

to prevent an extra space before the comma.

Original issue reported on code.google.com by ma...@vadnjal.net on 7 Aug 2011 at 4:02

GoogleCodeExporter commented 9 years ago
Thanks for reporting this.  Fixed in r142.

Original comment by watson@google.com on 9 Aug 2011 at 7:51