Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't generate html output when running with scancode #844

Closed
aalexanderr opened this issue Dec 15, 2020 · 8 comments
Closed

Can't generate html output when running with scancode #844

aalexanderr opened this issue Dec 15, 2020 · 8 comments
Labels
bug Something went wrong

Comments

@aalexanderr
Copy link
Contributor

Describe the bug
Can't generate html output when running tern with scancode:

To Reproduce
Steps to reproduce the behavior:

  1. git clone "https://gerrit.onap.org/r/integration/docker/onap-python"
  2. cd onap-python
  3. either:
    1. docker build -t onappython - < Dockerfile && tern report -x scancode -f html -o report.html -i onappython:latest
    2. tern report -x scancode -f html -o report.html -d Dockerfile
  4. See error

Error in terminal

2020-12-15 22:22:03,866 - DEBUG - executor - Collecting file data...
2020-12-15 22:22:04,104 - DEBUG - generator - Creating HTML report...
Traceback (most recent call last):
  File "/home/vagrant/ternenv/bin/tern", line 8, in <module>
    sys.exit(main())
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/__main__.py", line 192, in main
    do_main(args)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/__main__.py", line 95, in do_main
    crun.execute_image(args)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/analyze/default/container/run.py", line 87, in execute_image
    report.report_out(args, full_image)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/report/report.py", line 70, in report_out
    report = generate_report(args, *images)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/report/report.py", line 50, in generate_report
    return generate_format(images, args.report_format)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/report/report.py", line 64, in generate_format
    return mgr.driver.generate(images)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/formats/html/generator.py", line 299, in generate
    report = create_html_report(report_dict, image_obj_list)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/formats/html/generator.py", line 278, in create_html_report
    report = report + '\n' + write_licenses(image_obj_list)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/formats/html/generator.py", line 256, in write_licenses
    licenses = get_licenses_only(image_obj_list)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/report/content.py", line 40, in get_licenses_only
    pkg_licenses = get_layer_packages_licenses(layer)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/report/content.py", line 19, in get_layer_packages_licenses
    package_licenses = get_package_licenses(package)
  File "/home/vagrant/ternenv/lib/python3.6/site-packages/tern/report/content.py", line 54, in get_package_licenses
    pkg_licenses.add(package.pkg_license)
TypeError: unhashable type: 'dict'

Expected behavior
Get a html report

Environment you are running Tern on
Enter all that apply

  • Output of 'tern --version'
    Tern version 2.3.0
    python version = 3.6.12 (default, Aug 17 2020, 23:45:20)
  • Operating System (Linux Distro and version or Mac or Windows)
    Ubuntu 20.04
  • Vagrant file
    Vagrantfile.txt
    (had to add extension otherwise github complained it is not supported)
  • Container OS
    N/A
  • Python version (3.6 or higher)
    Python 3.6.12
  • Cloud environment (AWS, Azure, GCP)
    N/A

Please attach files if they exist

@rnjudge
Copy link
Contributor

rnjudge commented Dec 16, 2020

@abhaykatheria do you want to take a look at this?

@abhaykatheria
Copy link
Contributor

Oh ok cool.

@abhaykatheria
Copy link
Contributor

@aalexanderr @rnjudge I ran tern on the given image using same commands(BOTH OF THEM) and it ran well.
Here's the report I got.
report.html

And these are the logs

tern report -x scancode -f html -o report.html -d Dockerfile
log-1
tern.log

docker build -t onappython - < Dockerfile && tern report -x scancode -f html -o report.html -i onappython:latest
log-2
tern.log

@aalexanderr I would recommend updating tern and scancode-toolkit.

@aalexanderr
Copy link
Contributor Author

aalexanderr commented Dec 18, 2020

@abhaykatheria
What version of tern did you use? The html report links to this commit:
c8f336a
but it shows me 404.

I've checked your fork but the only active branch I see (master) is the same as here.

Both tern and scancode I used are latest releases. Same with python- latest release of 3.6.

$ scancode --version
ScanCode version 3.2.3
Tern version:
$ tern --version
Tern version 2.3.0
python version = 3.6.12 (default, Aug 17 2020, 23:45:20)

(before submitting I have verifed it on 2 different host machines with different vagrant versions and two different versions of generic/ubuntu2004 versions (latest and a bit older one).

@abhaykatheria
Copy link
Contributor

abhaykatheria commented Dec 19, 2020

I installed it manually from the source code (Instructions are in contribution.md). I didn't made any commits I checked the git logs. its strange the commit hash in report is pointing to nowhere. @rnjudge can you take a look at this ..?

@aalexanderr
Copy link
Contributor Author

aalexanderr commented Dec 29, 2020

I did everything as in linked contributing, then pip3 install scancode-toolkit[full] and went with steps to reproduce.
It resulted in the same error as initially reported.
BTW the unknown hash is the last commit from the onap-python repo :)
Additionally, the report you've linked has no licenses listed :(

@rnjudge rnjudge added the bug Something went wrong label Jan 31, 2021
@rnjudge
Copy link
Contributor

rnjudge commented Jun 4, 2021

Bumping the priority on this. Will work on a fix in the next week or two. @abhaykatheria if you have time, would be lovely for you to take a look also ;) We have two users reporting issues with the html format when using scancode.

rnjudge added a commit to rnjudge/tern that referenced this issue Jul 6, 2021
There was a traceback error running Tern with Scancode for multiple
report formats due to Scancode reporting licenses as a list containing a
single string or a list containing a license dictionary when Tern was
expecting just a string. This commit resolves the issue by parsing the
license list to get the license text before assigning it to a Package
object's 'pkg_license' value.

Resolves tern-tools#985 tern-tools#844

Signed-off-by: Rose Judge <[email protected]>
rnjudge added a commit that referenced this issue Jul 6, 2021
There was a traceback error running Tern with Scancode for multiple
report formats due to Scancode reporting licenses as a list containing a
single string or a list containing a license dictionary when Tern was
expecting just a string. This commit resolves the issue by parsing the
license list to get the license text before assigning it to a Package
object's 'pkg_license' value.

Resolves #985 #844

Signed-off-by: Rose Judge <[email protected]>
@rnjudge
Copy link
Contributor

rnjudge commented Jul 6, 2021

@aalexanderr Sincere apologies for the delay on this fix. Should work now.

@rnjudge rnjudge closed this as completed Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong
Projects
None yet
Development

No branches or pull requests

3 participants