kunyavskiy / polygon-cli

Command-line tool for polygon
MIT License
58 stars 17 forks source link

Comitting error in scripts with blank lines or freemarker templates #30

Closed alex65536 closed 7 years ago

alex65536 commented 7 years ago

When I try to commit a generator script with freemarker templates or blank lines, the script crashes with the following exception:

Traceback (most recent call last):
  File "/home/alex256/.local/bin/polygon-cli", line 9, in <module>
    load_entry_point('polygon-cli==1.1.1', 'console_scripts', 'polygon-cli')()
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/polygon_cli.py", line 51, in main
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/actions/commit.py", line 74, in read_options
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/actions/commit.py", line 55, in process_commit
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/local_file.py", line 66, in update
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/problem.py", line 419, in upload_script
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/problem.py", line 398, in update_groups
  File "/home/alex256/.local/lib/python3.5/site-packages/polygon_cli-1.1.1-py3.5.egg/polygon_cli/utils.py", line 102, in parse_script_groups
ValueError: invalid literal for int() with base 10: b''

The script may look like this:

gen 1 2 3 > $
gen 4 5 6 > $

<#list 1..10 as x>
    gen 100 100 ${x} > $
    gen 100 101 ${x} > $
    gen 100 102 ${x} > $
</#list>

The bug is in parse_script_groups, which is trying to determine the test number. Some lines does not contain test numbers (such as freemarker templates and blanks), so the script thinks that an empty string is a test number and fails parsing it as an integer.

kunyavskiy commented 7 years ago

Good solution, is to just remove it, when Mike support groups natively by some script command. I ask him again about this.

I added some workaround. No it doesn't try to update groups, if no group tag in file. Also, empty lines are fixed (aren't they removed by polygon?). With freemarker it have no chances to work :(

alex65536 commented 7 years ago

Thank you, it seems to work now.